Giter Site home page Giter Site logo

samirsalman / amazonoffers-telegrambot Goto Github PK

View Code? Open in Web Editor NEW
135.0 2.0 44.0 12.93 MB

This project is a Telegram Bot connected to a Telegram Channel that checks Amazon offers and send them to your Channel.

Python 99.99% Shell 0.01%
telegram-bot amazon-api

amazonoffers-telegrambot's Introduction

Amazon Offers Telegram Bot

logo

This project is a Telegram Bot connected to a Telegram Channel that check Amazon offers and send them to your Channel.

Requirements

SCRIPT INSTALLER

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.

MANUAL INSTALLER

If you used the script.sh method you can skip the following step.

In order to use this bot you must complete the following steps:

pip3 install -r requirements.txt
cd paapi5-python-sdk
python3 setup.py build
python3 setup.py install
cd ..

Project Structure

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
    • THE CHANNEL_NAME SHOULD START WITH @ (for example @MyChannelName)
  • 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

How it works

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:

  1. SEND OFFER MESSAGE
  2. PAUSE FOR PAUSE_MINUTES
  3. 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]
}

Usage

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

Support

If you need support for the installation and usage of the library you can write to:

In order to mantain and improve the library consider to contribute:

paypal

Message Structure

image

This is a generated telegram channel message example, you can edit the message structure on create_messages.py code.

Author

Samir Salman

amazonoffers-telegrambot's People

Contributors

samirsalman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

amazonoffers-telegrambot's Issues

error module

Hi, I'm having various problems, it gives me this error when I try to start the bot

DeprecationWarning: module 'sre_parse' is deprecated
from sre_parse import CATEGORIES
Traceback (most recent call last):
File "C:\Users\UTENTE\AmazonOffers-TelegramBot\bot.py", line 4, in
from amazon_api import search_items
File "C:\Users\UTENTE\AmazonOffers-TelegramBot\amazon_api.py", line 2, in
from paapi5_python_sdk.models.partner_type import PartnerType
ModuleNotFoundError: No module named 'paapi5_python_sdk.models'
PS C:\Users\UTENTE\AmazonOffers-TelegramBot>

even the telegram module says that it doesn't exist and yet it is installed, can you kindly help me, thanks

Set time

Hello,
how i can set the script for work only from 6 AM to 2 AM ?
I wish the script didn't run for only 4 hours a night, which is 2:01 AM to 5:59 AM,
Thank you very much for the clarification

Error

Ciao,

dopo aver inserito i parametri, ricevo questo errore:

python bot.py

2021-03-16 12:50:17,149 WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnec
tion object at 0x7f2dbc53aa50>: Failed to establish a new connection: [Errno 111] Connection refused')': /paapi5/searchitems
2021-03-16 12:50:18,173 WARNING Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnec
tion object at 0x7f2dbc4dda50>: Failed to establish a new connection: [Errno 111] Connection refused')': /paapi5/searchitems
2021-03-16 12:50:19,197 WARNING Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnec
tion object at 0x7f2dbc4b9b10>: Failed to establish a new connection: [Errno 111] Connection refused')': /paapi5/searchitems
Exception : HTTPSConnectionPool(host='webservices.amazon.it', port=443): Max retries exceeded with url: /paapi5/searchitems (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection
object at 0x7f2dbc4bb050>: Failed to establish a new connection: [Errno 111] Connection refused'))
^CTraceback (most recent call last):
File "bot.py", line 102, in
run_bot(bot, keywords)
File "bot.py", line 48, in run_bot
time.sleep(10)

Puoi aiutarmi?
Grazie

Getting error while posting to bot

I am getting this error at the step when it is posting to bot. Any idea what is causing this ?

INFO:root:***** Sending posts to channel *****
bot.py:37: RuntimeWarning: coroutine 'Bot.send_message' was never awaited
  bot.send_message(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
bot.py:47: RuntimeWarning: coroutine 'Bot.send_message' was never awaited
  bot.send_message(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

paapi5_python_sdk.models not found

Although I have installed the library it tells me that it cannot find the paapi5_python_sdk.models module, is it possible that there have been problems and that the library is out of date?

Errore quando il bot prova a comporre ed inviare il messaggio nel canale telegram

Ciao ragazzi quando il bot fa le richieste di ricerca ricevo questo errore :

Request received
Request received
Request received
Request received
Request received
Request received
Request received
Request received
Request received
INFO:root:***** Requests Completed *****
***** Creating post *****
INFO:root:***** Sending posts to channel *****
INFO:root:Chat not found

Mi sembra di aver messo tutte le info correttamente in const.py, TOKEN="tokendelbot" e CHANNEL_NAME="@nomedelcanale".
Ovviamente ho anche aggiunto il bot al canale come amministratore, ho dimenticato qualcosa?
Thanks

Amazon API

Hi all,
how do you recover this data?
with AWS AMAZON lamda?

does the host have to be amazon?
or can I choose other hosts?

AMAZON_ACCESS_KEY = ""
AMAZON_SECRET_KEY = ""

AMAZON_HOST = ""
AMAZON_REGION = ""

Thank you for your attention

Amazon API Keys and parameters

Hi Samir,
I have a question regarding Amazon parameters: I don't understand which is the difference between host and region to insert in the code.
I would like to use the bot for Italian market.

host = ""
region = ""

Thank you so much

Marco

Error when launching "python setup.py" - SOLVED

Hi, I receive this error, any idea? thanks.

λ python3 setup.py
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

error: no commands supplied

'Bot' object has no attribute 'send_message'

Hello, can someones help me? When I run the bot I obtain this error in shell and no post in telegram channel.

Request received
Request received
Request received
***** Requests Completed *****
***** Creating post *****
***** Sending posts to channel *****
'Bot' object has no attribute 'send_message'
***** Sending posts to channel *****
'Bot' object has no attribute 'send_message'

I have edited the bot.py with botfathers token and channel id and the amazon_api with my aapi keys. What's wrong?

How can I fix it?
Thank you

some keywords cause issue

it is not clear how this can happen...
but some category keywords get me this result:

Request received
Request received
Exception : 'NoneType' object has no attribute 'savings'
INFO:root:'NoneType' object is not iterable
Request received
Request received

ParseMode

I have this reponse:

Request received
INFO:root:***** Requests Completed *****
***** Creating post *****
INFO:root:***** Sending posts to channel *****
INFO:root:module 'telegram' has no attribute 'ParseMode'

api info

HI

AMAZON_ACCESS_KEY = "<YOUR AMAZON ACCESS KEY>" AMAZON_SECRET_KEY = "<YOUR AMAZON SECRET KEY>" PARTNER_TAG = "<YOUR AMAZON PARTNER TAG>" AMAZON_HOST = "<YOUR AMAZON HOST>" AMAZON_REGION = "<YOUR AMAZON REGION>"

Where i can find this? how i create

please help!

hi samir i need help, when i start the bot keeps saying request received but does not create the message says: Exception: 'NoneType' object has no attribute 'savings'
INFO: root: 'NoneType' object is not iterable how can I solve?

'NoneType' object is not iterable

I keep getting this error:

Exception: 'NoneType' object has no attribute 'savings'
INFO: root: 'NoneType' object is not iterable

The APIs are correct, I have tested them. Has anyone solved it?

Error

2-02-03T14:36:17.149710+00:00 app[worker.1]: Traceback (most recent call last):
2022-02-03T14:36:17.149725+00:00 app[worker.1]: File "/app/bot.py", line 2, in
2022-02-03T14:36:17.149765+00:00 app[worker.1]: from amazon_api import search_items
2022-02-03T14:36:17.149774+00:00 app[worker.1]: File "/app/amazon_api.py", line 1, in
2022-02-03T14:36:17.149821+00:00 app[worker.1]: from paapi5_python_sdk.api.default_api import DefaultApi
2022-02-03T14:36:17.149840+00:00 app[worker.1]: ModuleNotFoundError: No module named 'paapi5_python_sdk'
2022-02-03T14:36:17.289916+00:00 heroku[worker.1]: Process exited with status 1
2022-02-03T14:36:17.349466+00:00 heroku[worker.1]: State changed from up to crashed

Error while running bot.py

Hi, I was trying to run the bot with the wording "python bot.py" after installing the various things but it gives me an error:

File "bot.py", line 38
def is_active () -> bool:
^
SyntaxError: invalid syntax

How can I solve?

Info project

Hello
I would like to know if the project works, and if someone using it.
Thank you

Problema

Salve, vorrei chiedere il vostro aiuto.
Ho scaricato il tutto eseguo il comando "sudo bash script.sh" ma adesso che cosa dovrei fare?
Da quello che ho capito dovrei compilare il campo delle voci del file "consts.py"

***** Telegram TOKEN and parameters Definition *****

TOKEN = ""
CHANNEL_NAME = ""

***** BOT ACTIVITY TIME *****

MIN_HOUR = 9
MAX_HOUR = 24
PAUSE_MINUTES = 12

***** Amazon API Keys and parameters *****

AMAZON_ACCESS_KEY = ""
AMAZON_SECRET_KEY = ""
PARTNER_TAG = ""
AMAZON_HOST = ""
AMAZON_REGION = ""

Come dovrei compilare il tutto?

INFO:root:'NoneType' object is not iterable Exception : ('Connection aborted.', InvalidURL("URL can't contain control characters. '<your amazon host>' (found at least ' ')"))

i do everything in the description, but i have this issues. Im doing it for the amazon in germany. Can you help me?

INFO:root:'NoneType' object is not iterable
Exception : ('Connection aborted.', InvalidURL("URL can't contain control characters. '' (found at least ' ')"))
INFO:root:'NoneType' object is not iterable
Exception : ('Connection aborted.', InvalidURL("URL can't contain control characters. '' (found at least ' ')"))
INFO:root:'NoneType' object is not iterable
Exception : ('Connection aborted.', InvalidURL("URL can't contain control characters. '' (found at least ' ')"))
INFO:root:'NoneType' object is not iterable

LICENSE

Please insert lincese.

Thanks you.

ERROR SETUP.PY INSTALL

when i install setup.py it gives me this problem:

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

error: no commands supplied

how do i solve?

Bot startup errors

Hi, when I go to run the bot I get the following errors:

/usr/lib/python3/dist-packages/requests/init.py:89: RequestsDependencyWarning: urllib3 (1.26.9) or chardet (3.0.4) doesn't match a supported version!
warnings.warn ("urllib3 ({}) or chardet ({}) doesn't match a supported"

Traceback (most recent call last):
File "bot.py", line 5, in
from create_messages import create_item_html
File "/home/Alex/Scrivania/AmazonOffers-TelegramBot-main/create_messages.py", line 1, in
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
ImportError: cannot import name 'InlineKeyboardButton' from 'telegram' (/usr/local/lib/python3.8/dist-packages/telegram/init.py)

How can I solve? I did the automatic installation with script.sh

Host

what to put in the host I am From India

ciao Errore categorie

cia se metti altre categorie di amazon ad esempio

categories = {
"Casa e Cucina": [
"ecc..",
]
}

da questo errore

Status code: 400
Errors : {"__type":"com.amazon.paapi5#ValidationException","Errors":[{"Code":"InvalidParameterValue","Message":"The value Casa e Cucina provided in the request for SearchIndex is invalid. Refer https://webservices.amazon.it/paapi5/documentation/locale-reference/italy.html#search-index for valid values."}]}
Request ID: 93360c60-79c0-45d3-8e5e-96f7128a064e
INFO:root:'NoneType' object is not iterable
Error calling PA-API 5.0!
Status code: 400
Errors : {"__type":"com.amazon.paapi5#ValidationException","Errors":[{"Code":"InvalidParameterValue","Message":"The value Casa e Cucina provided in the request for SearchIndex is invalid. Refer https://webservices.amazon.it/paapi5/documentation/locale-reference/italy.html#search-index for valid values."}]}
Request ID: 2dc7ab2c-0ea5-4447-809d-fd7ce1c28aca
INFO:root:'NoneType' object is not iterable
Error calling PA-API 5.0!
Status code: 400
Errors : {"__type":"com.amazon.paapi5#ValidationException","Errors":[{"Code":"InvalidParameterValue","Message":"The value Casa e Cucina provided in the request for SearchIndex is invalid. Refer https://webservices.amazon.it/paapi5/documentation/locale-reference/italy.html#search-index for valid values."}]}
Request ID: 3ede10c8-f044-4b0a-91ad-a84b03fe3274
INFO:root:'NoneType' object is not iterable

ModuleNotFoundError: No module named 'paapi5_python_sdk.models'

Someone can help me to start bot ? I have installed all package manually becouse the command ""bash script.sh"" dont work on windows. After install i start bot with python bot.py but the terminal sends me this error :

C:\Users\thebu\OneDrive\Desktop\AmazonOffers-TelegramBot-main>python bot.py
Traceback (most recent call last):
File "C:\Users\thebu\OneDrive\Desktop\AmazonOffers-TelegramBot-main\bot.py", line 4, in
from amazon_api import search_items
File "C:\Users\thebu\OneDrive\Desktop\AmazonOffers-TelegramBot-main\amazon_api.py", line 2, in
from paapi5_python_sdk.models.partner_type import PartnerType
ModuleNotFoundError: No module named 'paapi5_python_sdk.models'

Does it stay in operation?

Hi, I would be interested in trying your bot. My question is how does it stay running? Can i host on a website? Thanks.

Error calling PA-API 5.0! Status code: 429

Hello everybody,

When I start the bot I get this error:
Anyone know how to fix?

thank you for your attention

Error calling PA-API 5.0!
Status code: 429
Errors : {"__type":"com.amazon.paapi5#TooManyRequestsException","Errors":[{"Code":"TooManyRequests","Message":"The request was denied due to request throttling. Please verify the number of requests made per second to the Amazon Product Advertising API."}]}
Request ID: d90e195336-8b-4d33-b431-2e2195b541e0
INFO:root:'NoneType' object is not iterable

More Categories [Help]

Hello!
thank you very much for your code. I wanted to ask you if it was possible to add multiple categories together. I currently run an offer channel where I simply added two bots that activate at the same time but from an optimization point of view I think it's better to add a new category. For example, if I wanted to add the category "Apparel" to the existing category "Fashion", how should I do?

Problem: No module named 'paapi5_python_sdk.models'

Hi when i try to start the bot it says
Traceback (most recent call last):
File "C:\Users\danie\Downloads\AmazonOffers-TelegramBot-main\AmazonOffers-TelegramBot-main\bot.py", line 4, in
from amazon_api import search_items
File "C:\Users\danie\Downloads\AmazonOffers-TelegramBot-main\AmazonOffers-TelegramBot-main\amazon_api.py", line 2, in
from paapi5_python_sdk.models.partner_type import PartnerType
ModuleNotFoundError: No module named 'paapi5_python_sdk.models'
What Am i supposed to do?

hi

who can help me the bot gives me this error

Traceback (most recent call last):
File "bot.py", line 4, in
from amazon_api import search_items
File "/home/demian82/Scrivania/AmazonOffers-TelegramBot-main/amazon_api.py", line 2, in
from paapi5_python_sdk.models.partner_type import PartnerType
ModuleNotFoundError: No module named 'paapi5_python_sdk.models'

Select n keywords

Hello @samirsalman
Is it possible to select randomly only n keywords from the list?
You can add this features?
If there are a lot of keywords, the script crashes and can't move forward.
Another modification would be to write the keywords inside a text file and not directly in the bot.py file
Thanks for your help

AMAZON_HOST

what information needs AMAZON_HOST and AMAZON_REGION ?

Help me!

Hi, I am approaching your bot for the first time and I am truly amazed! However, being new to this language, I would have problems:

  1. I did not understand what parameters I have to put in these fields, especially in the first two. Should I put my email and password?

***** Amazon API Keys and parameters *****

access_key = ""
secret_key = ""
partner_tag = ""
host = ""
region = ""

  1. I would be interested in cloning it however I don't know how to do it. What programs do you need to download?

Error while running the bot

Hi, when start running the bot it says.


Error calling PA-API 5.0!
Status code: 429
Errors : {"__type":"com.amazon.paapi5#TooManyRequestsException","Errors":[{"Code":"TooManyRequests","Message":"The request was denied due to request throttling. Please verify the number of requests made per second to the Amazon Product Advertising API."}]}

How can I solve? thank you for your work

Hours and Hours of search

Hello @samirsalman,
I have entered 5 words in the list of keywords, chosen the category in which to search, everything seems to work but the bot continues for hours to return only the message: Request received
He continues to grind objects upon objects but in the end he does not post any results on the telegram group. Why is the bot unable to finalize the search for objects?
Thanks for your time and help

Request Received

Ciao ho compilato tutto e non mi da alcun errore.
Se lancio mi da Request Received, ma perchè il bot non manda nulla nel mio canale?

Grazie mille

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.