This adapter provides a pluggable implementation for integrating Telegram as a messaging platform. It is designed to work with RelaySMS Publisher, enabling users to connect to Telegram using PNBA (Phone number-based authentication) authentication.
- Python: Version >= 3.8.10
- Python Virtual Environments: Documentation
Install the necessary system packages:
sudo apt install build-essential python3-dev-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
. venv/bin/activate -
Install the required Python packages:
# For production use pip install -r requirements.txt # For development and testing (includes CLI tools) pip install -r test-requirements.txt
- Obtain your credentials from the Telegram Developer Portal.
- Set the
credentials.jsonpath of your credentials file in themanifest.ini:
[credentials]
path = ./credentials.jsonSample credentials.json
{
"api_id": "",
"api_hash": ""
}The adapter comes with a command-line interface (CLI) that allows you to test all functionality directly from the terminal.
To see all available commands:
python telegram_cli.py --helpTo use the interactive mode which provides a menu interface:
python telegram_cli.py --interactiveor
python telegram_cli.py -iSend Authentication Code:
python telegram_cli.py auth:send-code --phone="+1234567890"Validate Authentication Code:
python telegram_cli.py auth:validate-code --phone="+1234567890" --code="12345"Validate Two-Step Verification Password:
python telegram_cli.py auth:validate-password --phone="+1234567890" --password="your_password"Send a Message:
python telegram_cli.py message:send --phone="+1234567890" --recipient="@username" --text="Hello from CLI"Invalidate a Session:
python telegram_cli.py session:invalidate --phone="+1234567890"Tip
If you don't provide required options, the CLI will prompt you for them:
python telegram_cli.py message:sendTip
To get help for a specific command:
python telegram_cli.py auth:send-code --help