botaffiumeiro is a Telegram bot that detects Amazon, Aliexpress and other links shared in Telegram groups and automatically converts them into affiliate links using your custom Amazon Affiliate ID. This is especially useful for those who want to monetize links shared in their communities.
/discounts
, /bonus
, etc.$ docker create \
--name=botaffiumeiro \
-v /path/to/host/data:/app/data \
--restart unless-stopped \
ghcr.io/hectorzin/botaffiumeiro
Modify the /path/to/host/data/config.yaml
file with your settings.
$ docker start botaffiumeiro
Once configured and running, the bot will detect Affiliate links in any group it's added to and replace them with your affiliate links, making it easy to earn commissions from shared products.
To ensure that the bot works correctly, you need to install Python and the required libraries.
First, ensure that you have Python installed. You can download Python from the official website: Python Downloads.
Once Python is installed, you need to run the following commands to install the required Python libraries:
pip install -r requirements.txt
data/config.py
.python botaffiumeiro.py
Once configured and running, the bot will detect Affiliate links in any group it's added to and replace them with your affiliate links, making it easy to earn commissions from shared products.
To obtain the Bot Token, follow these steps:
/start
./newbot
to create a new bot. Follow the prompts to choose a name and username for your bot.
YourBotName_bot
).Telegram has a privacy setting for bots that prevents them from reading messages in groups unless they are mentioned directly, or the admin has configured the bot to run in No Privacy Mode. To allow the bot to read all messages, follow these steps:
/mybots
to BotFather.This will allow the bot to read all messages in the group, not just the ones where it is mentioned directly.
If your bot will operate in a group, follow these steps to add it:
You can exclude certain users from having their Amazon links modified by the bot. You can do this by defining a list of usernames or Telegram user IDs.
telegram:
excluded_users:
- "username1"
- "username2"
- 123456789
When the bot detects an AliExpress link, it will automatically reply to the message with the pre-configured discount codes. You can modify these discount codes as needed.
aliexpress:
discount_codes: |
💥 AliExpress discount codes:
💰2$ off for purchases over 20$:【IFPTKOH】
💰5$ off for purchases over 50$:【IFPT35D】
💰25$ off for purchases over 200$:【IFPQDMH】
💰50$ off for purchases over 400$:【IFP5RIN】
You can define custom commands that users can use to request AliExpress discount codes in your config.yaml
file. The following example shows how to configure discount keywords:
discount_keywords:
- discounts
- bonus
- bonuses
- aliexpress
You can also customize the bot's response messages and translate them into different languages. To do this, you can modify the message strings in the code. For example:
messages:
affiliate_link_modified: "Here is the modified link with our affiliate program:"
reply_provided_by_user: "Reply provided by"
By changing these variables, you can personalize how the bot interacts with users. This makes it easy to:
This parameter allows you to define what percentage of the links shared in Telegram groups will be replaced with affiliate links belonging to the software creators. However, there are a few important conditions to keep in mind:
Available Affiliate Links: Only links that the software creators have affiliate programs for will be eligible to be replaced.
Affiliate Priority: If the user does not have an affiliate link for a specific domain, but the creators of the software do, the creators' affiliate link will be used instead.
This ensures that affiliate links are always used when available, whether from the user or the software creators, while respecting the configured percentage.
We usually use Visual Studio Code to develop the project.
data/config.py
file with your Test settings.botaffiumeiro.py
.For testing you could directly run test with Visual Studio Code Testing tab. Or installing pytest with pip install pytest
and then run the test with python -m pytest tests/
.