Telegram setup

It will be necessary to create and setup a bot to manipulate all the files in an archive chat.

Bot

  1. Start a chat with BotFather
  2. Send the following message: /newbot
  3. Choose a name
  4. Choose a unique username that we are going to reference with <BOT_USERNAME>
  5. If the creation successes, BotFather will send you a message with the bot token, that we are going to reference with <BOT_TOKEN>

Archive chat

  1. Create a group chat named Archive
  2. Make the Archive group chat as a topic chat by editing the following settings:
    Group info -> Edit group, Topics toggle is off -> Topics toggle to on
  3. Open Telegram Web K version
  4. Open: Archive group chat -> General topic
  5. Copy the chat ID in the browser URL. We are going to reference it with <GROUP_ARCHIVE>
  6. Add the bot <BOT_USERNAME> into the Archive group
  7. Give administrator privilege to the bot:
    Edit group -> Administrators -> Add Administrator, choose the bot -> Save

Firebase setup

It will be necessary to create a Firebase Realtime Database to store managed file metadata.

  1. Open Firebase
  2. Click on "Go to console"
  3. Create a new project by choosing a name and accepting Firebase terms
  4. Go to the project console
  5. Go to the "Build" section, open "Realtime Database" and press "Create Database"
  6. Go forward the "Set up database" wizard
  7. In the database dashboard you'll see an URL: it's the <FIREBASE_REALTIME_DATABASE_BASE_URL>
  8. Open "Rules" section and set the following code:

Server setup

It will be necessary to create a download folder and a settings file to connect the server with Telegram and the database.

Note

If you installed Node.js via WSL (Windows method), the terminal you need to open is the WSL.

Version 1 to 1.4.1

  1. Create a folder on your local computer to store downloaded files. We are going to reference its absolute path with <DOWNLOADS_FOLDER>
  2. Open the <REPOSITORY_FOLDER>server folder
  3. Create a file named .env and add the following code:
  4. Change <...> with the values obtained during this guide
  5. Open a terminal in the server folder and run the following command:
    npm install

Version 2+

  1. Create a folder on your local computer to store downloaded files. We are going to reference its absolute path with <DOWNLOADS_FOLDER>
  2. Open the <REPOSITORY_FOLDER>server/settings folder
  3. Duplicate config-template.json and rename the copy to config.json
  4. Look at this image to understand what will be meant by profile configuration
  5. Delete all profiles except the first one. In the last remaining profile (so the first one) the comma should not appear after the parentheses. Look at this image
  6. Change all placeholder values with the values obtained following this guide:
    • Change ACCOUNT_NAME_1 with a name you want to give to your profile: it’s a name of your choice.
    • Change TOKEN_1 with <BOT_TOKEN> value
    • Change CHATID_1 with -100<GROUP_ARCHIVE> value
    • Change DB_URL_1 with <FIREBASE_REALTIME_DATABASE_BASE_URL> value
  7. Leave active_account_index value to 1
  8. Change DOWNLOAD_FOLDER_PATH value to <DOWNLOADS_FOLDER>. If a \ character appears in the path, add another one right after it (see the download path declared in the example config.json file to understand)

Note: schedule folder deletion (version 2.1+)

Update 2.1 introduced scheduled deletion of downloaded folders.
Edit the config.json file and introduce a new attribute called future_deletion_minutes valued with numeric value that indicates after how many minutes you want to delete the folder. If this is your first time downloading HorizonGram and you downloaded version 2.1, you will find this attribute already included in your config.json file
It's an optional step: if you do not add this attribute, HorizonGram will continue to operate normally by automatically setting the scheduled deletion to 5 minutes.

Your config.json file should be similar to this one:

Add more profiles

To add new profiles you must repeat all the steps listed in Telegram setup and Firebase setup. Each profile must have a different bot, chat archive, and metadata database.
Suppose you followed the steps again, so you have a new <BOT_TOKEN>, <GROUP_ARCHIVE> and <FIREBASE_REALTIME_DATABASE_BASE_URL>:

  1. Open the <REPOSITORY_FOLDER>server/settings folder
  2. Open config.json
  3. Add a new profile by adding a comma between the last and the new. Look at this image
  4. Change all placeholder values with the values obtained following Telegram setup and Firebase setup:
    • Change ACCOUNT_NAME_X with a name you want to give to your profile: it’s a name of your choice.
    • Change TOKEN_X with <BOT_TOKEN> value
    • Change CHATID_X with -100<GROUP_ARCHIVE> value
    • Change DB_URL_X with <FIREBASE_REALTIME_DATABASE_BASE_URL> value

Shortcut setup

It's an optional step, but it may be useful to follow it so that you can start HorizonGram more quickly and conveniently.
Shortcuts allow you to start and change HorizonGram profiles with a single click, without having to edit the configuration file (config.json) and without having to manually start, via command, the server.

Note

Shortcuts are available starting from version 2.2

Warning

There is not and will not be shortcut support for macOS

Windows

  1. Open the <REPOSITORY_FOLDER>executors folder
  2. Duplicate windows-start-template.bat file and rename it - we will reference it with <STARTER_BAT>
  3. Duplicate windows-change-profile-template.bat file and rename it by giving it a name that refers to your HorizonGram profile - we will reference it with <CHANGE_PROFILE_BAT>
  4. Repeat the previous step by creating a copy of windows-change-profile-template.bat file, one for each HorizonGram profile set on the config.json file
  5. Edit <STARTER_BAT> by setting your server folder path
  6. Edit each <CHANGE_PROFILE_BAT> file by setting your server folder path and the profile ID (see lines 4 and 5) set on the config.json file.
    In this step, server path and profile ID should not be in the quotation marks.
  7. Move the duplicate files to a location on your pc that is convenient to you, such as the desktop
  8. Execute the files by double clicking them!

Linux

  1. Open the <REPOSITORY_FOLDER>executors folder
  2. Duplicate linux-start-template.sh file and rename it - we will reference it with <STARTER_SH>.
    You can use the following command: cp linux-start-template.sh <STARTER_SH>
  3. Duplicate linux-change-profile-template.sh file and rename it by giving it a name that refers to your HorizonGram profile - we will reference it with <CHANGE_PROFILE_SH>.
    You can use the following command: cp linux-change-profile-template.sh <CHANGE_PROFILE_SH>
  4. Repeat the previous step by creating a copy of linux-change-profile-template.sh file, one for each HorizonGram profile set on the config.json file
  5. Edit <STARTER_SH> by setting your server folder path
  6. Edit each <CHANGE_PROFILE_SH> file by setting your server folder path and the profile ID (see lines 4 and 5) set on the config.json file.
  7. Move the duplicate files to a location on your pc that is convenient to you.
  8. Execute the files using the following command: ./<CHOSEN_FILE>

Here's a full editing and utilization example:

  1. cp linux-start-template.sh start-horizongram.sh
  2. cp linux-change-profile-template.sh change-profile-to-personal.sh
  3. Editing files by setting variable values...
    vi start-horizongram.sh
    vi change-profile-to-personal.sh
  4. ./change-profile-to-personal.sh
  5. ./start-horizongram.sh