This guide provides a detailed, step-by-step installation and usage manual for the Telegram Account Switcher script. Follow these instructions carefully to set up and use the script effectively.
To run this script, you need to have the following installed:
- Python 3.8 or higher
- Pip (Python package installer)
- Flask library (
pip install Flask) - Python-dotenv library (
pip install python-dotenv) - Git (for version control)
- Telegram Portable (
Telegram.exeshould be accessible in the system or a defined path)
Ensure that the Telegram Desktop is installed in a portable configuration, allowing easy access to its data folder (tdata).
-
Clone the Repository
- Clone this repository to your local machine:
git clone <repository-url> cd telegram_account_switcher
- Clone this repository to your local machine:
-
Environment Configuration
- Create a
.envfile in the root directory and add the following configurations:Update the paths based on your Telegram Portable installation and tdata accounts directory.FLASK_APP=main.py FLASK_ENV=development FLASK_DEBUG=1 FLASK_RUN_PORT=5000 TG_PORTABLE_PATH=/path/to/telegram/portable TDATA_ACCOUNTS_PATH=/path/to/tdata/accounts TG_SYMLINK_PATH=/path/to/telegram/portable/tdata PROXY_ACCOUNTS_PATH=/path/to/proxy/accounts TELEGRAM_COMMAND=/path/to/telegram/Telegram TELEGRAM_WORKDIR=/path/to/telegram/portable
- Create a
-
Install Dependencies
- Install the required Python libraries:
Ensure the file
pip install -r requirements.txt
requirements.txtcontains the following:Flask python-dotenv
- Install the required Python libraries:
-
Account Directory Setup
- Place the Telegram tdata folders under the configured
TDATA_ACCOUNTS_PATH. - The account folders should be named sequentially as
Account_1,Account_2, etc.
- Place the Telegram tdata folders under the configured
-
Run the Script
- Start the Flask server by executing:
python main.py
- By default, the server runs on
http://127.0.0.1:5000/.
- Start the Flask server by executing:
-
Using the Web Interface
- Access the web interface by visiting
http://127.0.0.1:5000/. - You can select an account from the dropdown menu to switch.
- Optionally, add proxy details in the provided text field.
- After pressing "Switch Account", the Telegram instance will restart with the chosen account.
- Access the web interface by visiting
- Flask Server Fails to Start: Ensure all environment variables in the
.envfile are correctly set. - Symbolic Link Issues: Check if you have permission to create symbolic links. You may need administrative rights.
- pkill not working on Windows: Modify the shutdown command to match Windows (
taskkill /IM Telegram.exe /F).
Для запуска этого скрипта вам потребуется:
- Python 3.8 или новее
- Pip (установщик пакетов Python)
- Библиотека Flask (
pip install Flask) - Библиотека Python-dotenv (
pip install python-dotenv) - Git (для управления версиями)
- Telegram Portable (должна быть доступна Telegram.exe)
Убедитесь, что Telegram Desktop установлен в portable-режиме, что облегчает доступ к папке tdata.
-
Клонирование репозитория
- Клонируйте этот репозиторий на вашу местную машину:
git clone <repository-url> cd telegram_account_switcher
- Клонируйте этот репозиторий на вашу местную машину:
-
Конфигурация окружения
- Создайте файл
.envв корневой папке и добавьте следующие конфигурации:Обновите пути в соответствии с вашей Telegram Portable и директорией tdata.FLASK_APP=main.py FLASK_ENV=development FLASK_DEBUG=1 FLASK_RUN_PORT=5000 TG_PORTABLE_PATH=/path/to/telegram/portable TDATA_ACCOUNTS_PATH=/path/to/tdata/accounts TG_SYMLINK_PATH=/path/to/telegram/portable/tdata PROXY_ACCOUNTS_PATH=/path/to/proxy/accounts TELEGRAM_COMMAND=/path/to/telegram/Telegram TELEGRAM_WORKDIR=/path/to/telegram/portable
- Создайте файл
-
Установка зависимостей
- Установите нужные библиотеки Python:
Убедитесь, что файл
pip install -r requirements.txt
requirements.txtсодержит следующее:Flask python-dotenv
- Установите нужные библиотеки Python:
-
Настройка директорий аккаунтов
- Поместите Telegram tdata папки в конфигурированный
TDATA_ACCOUNTS_PATH. - Папки аккаунтов должны именоваться последовательно:
Account_1,Account_2, и т.д.
- Поместите Telegram tdata папки в конфигурированный
-
Запуск скрипта
- Запустите Flask сервер с помощью команды:
python main.py
- По умолчанию сервер запускается на
http://127.0.0.1:5000/.
- Запустите Flask сервер с помощью команды:
-
Использование веб-интерфейса
- Перейдите на
http://127.0.0.1:5000/для доступа к веб-интерфейсу. - Выберите нужный аккаунт из выпадающего списка и переключитесь.
- При необходимости добавьте прокси в соответствующее поле.
- После нажатия кнопки "Switch Account" Telegram будет перезапущен с выбранным аккаунтом.
- Перейдите на
- Сервер Flask не запускается: Проверьте, все ли переменные среды определены в
.envфайле. - Проблемы со символической ссылкой: Проверьте, есть ли у вас права на создание символических ссылок. Могут потребоваться административные права.
- pkill не работает на Windows: Модифицируйте команду для закрытия на Windows (толстая стрелка —
taskkill /IM Telegram.exe /F).