diff --git a/bot/bot.py b/bot/bot.py index 66dba24..6c92c29 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -16,7 +16,8 @@ def get_text_or_type(msg, bot, truncate=False): # Set message contents if msg.text: - if msg.from_user.username == bot.username: + if msg.from_user.username == bot.username and re.match('<.*?>(.*)', + msg.text): x = re.compile('(<.*?>)(.*)') y = x.search(msg.text) z = y.group(2) @@ -59,7 +60,8 @@ def get_text_or_type(msg, bot, truncate=False): # Set sender return_message = "" for i in message.strip().split("\n"): - if msg.from_user.username != bot.username: + if msg.from_user.username != bot.username or not re.match('<.*?>(.*)', + msg.text): if msg.from_user.username: return_message += f"@{msg.from_user.username}: " else: @@ -96,7 +98,9 @@ def direct_cmd(bot, update, text): updater = Updater(token=config.api_key) dispatcher = updater.dispatcher -dispatcher.add_handler(CommandHandler('list', lambda x, y: direct_cmd(x, y, "list"))) -dispatcher.add_handler(CommandHandler('time', lambda x, y: direct_cmd(x, y, "time"))) +dispatcher.add_handler(CommandHandler('list', lambda x, y: direct_cmd(x, y, + "list"))) +dispatcher.add_handler(CommandHandler('time', lambda x, y: direct_cmd(x, y, + "time"))) dispatcher.add_handler(MessageHandler(Filters.all, message_handling)) updater.start_polling()