This project is a Telegram Bot connected to a Telegram Channel that check Amazon offers and send them to your Channel.
Now you can run the script.sh
file from the terminal to install all dependencies, included paapi5 package. Open a terminal in the working directory, then type bash script.sh
and launch the command.
In order to use this bot you must complete the following steps:
-
Create a telegram bot (https://core.telegram.org/bots)
-
Create an Amazon Affiliation (https://programma-affiliazione.amazon.it/)
-
Put all of your keys (Amazon and Telegram API Keys) in the code, we are going to define how below
-
Install packages, you can install them with pip:
- python-telegram-bot
- itertools
- datetime
-
Install Amazon paapi5 package:
- open your terminal
- go to /paapi5-python-sdk
- launch the command:
python setup.py
orpython3 setup.py
The project is organized like follow:
-
bot.py
- Contains the bot start code
-
consts.py
- HERE YOU MUST PUT YOUR TELEGRAM API KEYS AND PARAMETERS AND YOUR AMAZON API KEYS AND PARAMETERS
-
amazon_api.py
- Contain amazon api function to search products
-
response_parser.py
- Util functions that parse amazon api response
-
create_messages
- message creation functions
The bot is running in a while loop, you can define your favorite parameters for:
- Hours of activity
- Pause time between messages
- Amazon Search Categories
- Search Keywords
The bot is active if the time is between MIN_HOUR and MAX_HOUR (you can deactivate it during the night for example) , you can define these parameters in the code.
The do a break for defined PAUSE_MINUTE after sent a message.
You can also edit message body in create_messages.py
.
The bot make all http requests to Amazon API at start, save a list of all results in RAM and as long as there are items in results list it:
- SEND OFFER MESSAGE
- PAUSE FOR PAUSE_MINUTES
- SEND ANOTHER MESSAGE
for all the activity time. When all results have been sent, it restart his loop.
NOW YOU CAN SEARCH OVER MULTIPLE CATEGORIES : in bot.py
you need to specify your categories and a list of keywords for each category. The corresponding variable is categories
, it accept a dictionary like:
{
"1_CATEGORY_NAME":[LIST OF KEYWORD],
"2_CATEGORY_NAME":[LIST OF KEYWORD]
}
After cloning the repository, define all parameters in the code, install all packages and then start bot with command:
python bot.py
or python3 bot.py
This is a generated telegram channel message example, you can edit the message structure on create_messages.py
code.
Samir Salman