Fix replies to non-chat messages by bot
This commit is contained in:
parent
7bdebb7fd3
commit
17eb4e8bdd
12
bot/bot.py
12
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()
|
||||
|
|
Loading…
Reference in New Issue