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.
- Clone the project from the master branch.
git clone git@github.com:ilyarolf/AiogramShopBot.git
- If you want to use the version with database encryption, clone from the feature/sqlalchemy-sqlcipher
branch.
git clone git@github.com:ilyarolf/AiogramShopBot.git -b feature/sqlalchemy-sqlcipher
- Set environment variables in docker-compose.yml file, token from @BotFather(
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). - If you use the version with database encryption, you must set a variable with the password from the
database (
DB_PASS
). - Run the
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
- Clone the project from the master branch.
git clone git@github.com:ilyarolf/AiogramShopBot.git
- Install all necessary packages
pip install -r requirements.txt
- Set the environment variables to run in the .env file.
Example:
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"
- After these steps the bot is ready to run, the entry point to run the bot is run.py
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.
- Clone the project from the feature/sqlalchemy-sqlcipher
branch.
git clone git@github.com:ilyarolf/AiogramShopBot.git -b feature/sqlalchemy-sqlcipher
- Install the SQLCipher package, for example in Ubuntu this can be done with the command
sudo apt install sqlcipher
. - Install all necessary packages
pip install -r requirements.txt
- Variables in .env are set in the same way as in point 1.1, but with one exception, you need to set a password for the
database.
Example:
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"
- After these steps the bot is ready to run, the entry point to run the bot is run.py
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:
Item#1
Data: DataOfItem#1
Item#2
Data:DataOfItem#2
Item#3
Data:DataOfItem#3
Item#4
Data:DataOfItem#4
Item#5
Data:DataOfItem#5
Item#6
Data:DataOfItem#6
Item#7
Data:DataOfItem#7
Item#8
Data:DataOfItem#8
Item#9
Data:DataOfItem#9
Item#10
Data:DataOfItem#10
- To access your purchase history go to "My Profile" -> "Purchase History".
- You will be presented with an inline keyboard with all your purchases, by clicking on any of the purchases you will be sent a message in the format from paragraph 2.3.
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
- Open the admin panel by entering the command
/admin
, then click on the "Send to everyone" button. - Type a message or forward to the bot, the bot supports sending a message with pictures and Telegram markup (bold, italics, spoilers, etc.).
- Confirm or decline the sending of messages.
- After successful message sending, the original message with inline buttons "Confirm", "Decline" will change
to
Message sent to x out of y people
.
Note The functionality for adding new products so far supports adding products using .json files.
- Open the admin panel by entering the command
/admin
. - Click on the "Add new items" button.
- Send .json file with new items.
Example of .json file:
{
"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.
- Open the admin panel by entering the command
/admin
. - Click on the "Send restocking message" button.
Note Restocking message is generated automatically and looks as follows:
π
Update YYYY-MM-DD
π Category Category#1
π Subcategory Subcategory#1 1 pcs
π Category Category#2
π Subcategory Subcategory#2 1 pcs
- Open the admin panel by entering the command
/admin
. - Click on the "Send restocking message" button.
- You will get a message
x new users:
with inline buttons that will take you to chat with each new user who has a nickname.
- Open the admin panel by entering the command
/admin
. - Click on the
Delete category
orDelete subcategory
button. - Select a category or subcategory, confirm deletion. If the deletion is successful, you will receive the
message
Sucessfully deleted {name} category/subcategory
Note Refunds returns money to the user's balance in the bot.
- Open the admin panel by entering the command
/admin
. - Click on the
Make refund
button. - In the received message you will have inline buttons in the
format
TelegramID/TelegramUsername|TotalPrice|SubcategoryName
.
For example:@durov|$500.0|Test subcategory
. - Select the purchase for which you want to make a refund.
- You will receive a message
in
Do you really want to refund user @durov for purchasing 1 SubcategoryName in the amount of $500.0
format. Confirm or decline the refund. - If the refund is successful, you will receive
a
Successfully refunded $500.0 to user durov for purchasing 1 SubcategoryName
message. - The user to whom you returned the message will also receive a message
in
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
- If any user topped up the balance and clicked on the "Refresh balance" button, you will receive the following message from the bot:
New deposit by user with username @durov for $500 with 0.01 BTC
BTC address:bc1pvz78lx4lw0sutcu0l5szn74ke0hrkghvdg2u8wc705alr5hj9l4q8hzymp
Seed: abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon
After each purchase, you will receive a message in the format:
A new purchase by user @durov for the amount of $500.0 for the purchase of a 1 pcs SubcategoryName.
- Make migration from direct raw database queries to SQLAlchemy ORM.
- Add option to encrypt database via SQLCipher (when using SQLAlchemy).
- Add an option to generate new crypto addresses using new mnemonic phrases so that 1 user=1 mnemonic phrase.
- Items pagination.
- Make the functionality of database backup by action in the admin in the Telegram bot.
- Make the functionality of generating statistics of sales and users in the bot for a month/week/day in the admin panel.
- Make the functionality of generating statistics of deposits in the bot for a month/week in the admin panel.
- BTC - bc1q2kv89q8yvf068xxw3x65gzfag98l9wnrda3x56
- LTC - ltc1q0tuvm5vqn9le5zmhvhtp7z9p2eu6yvv24ey686
- TRX - THzRw8UpTsEYBEG5CCbsCVnJzopSHFHJm6
- ETH - 0xB49D720DE2630fA4C813d5B4c025706E25cF74fe
- USDT ERC20 - 0xB49D720DE2630fA4C813d5B4c025706E25cF74fe
- USDT BEP20 - 0xB49D720DE2630fA4C813d5B4c025706E25cF74fe
- USDT TRC20 - THzRw8UpTsEYBEG5CCbsCVnJzopSHFHJm6