Fixed error with thread_id when responding to a message in a group that has no topics
This commit is contained in:
10
bot/bot.py
10
bot/bot.py
@@ -107,17 +107,23 @@ async def find_amazon_link(update: Update, context: CallbackContext) -> None:
|
||||
logging.info(f"Received message has no text")
|
||||
return
|
||||
|
||||
user, chat, chat_id, message_id, thread_id = (update.message.from_user,
|
||||
user, chat, chat_id, message_id = (update.message.from_user,
|
||||
update.message.chat,
|
||||
update.message.chat_id,
|
||||
update.message.message_id,
|
||||
update.message.message_thread_id)
|
||||
)
|
||||
|
||||
if update.message.is_topic_message:
|
||||
thread_id = update.message.message_thread_id
|
||||
else:
|
||||
thread_id = None
|
||||
|
||||
amazon_url_with_referer, original_message = extract_amazon_url_with_referer(msg)
|
||||
original_message = f"\n\nMensaje original: {original_message}" if original_message != '<enlace>' else ''
|
||||
|
||||
if amazon_url_with_referer:
|
||||
logging.info(f"Link sent by {user} - {msg}")
|
||||
logging.info(f"Info from message: chat_id: {chat_id}, message_id: {message_id}, thread_id: {thread_id}")
|
||||
with create_selenium_driver(get_chrome_options()) as chrome_driver:
|
||||
logging.info("Loading page for scraping information")
|
||||
page_html = load_page(url=amazon_url_with_referer, driver=chrome_driver)
|
||||
|
||||
Reference in New Issue
Block a user