Avoid sending excess messages and unnecessary state drops

This commit is contained in:
Ceda EI 2019-03-19 18:02:05 +05:30
parent 697738945f
commit 3b134ae5f2
1 changed files with 14 additions and 10 deletions

24
bot.py
View File

@ -486,8 +486,8 @@ def message_handling(bot, update, db):
delete_token(bot, update, player) delete_token(bot, update, player)
else: else:
drop_state(bot, update, player) if update.message.chat.type == "private":
send_status(bot, update, player) send_status(bot, update, player)
elif state["state"] == "aq": elif state["state"] == "aq":
add_name(bot, update, player, "quest", state["extra"]) add_name(bot, update, player, "quest", state["extra"])
@ -540,8 +540,9 @@ def message_handling(bot, update, db):
prefix = f"<b>Quest {quest.name} has been deleted</b>\n\n" prefix = f"<b>Quest {quest.name} has been deleted</b>\n\n"
send_status(bot, update, player, prefix=prefix) send_status(bot, update, player, prefix=prefix)
else: else:
drop_state(bot, update, player) if update.message.chat.type == "private":
send_status(bot, update, player) drop_state(bot, update, player)
send_status(bot, update, player)
elif state["state"] == "esq": elif state["state"] == "esq":
if text == "back" or text == "⬅️ back": if text == "back" or text == "⬅️ back":
@ -576,12 +577,14 @@ def message_handling(bot, update, db):
prefix = f"<b>Side Quest {sq.name} has been deleted</b>\n\n" prefix = f"<b>Side Quest {sq.name} has been deleted</b>\n\n"
send_status(bot, update, player, prefix=prefix) send_status(bot, update, player, prefix=prefix)
else: else:
drop_state(bot, update, player) if update.message.chat.type == "private":
send_status(bot, update, player) drop_state(bot, update, player)
send_status(bot, update, player)
elif state["state"] == "bo": elif state["state"] == "bo":
player.set_state('none', 0) if text == "back" or update.message.chat.type == "private":
send_status(bot, update, player) player.set_state('none', 0)
send_status(bot, update, player)
elif state["state"] == "eqn": elif state["state"] == "eqn":
edit_quest(bot, update, player, state["extra"], "name", "quest") edit_quest(bot, update, player, state["extra"], "name", "quest")
@ -604,8 +607,9 @@ def message_handling(bot, update, db):
elif state["state"] == "rt": elif state["state"] == "rt":
delete_token_rt(bot, update, player) delete_token_rt(bot, update, player)
else: else:
drop_state(bot, update, player) if update.message.chat.type == "private":
send_status(bot, update, player) drop_state(bot, update, player)
send_status(bot, update, player)
def sigterm_handler(signal, frame, db): def sigterm_handler(signal, frame, db):