Skip to content

How to: Add New Accounts

Amin Mahmoudi edited this page Sep 21, 2024 · 5 revisions

How to: Add New Accounts

You can add new accounts to your MasterCryptoFarmBot using two methods:

This is the recommended method.

Pros: More access to your account, modules will be able to join channels for tasks, change name if needed for tasks, One-time login for all bots, etc.

Cons: You need to get API_ID and API_HASH from MyTelegram, and there will be a session in your Telegram account.

Pros: You don't need to get API_ID and API_HASH from My.Telegram.org, and there will be no session in your Telegram account.

Cons: You need to get WebAppInitData which could be hard for some users, with no full control over your account.


Using Pyrogram Sessions ~ [ RECOMMENDED ] ✅

Setup Telegram API & Hash

If the file config.py does not already exist, create a copy of config.py.example and rename it to config.py.

Visit my.telegram.org and log in with your Telegram account.

Navigate to the "API development tools" section.

Create a new application and take note of your api_id and api_hash.

Open your config.py file and add the api_id and api_hash values in their respective fields.


Navigate to your MasterCryptoFarmBot directory, then run python add_account.py on Windows or python3 add_account.py on Linux.

Then you will have 3 options:

1. Register new sessions

  1. You will be asked to enter a session_name, you can enter a valid (a-zA-Z0-9) session name of your choice or if you want to keep it simple just enter your account's telegram ID. Session Name will be stored locally and can be anything as long as it's not duplicated with another session name!
  2. Then you need to enter the phone number with the country code, for example: +12345678900 or +989123456789
  3. At this point, Pyrogram will be called and the rest will be handled by Pyrogram. You will have to enter the received code from Telegram and 2FA Password (if you've enabled 2FA).
  4. Upon successful registration, the application will let you know the session was created successfully and give you the basic info about the session, like userID, Name, UserName, Phone Number, and Session Name.

2. Import existing sessions

If you already have Pyrogram .session files, you would have to import them again as we store the data locally inside accounts.json, simply move your session files to the /telegram_accounts directory, and select this option. The application will check them for validity and let you know if the import was successful or not.

This is needed to attach some important data like user_agent, proxy, and activation status (should the account be used in modules?) to the session.

3. Exit

Self-explanatory


Using TgWebAppInitData

There are several ways to obtain Telegram WebApplication Initial Data, which is used to authorize bots using your Telegram accounts.

1. Using Telegram Desktop

  1. Open Telegram Desktop and head to Settings > Advanced > Experimental Settings > Enable WebView Inspecting.
  2. Open your desired bot's application (Hit Play / Launch Button), then open the developer tools (F12) and go to the Console tab.
  3. Paste the following code in the console and hit enter:
copy(Telegram.WebApp.initData)
  1. InitData is now copied to your clipboard.

2. Using Android

  1. Open your desired bot's application (Hit Play / Launch Button).
  2. Once it's loaded, turn off your device's Wi-Fi and mobile data, then refresh the page. you can find the refresh button in the top right corner of the screen.
  3. You should see a "Webpage not available" message, copy the URL that includes #tgWebAppData.

3. Using Web.Telegram.Org

  1. Open Telegram Web and head to your desired bot's application (Hit Play / Launch Button).
  2. Press F12 to open developer tools, then go to the Console tab.
  3. Paste the following code in the console and hit enter:
copy(document.querySelector('iframe')?.src || 'No iframe found.');
  1. InitData is now copied to your clipboard.

InitData Example:

https://major.glados.app/#tgWebAppData%3Dquery_id%3DREDACTED%26user%3D%7B%22id%22%3AREDACTED%2C%22first_name%22%3A%22REDACTED%22%2C%22last_name%22%3A%22%22%2C%22username%22%3A%22REDACTED%22%2C%22language_code%22%3A%22en%22%2C%22is_premium%22%3Atrue%2C%22allows_write_to_pm%22%3Atrue%7D%26auth_date%3DREDACTED%26hash%3DREDACTED%26tgWebAppVersion%3D7.8%26tgWebAppPlatform%3Dweba%26tgWebAppBotInline%3D1%26tgWebAppThemeParams%3D%7B%22bg_color%22%3A%22%23212121%22%2C%22text_color%22%3A%22%23ffffff%22%2C%22hint_color%22%3A%22%23aaaaaa%22%2C%22link_color%22%3A%22%238774e1%22%2C%22button_color%22%3A%22%238774e1%22%2C%22button_text_color%22%3A%22%23ffffff%22%2C%22secondary_bg_color%22%3A%22%230f0f0f%22%2C%22header_bg_color%22%3A%22%23212121%22%2C%22accent_text_color%22%3A%22%238774e1%22%2C%22section_bg_color%22%3A%22%23212121%22%2C%22section_header_text_color%22%3A%22%23aaaaaa%22%2C%22subtitle_text_color%22%3A%22%23aaaaaa%22%2C%22destructive_text_color%22%3A%22%23e53935%22%7D

OR - (both will work)

#tgWebAppData%3Dquery_id%3DREDACTED%26user%3D%7B%22id%22%3AREDACTED%2C%22first_name%22%3A%22REDACTED%22%2C%22last_name%22%3A%22%22%2C%22username%22%3A%22REDACTED%22%2C%22language_code%22%3A%22en%22%2C%22is_premium%22%3Atrue%2C%22allows_write_to_pm%22%3Atrue%7D%26auth_date%3DREDACTED%26hash%3DREDACTED%26tgWebAppVersion%3D7.8%26tgWebAppPlatform%3Dweba%26tgWebAppBotInline%3D1%26tgWebAppThemeParams%3D%7B%22bg_color%22%3A%22%23212121%22%2C%22text_color%22%3A%22%23ffffff%22%2C%22hint_color%22%3A%22%23aaaaaa%22%2C%22link_color%22%3A%22%238774e1%22%2C%22button_color%22%3A%22%238774e1%22%2C%22button_text_color%22%3A%22%23ffffff%22%2C%22secondary_bg_color%22%3A%22%230f0f0f%22%2C%22header_bg_color%22%3A%22%23212121%22%2C%22accent_text_color%22%3A%22%238774e1%22%2C%22section_bg_color%22%3A%22%23212121%22%2C%22section_header_text_color%22%3A%22%23aaaaaa%22%2C%22subtitle_text_color%22%3A%22%23aaaaaa%22%2C%22destructive_text_color%22%3A%22%23e53935%22%7D

so basically copy the whole URL or just #tgWebAppData to the end.