diff --git a/bot.py b/bot.py index 732f4e1..7aea760 100755 --- a/bot.py +++ b/bot.py @@ -98,11 +98,11 @@ def add_name(bot, update, player, type, qid): def add_diff(bot, update, player, type, qid): message = update.message.text.lower() chat_id = update.message.chat_id - if message == "low" or message == "๐Ÿ“™ low": + if message in ["low", "๐Ÿ“™ low", "l"]: diff = 1 - elif message == "medium" or message == "๐Ÿ“˜ medium": + elif message in ["medium", "๐Ÿ“˜ medium", "m"]: diff = 2 - elif message == "high" or message == "๐Ÿ“— high": + elif message in ["high", "๐Ÿ“— high", "h"]: diff = 3 else: bot.send_message(chat_id=chat_id, text="Invalid Option") @@ -129,11 +129,11 @@ def add_diff(bot, update, player, type, qid): def add_imp(bot, update, player, type, qid): message = update.message.text.lower() chat_id = update.message.chat_id - if message == "low" or message == "๐Ÿ”น low": + if message in ["low", "๐Ÿ”น low", "l"]: imp = 1 - elif message == "medium" or message == "๐Ÿ”ธ medium": + elif message in ["medium", "๐Ÿ”ธ medium", "m"]: imp = 2 - elif message == "high" or message == "๐Ÿ”บ high": + elif message in ["high", "๐Ÿ”บ high", "h"]: imp = 3 else: bot.send_message(chat_id=chat_id, text="Invalid Option") @@ -305,11 +305,11 @@ def edit_quest(bot, update, player, qid, target, type): text = "โ˜‘๏ธ Updated Name" elif target == "imp": message = message.lower() - if message == "low" or message == "๐Ÿ”น low": + if message in ["low", "๐Ÿ”น low", "l"]: x.imp = 1 - elif message == "medium" or message == "๐Ÿ”ธ medium": + elif message in ["medium", "๐Ÿ”ธ medium", "m"]: x.imp = 2 - elif message == "high" or message == "๐Ÿ”บ high": + elif message in ["high", "๐Ÿ”บ high", "h"]: x.imp = 3 else: bot.send_message(chat_id=chat_id, text="Invalid Option") @@ -317,11 +317,11 @@ def edit_quest(bot, update, player, qid, target, type): text = "โ˜‘๏ธ Updated Priority" elif target == "diff": message = message.lower() - if message == "low" or message == "๐Ÿ“™ low": + if message in ["low", "๐Ÿ“™ low", "l"]: x.diff = 1 - elif message == "medium" or message == "๐Ÿ“˜ medium": + elif message in ["medium", "๐Ÿ“˜ medium", "m"]: x.diff = 2 - elif message == "high" or message == "๐Ÿ“— high": + elif message in ["high", "๐Ÿ“— high", "h"]: x.diff = 3 else: bot.send_message(chat_id=chat_id, text="Invalid Option") @@ -466,23 +466,21 @@ def message_handling(bot, update, db): # rt: Remove token if state["state"] == "none": - if text == "add quest" or text == "โ‡๏ธ add quest": + if text in ["add quest", "โ‡๏ธ add quest", "aq"]: add_quest(bot, update, player) - elif text == "add side quest" or text == "๐Ÿ“ฏ add side quest": + elif text in ["add side quest", "๐Ÿ“ฏ add side quest", "asq"]: add_quest(bot, update, player, "side_quest") - elif text == "list quests" or text == "๐Ÿ“œ list quests": + elif text in ["list quests", "๐Ÿ“œ list quests", "lq"]: list_quests(bot, update, player, "quest") - elif text == "list side quests" or text == "๐Ÿ“ƒ list side quests": + elif text in ["list side quests", "๐Ÿ“ƒ list side quests", "lsq"]: list_quests(bot, update, player, "side_quest") - elif text == "tokens" or text == "๐Ÿ”‘ tokens": + elif text in ["tokens", "๐Ÿ”‘ tokens", "t"]: tokens(bot, update) - elif text == "list tokens" or text == "๐Ÿ“‹ list tokens": + elif text in ["list tokens", "๐Ÿ“‹ list tokens", "lt"]: list_tokens(bot, update, player) - - elif text == "generate token" or text == "๐Ÿ”‘ generate token": + elif text in ["generate token", "๐Ÿ”‘ generate token", "gt"]: add_token(bot, update, player) - - elif text == "delete token" or text == "๐Ÿงน delete token": + elif text in ["delete token", "๐Ÿงน delete token", "dt"]: delete_token(bot, update, player) else: @@ -508,32 +506,32 @@ def message_handling(bot, update, db): add_imp(bot, update, player, "side_quest", state["extra"]) elif state["state"] == "eq": - if text == "back" or text == "โฌ…๏ธ back": + if text in ["back", "โฌ…๏ธ back", "b"]: player.set_state('none', 0) send_status(bot, update, player) - elif text == "mark as done" or text == "โœ… mark as done": + elif text in ["mark as done", "โœ… mark as done", "mad"]: mark_as_done(bot, update, player, state["extra"], "quest") - elif text == "edit name" or text == "๐Ÿ“ edit name": + elif text in ["edit name", "๐Ÿ“ edit name", "en"]: player.set_state('eqn', state["extra"]) text = "What shall the new name of the Quest be?" reply_markup = telegram.ReplyKeyboardRemove() bot.send_message(chat_id=player.CHAT_ID, text=text, reply_markup=reply_markup) - elif text == "change priority" or text == "โš ๏ธ change priority": + elif text in ["change priority", "โš ๏ธ change priority", "cp"]: player.set_state('eqi', state["extra"]) text = "How important is it?" custom_keyboard = button_groups.importance reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard) bot.send_message(chat_id=player.CHAT_ID, text=text, reply_markup=reply_markup) - elif text == "change difficulty" or text == "๐Ÿ“š change difficulty": + elif text in ["change difficulty", "๐Ÿ“š change difficulty", "cd"]: player.set_state('eqd', state["extra"]) text = "How difficult is it?" custom_keyboard = button_groups.difficulty reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard) bot.send_message(chat_id=player.CHAT_ID, text=text, reply_markup=reply_markup) - elif text == "delete quest" or text == "๐Ÿ—‘ delete quest": + elif text in ["delete quest", "๐Ÿ—‘ delete ques", "dq"]: quest = questable.get_quest(db, player.CHAT_ID, state["extra"]) quest.delete_from_db() drop_state(bot, update, player) @@ -545,32 +543,32 @@ def message_handling(bot, update, db): send_status(bot, update, player) elif state["state"] == "esq": - if text == "back" or text == "โฌ…๏ธ back": + if text in ["back", "โฌ…๏ธ back", "b"]: player.set_state('none', 0) send_status(bot, update, player) - elif text == "mark as done" or text == "โœ… mark as done": + elif text in ["mark as done", "โœ… mark as done", "mad"]: mark_as_done(bot, update, player, state["extra"], "side_quest") - elif text == "edit name" or text == "๐Ÿ“ edit name": + elif text in ["edit name", "๐Ÿ“ edit name", "en"]: player.set_state('esqn', state["extra"]) text = "What shall the new name of the Side Quest be?" reply_markup = telegram.ReplyKeyboardRemove() bot.send_message(chat_id=player.CHAT_ID, text=text, reply_markup=reply_markup) - elif text == "change priority" or text == "โš ๏ธ change priority": + elif text in ["change priority", "โš ๏ธ change priority", "cp"]: player.set_state('esqi', state["extra"]) text = "How important is it?" custom_keyboard = button_groups.importance reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard) bot.send_message(chat_id=player.CHAT_ID, text=text, reply_markup=reply_markup) - elif text == "change difficulty" or text == "๐Ÿ“š change difficulty": + elif text in ["change difficulty", "๐Ÿ“š change difficulty", "cd"]: player.set_state('esqd', state["extra"]) text = "How difficult is it?" custom_keyboard = button_groups.difficulty reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard) bot.send_message(chat_id=player.CHAT_ID, text=text, reply_markup=reply_markup) - elif text == "delete side quest" or text == "๐Ÿ—‘ delete side quest": + elif text in ["delete side quest", "๐Ÿ—‘ delete side quest", "dsq"]: sq = questable.get_side_quest(db, player.CHAT_ID, state["extra"]) sq.delete_from_db() drop_state(bot, update, player)