Skip to content

TON Token Control Bot manages access to your private Telegram chats using unique tokens for each participant.

License

Notifications You must be signed in to change notification settings

nessshon/token-access-control-bot

Repository files navigation

🤖 TON Token Access Control Bot

TON Telegram Bot Python License Redis Docker

TON Token Access Control Bot is a specialized bot that utilizes NFT tokens and/or Jettons to manage access to your private Telegram chats. This convenient solution allows you to control who has access to your groups and when, using tokens as unique non-transferable identifiers for each participant.

Features

  • Token Access Control: Allows access via NFT tokens and Jettons, with customizable token limits.

  • Testnet and Mainnet Support: Flexible testing and deployment on both networks.

  • TON-Connect Integration: Ensures a secure and user-friendly experience.

  • User-Friendly Admin Panel: Built-in panel for easy administration.

  • Multilingual Support: Supports Russian and English for user interaction.

  • Newsletters to All Users: Distributes newsletters to all users, including delayed scheduling.

Usage

Preparation and installation

You need your own server or you can rent one from a hosting provider. For this, check out the Recommended Hosting Provider section below.

  1. Create a private group and/or channel.

  2. Create a bot via @BotFather and save the TOKEN (later referred to as BOT_TOKEN).

  3. Create an API key on tonconsole.com (later referred to as TONAPI_KEY).

  4. Clone the repository:

    git clone https://github.com/nessshon/token-access-control-bot.git
  5. Navigate to the bot directory:

    cd token-access-control-bot
  6. Clone the environment variables file:

    cp .env.example .env
  7. Configure environment variables file:

    nano .env
  8. Install Docker and Docker Compose:

    sudo apt install docker.io && apt install docker-compose -y
  9. Run the bot in a Docker container:

    docker-compose up --build

    If you encounter the error:

    Error while fetching server API version: HTTPConnection.request() got an unexpected keyword argument 'chunked'
    

    Install the latest version of docker-compose using the following command:

    sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose  && sudo chmod +x /usr/bin/docker-compose

    After the bot is up and running smoothly, you can stop the containers by pressing Ctrl + C or **Ctrl + Shift + C ** in the terminal. Then, to restart them in the background, use:

    docker-compose up -d
  10. Start the bot with the command /start, choose the language, and connect wallet.

  11. Access the admin panel with the command /admin and add the token.

  12. Add the bot to your private chat, ensuring you grant permissions to add administrators. After that, the bot will prompt you to add the chat to the database for monitoring.

  13. You're all set!

Customize the bot's texts in the texts file and pictures in the texts_pics file according to your requirements. Additionally, if desired, add your preferred language to SUPPORTED_LANGUAGES and insert the corresponding codes into TEXT_BUTTONS and TEXT_MESSAGES.

Environment Variables Reference

Click to expand

Here's a comprehensive reference guide for the environment variables used in the project:

Variable Type Description Example
BOT_TOKEN str Bot token obtained from @BotFather 123456:qweRTY
BOT_DEV_ID int User ID of the bot developer, obtain it from my_id_bot 123456789
BOT_ADMIN_ID int User ID of the bot admin, obtain it from my_id_bot 123456789
DEX_NAME str The name of the DEX identifying the provider is displayed in the bot for purchasing or viewing tokens dedust or stonfi or swapcoffee
IS_TESTNET bool Set to True for TON testnet or False for mainnet False
MANIFEST_URL str URL of the bot's manifest file https://raw.githubusercontent.com/nessshon/token-access-control-bot/main/tonconnect-manifest.json
EXCLUDE_WALLETS list List of wallets to exclude ["mytonwallet"]
TONAPI_KEY str API key for TONAPI, obtain it from tonconsole.com AE33E...3FYQ
TONAPI_RPS str Specifies the requests per second (RPS) limit for TONAPI to avoid exceeding rate limits and ensure stable performance 1
SCHEDULER_CHECK_CHAT_MEMBERS_INTERVAL int Interval (minutes) for checking chat members (5 minutes is acceptable) 5
SCHEDULER_UPDATE_TOKEN_HOLDERS_INTERVAL int Interval (minutes) for updating token holders (adjust value by Jetton holders or NFT elements. Every 1000 tokens or holders equals 1-2 seconds. For instance, for collections with 30k or fewer elements, set the value to 1) 5
REDIS_HOST str Hostname or IP address of the Redis server (set redis if you don't have your own Redis server) redis
REDIS_PORT int Port number of the Redis server (set 6379 if you don't have your own Redis server) 6379
REDIS_DB int Redis database number (set 0 if you don't have your own Redis server) 0

Recommended Hosting Provider

I recommend using aeza.net for your hosting needs. Here's why:

  • 24/7 Support: Quick and effective support via chat or phone.
  • Promo Plan for €1: Great for testing Telegram bots and small websites.
  • Easy Backups: Secure backups on independent servers.
  • Hourly Billing: Rent a server by the hour for testing or demos.
  • Anti-DDoS Protection: Reliable and secure internet connection for your business.
  • Multiple Payment Methods: Supports various payment methods, including cryptocurrencies like TON.

Learn more at aeza.net.

Donations

TON - EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess

USDT (TRC-20) - TGKmm9H3FApFw8xcgRcZDHSku68vozAjo9

Contribution

We welcome your contributions! If you have ideas for improvement or have identified a bug, please create an issue or submit a pull request.

Support

Supported by TON Society, Grants and Bounties program.

License

This repository is distributed under the MIT License.