Skip to content

smswithoutborders/telegram-pnba-adapter

Repository files navigation

Telegram PNBA Platform Adapter

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.

Requirements

Dependencies

On Ubuntu

Install the necessary system packages:

sudo apt install build-essential python3-dev

Installation

  1. Create a virtual environment:

    python3 -m venv venv
  2. Activate the virtual environment:

    . venv/bin/activate
  3. 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

Configuration

  1. Obtain your credentials from the Telegram Developer Portal.
  2. Set the credentials.json path of your credentials file in the manifest.ini:
   [credentials]
   path = ./credentials.json

Sample credentials.json

{
  "api_id": "",
  "api_hash": ""
}

CLI Usage

The adapter comes with a command-line interface (CLI) that allows you to test all functionality directly from the terminal.

Getting Started

To see all available commands:

python telegram_cli.py --help

To use the interactive mode which provides a menu interface:

python telegram_cli.py --interactive

or

python telegram_cli.py -i

Authentication Commands

Send 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"

Messaging Commands

Send a Message:

python telegram_cli.py message:send --phone="+1234567890" --recipient="@username" --text="Hello from CLI"

Session Management

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:send

Tip

To get help for a specific command:

python telegram_cli.py auth:send-code --help

About

Pluggable Telegram PNBA adapter for RelaySMS Publisher.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages