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

jayp89/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. Obtain a key for TON Connect (Optional, later referred to as TONAPI_TONCONNECT_KEY).

    This key is necessary for the correct functioning of TON Connect on the backend under heavy user load. If you are expecting a high volume of traffic, more than one user per second, contact @subden via private message to receive the key. Tell him about your project and the need for this key. If you don't expect much traffic, you can skip this step and use the bot without a key.
  5. Clone the repository:

    git clone https://github.com/jayp89/og-access-control-bot.git
  6. Navigate to the bot directory:

    cd og-access-control-bot
  7. Clone the environment variables file:

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

    nano .env
  9. Install Docker and Docker Compose:

    sudo apt install docker.io && apt install docker-compose -y
  10. 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
  11. Start the bot with the command /start, choose the language, and connect wallet.

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

  13. 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.

  14. You're all set!

Customize the bot's texts in the texts 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
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
TONAPI_KEY str API key for TONAPI, obtain it from tonconsole.com AE33E...3FYQ
TONAPI_TONCONNECT_KEY str API key for TON Connect (optional), obtain it by contacting @subden 587d4...5a71 or leave empty
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.

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.8%
  • Dockerfile 0.2%