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.
- Bot example: @TONTokenAccessControlBot
-
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.
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.
-
Create a private group and/or channel.
-
Create a bot via @BotFather and save the
TOKEN
(later referred to asBOT_TOKEN
). -
Create an API key on tonconsole.com (later referred to as
TONAPI_KEY
). -
Clone the repository:
git clone https://github.com/nessshon/token-access-control-bot.git
-
Navigate to the bot directory:
cd token-access-control-bot
-
Clone the environment variables file:
cp .env.example .env
-
Configure environment variables file:
nano .env
-
Install Docker and Docker Compose:
sudo apt install docker.io && apt install docker-compose -y
-
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
-
Start the bot with the command
/start
, choose the language, and connect wallet. -
Access the admin panel with the command
/admin
and add the token. -
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.
-
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.
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 |
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.
TON - EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess
USDT (TRC-20) - TGKmm9H3FApFw8xcgRcZDHSku68vozAjo9
We welcome your contributions! If you have ideas for improvement or have identified a bug, please create an issue or submit a pull request.
Supported by TON Society, Grants and Bounties program.
This repository is distributed under the MIT License.