AiogramShopBot is a software product based on Aiogram3.x and SQLAlchemy that allows you to automate sales of digital goods in Telegram. One of the advantages of the bot is that AiogramShopBot implements the ability to top up with Bitcoin, Litecoin, USDT TRC-20, which allows you to sell digital goods worldwide.
Environment Variable Name | Description | Recommend Value |
---|---|---|
WEBHOOK_PATH | The path to the webhook where Telegram servers send requests for bot updates. It is not recommended to change it if only one bot will be deployed. In case several bots will be deployed on the same server, it will be necessary to change it, because there will be path collision (Does not apply to the multibot case). | "" (empty string) |
WEBAPP_HOST | Hostname for Telegram bot, it is not recommended to change in case you use docker-compose. | For docker-compose="0.0.0.0". For local deployment="localhost". |
WEBAPP_PORT | Port for Telegram bot, if you plan to deploy several bots on the same server, you will need to assign a different port to each one (Not relevant to the multibot case). | No recommended value |
TOKEN | Token from your Telegram bot, you can get it for free in Telegram from the bot of all bots with the username @botfather. | No recommended value |
NGROK_TOKEN | Token from your NGROK profile, it is needed for port forwarding to the Internet. The main advantage of using NGROK is that NGROK assigns the HTTPS certificate for free. | No recommended value |
ADMIN_ID_LIST | List of Telegram id of all admins of your bot. This list is used to check for access to the admin menu. | No recommended value |
SUPPORT_LINK | A link to the Telegram profile that will be sent by the bot to the user when the “Help” button is pressed. | https://t.me/${YOUR_USERNAME_TG} |
DB_NAME | The name of the SQLite database file. | database.db |
PAGE_ENTIRES | The number of entries per page. Serves as a variable for pagination. | 8 |
BOT_LANGUAGE | The name of the .json file with the l10n localization. At the moment only English localization is supplied out of the box, but you can make your own if you create a file in the l10n folder with the same keys as in l10n/en.json. | "en" |
MULTIBOT | Experimental functionality, allows you to raise several bots in one process. And there will be one main bot, where you can create other bots with the command “/add $BOT_TOKEN”. Accepts string parameters “true” or “false”. | "false" |
DB_PASS | Only works in the feature/sqlalchemy-sqlcipher branch. The password that will be used to encrypt your SQLite database. | No recommended value |
git clone git@github.com:ilyarolf/AiogramShopBot.git
git clone git@github.com:ilyarolf/AiogramShopBot.git -b feature/sqlalchemy-sqlcipher
TOKEN
), token from
ngrok(NGROK_TOKEN
), telegram id of admins(ADMIN_ID_LIST
), support link (SUPPORT_LINK
, the link will be
needed for the "Help" button in the bot).DB_PASS
).docker-compose up
command.Note
To get the ngrok token, you need to register on the ngrok website and confirm your email. Then you will have the ngrok token in your personal account.
Note
Fully compatible with python 3.9.6.
AiogramShopBot from the master branch does not use database encryption via SQLCipher, but it does use Aiosqlite
git clone git@github.com:ilyarolf/AiogramShopBot.git
pip install -r requirements.txt
WEBHOOK_PATH = "/bot"
WEBAPP_HOST = "localhost"
WEBAPP_PORT = 1234
TOKEN = "TELEGRAM_BOT_TOKEN_HERE"
ADMIN_ID_LIST = 123456,654321
SUPPORT_LINK = "https://t.me/your_username_123"
DB_NAME = "db_file_name.db"
NGROK_TOKEN = "NGROK_TOKEN_HERE"
PAGE_ENTRIES = 8
BOT_LANGUAGE = "en"
MULTIBOT = "false"
python run.py
Note
To run AiogramShopBot with database encryption via SQLCipher, it is recommended to use Linux kernel operating systems because installing SQLCipher on Windows is not the easiest.
git clone git@github.com:ilyarolf/AiogramShopBot.git -b feature/sqlalchemy-sqlcipher
sudo apt install sqlcipher
.pip install -r requirements.txt
WEBHOOK_PATH = "/bot"
WEBAPP_HOST = "localhost"
WEBAPP_PORT = 1234
TOKEN = "TELEGRAM_BOT_TOKEN_HERE"
ADMIN_ID_LIST = 123456,654321
SUPPORT_LINK = "https://t.me/your_username_123"
DB_NAME = "db_file_name.db"
DB_PASS = "your_password_to_database"
NGROK_TOKEN = "NGROK_TOKEN_HERE"
PAGE_ENTRIES = 8
BOT_LANGUAGE = "en"
MULTIBOT = "false"
python run.py
User registration occurs when the bot is first accessed with the /start
command. Each user is assigned a different
mnemonic phrase to generate BTC, LTC, USDT TRC20 crypto addresses. BTC and LTC addresses are generated according to
BIP-84 standard, for USDT TRC20 the BIP-44 standard is used, this is done so that wallets can be easily imported into
Trust Wallet.
To deposit balance in the bot, go to "My Profile -> Top Up balance". Copy the address of the cryptocurrency you want to
top up and send the cryptocurrency there, then go back to "My Profile" and click "Refresh Balance". Refreshing the
balance takes some time (1-2 seconds).
Note "Refresh balance" button has a 30 second cooldown.
To buy any item, go to "All categories" -> Select any category -> Select any subcategory -> Select quantity -> Confirm purchase. If the purchase is successful, you will immediately receive a message in the format:
To add a new admin you need to add his telegram id to the ADMIN_ID_LIST environment variable, separated by commas, and
reload the bot.
For example: ADMIN_ID_LIST=123456,654321
/admin
, then click on the "Send to everyone" button.Note The functionality for adding new products so far supports adding products using .json files.
/admin
.{
"items": [
{
"category": "Category#1",
"subcategory": "Subcategory#1",
"price": 50,
"description": "Mocked description",
"private_data": "Mocked private data"
},
{
"category": "Category#2",
"subcategory": "Subcategory#2",
"price": 100,
"description": "Mocked description",
"private_data": "Mocked private data"
}
]
}
Note The "private_data" property is what the user gets when they make a purchase.
/admin
.Note Restocking message is generated automatically and looks as follows:
/admin
.Delete category
or Delete subcategory
button.Sucessfully deleted {name} category/subcategory
Note Refunds returns money to the user's balance in the bot.
/admin
.Make refund
button.TelegramID/TelegramUsername|TotalPrice|SubcategoryName
.@durov|$500.0|Test subcategory
.Do you really want to refund user @durov for purchasing 1 SubcategoryName in the amount of $500.0
format.
Confirm or decline the refund.Successfully refunded $500.0 to user durov for purchasing 1 SubcategoryName
message.
You have been refunded $50.0 for the purchase of 1 pieces of SubcategoryName
format.
Note All users with telegram id in the .env ADMIN_ID_LIST environment variable will receive these notifications
After each purchase, you will receive a message in the format:
MULTIBOT="true"
docker-compose up
command./add $TOKEN
to the bot manager. If everything is successful, you will receive this notification.