Skip to content

Commit

Permalink
Fix: Dev chat message handling
Browse files Browse the repository at this point in the history
Fix condition to avoid sending messages every time, even if the product code was found.
Fix sending a message for every URL
  • Loading branch information
Aritzherrero4 committed Jul 23, 2023
1 parent d338926 commit ac5105c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

12 changes: 6 additions & 6 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ async def filterText(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None

# Create and send the new url with the affiliate tag
new_url = create_affiliate_url(pCode)
logger.info(f"Filtered link: {msg} -> {new_url}" if m != None else f"Product code not found: {msg} -> {new_url}")

if DEV_CHAT_ID is not None and msg != base_url:
await context.bot.sendMessage(chat_id=DEV_CHAT_ID, text=f'Product code not found! Original URL: {msg} ')
if m != None:
logger.info(f"Filtered link: {msg} -> {new_url}")
else:
logger.warning(f"Product code not found: {msg} -> {new_url}")
if DEV_CHAT_ID != None and msg != base_url:
await context.bot.sendMessage(chat_id=DEV_CHAT_ID, text=f'Product code not found! Original URL: {msg} ')

await context.bot.sendMessage(chat_id=update.message.chat_id, reply_to_message_id=update.effective_message.id, text=new_url)
else:
logger.warning(f'URL not filtered: {msg}')
if DEV_CHAT_ID is not None:
await context.bot.sendMessage(chat_id=DEV_CHAT_ID, text=f'URL not filtered: {msg}')

def main():
"""Start the bot."""
Expand Down

0 comments on commit ac5105c

Please sign in to comment.