Add initial shortcuts

This commit is contained in:
Ceda EI 2019-04-13 00:55:56 +05:30
parent a23f1499ec
commit 0a41d3d868
1 changed files with 32 additions and 34 deletions

66
bot.py
View File

@ -98,11 +98,11 @@ def add_name(bot, update, player, type, qid):
def add_diff(bot, update, player, type, qid): def add_diff(bot, update, player, type, qid):
message = update.message.text.lower() message = update.message.text.lower()
chat_id = update.message.chat_id chat_id = update.message.chat_id
if message == "low" or message == "📙 low": if message in ["low", "📙 low", "l"]:
diff = 1 diff = 1
elif message == "medium" or message == "📘 medium": elif message in ["medium", "📘 medium", "m"]:
diff = 2 diff = 2
elif message == "high" or message == "📗 high": elif message in ["high", "📗 high", "h"]:
diff = 3 diff = 3
else: else:
bot.send_message(chat_id=chat_id, text="Invalid Option") 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): def add_imp(bot, update, player, type, qid):
message = update.message.text.lower() message = update.message.text.lower()
chat_id = update.message.chat_id chat_id = update.message.chat_id
if message == "low" or message == "🔹 low": if message in ["low", "🔹 low", "l"]:
imp = 1 imp = 1
elif message == "medium" or message == "🔸 medium": elif message in ["medium", "🔸 medium", "m"]:
imp = 2 imp = 2
elif message == "high" or message == "🔺 high": elif message in ["high", "🔺 high", "h"]:
imp = 3 imp = 3
else: else:
bot.send_message(chat_id=chat_id, text="Invalid Option") bot.send_message(chat_id=chat_id, text="Invalid Option")
@ -305,11 +305,11 @@ def edit_quest(bot, update, player, qid, target, type):
text = "<b>☑️ Updated Name</b>" text = "<b>☑️ Updated Name</b>"
elif target == "imp": elif target == "imp":
message = message.lower() message = message.lower()
if message == "low" or message == "🔹 low": if message in ["low", "🔹 low", "l"]:
x.imp = 1 x.imp = 1
elif message == "medium" or message == "🔸 medium": elif message in ["medium", "🔸 medium", "m"]:
x.imp = 2 x.imp = 2
elif message == "high" or message == "🔺 high": elif message in ["high", "🔺 high", "h"]:
x.imp = 3 x.imp = 3
else: else:
bot.send_message(chat_id=chat_id, text="Invalid Option") bot.send_message(chat_id=chat_id, text="Invalid Option")
@ -317,11 +317,11 @@ def edit_quest(bot, update, player, qid, target, type):
text = "<b>☑️ Updated Priority</b>" text = "<b>☑️ Updated Priority</b>"
elif target == "diff": elif target == "diff":
message = message.lower() message = message.lower()
if message == "low" or message == "📙 low": if message in ["low", "📙 low", "l"]:
x.diff = 1 x.diff = 1
elif message == "medium" or message == "📘 medium": elif message in ["medium", "📘 medium", "m"]:
x.diff = 2 x.diff = 2
elif message == "high" or message == "📗 high": elif message in ["high", "📗 high", "h"]:
x.diff = 3 x.diff = 3
else: else:
bot.send_message(chat_id=chat_id, text="Invalid Option") bot.send_message(chat_id=chat_id, text="Invalid Option")
@ -466,23 +466,21 @@ def message_handling(bot, update, db):
# rt: Remove token # rt: Remove token
if state["state"] == "none": 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) 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") 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") 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") list_quests(bot, update, player, "side_quest")
elif text == "tokens" or text == "🔑 tokens": elif text in ["tokens", "🔑 tokens", "t"]:
tokens(bot, update) tokens(bot, update)
elif text == "list tokens" or text == "📋 list tokens": elif text in ["list tokens", "📋 list tokens", "lt"]:
list_tokens(bot, update, player) list_tokens(bot, update, player)
elif text in ["generate token", "🔑 generate token", "gt"]:
elif text == "generate token" or text == "🔑 generate token":
add_token(bot, update, player) add_token(bot, update, player)
elif text in ["delete token", "🧹 delete token", "dt"]:
elif text == "delete token" or text == "🧹 delete token":
delete_token(bot, update, player) delete_token(bot, update, player)
else: else:
@ -508,32 +506,32 @@ def message_handling(bot, update, db):
add_imp(bot, update, player, "side_quest", state["extra"]) add_imp(bot, update, player, "side_quest", state["extra"])
elif state["state"] == "eq": elif state["state"] == "eq":
if text == "back" or text == "⬅️ back": if text in ["back", "⬅️ back", "b"]:
player.set_state('none', 0) player.set_state('none', 0)
send_status(bot, update, player) 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") 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"]) player.set_state('eqn', state["extra"])
text = "What shall the new name of the Quest be?" text = "What shall the new name of the Quest be?"
reply_markup = telegram.ReplyKeyboardRemove() reply_markup = telegram.ReplyKeyboardRemove()
bot.send_message(chat_id=player.CHAT_ID, text=text, bot.send_message(chat_id=player.CHAT_ID, text=text,
reply_markup=reply_markup) 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"]) player.set_state('eqi', state["extra"])
text = "How important is it?" text = "How important is it?"
custom_keyboard = button_groups.importance custom_keyboard = button_groups.importance
reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard) reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard)
bot.send_message(chat_id=player.CHAT_ID, text=text, bot.send_message(chat_id=player.CHAT_ID, text=text,
reply_markup=reply_markup) 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"]) player.set_state('eqd', state["extra"])
text = "How difficult is it?" text = "How difficult is it?"
custom_keyboard = button_groups.difficulty custom_keyboard = button_groups.difficulty
reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard) reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard)
bot.send_message(chat_id=player.CHAT_ID, text=text, bot.send_message(chat_id=player.CHAT_ID, text=text,
reply_markup=reply_markup) 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 = questable.get_quest(db, player.CHAT_ID, state["extra"])
quest.delete_from_db() quest.delete_from_db()
drop_state(bot, update, player) drop_state(bot, update, player)
@ -545,32 +543,32 @@ def message_handling(bot, update, db):
send_status(bot, update, player) send_status(bot, update, player)
elif state["state"] == "esq": elif state["state"] == "esq":
if text == "back" or text == "⬅️ back": if text in ["back", "⬅️ back", "b"]:
player.set_state('none', 0) player.set_state('none', 0)
send_status(bot, update, player) 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") 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"]) player.set_state('esqn', state["extra"])
text = "What shall the new name of the Side Quest be?" text = "What shall the new name of the Side Quest be?"
reply_markup = telegram.ReplyKeyboardRemove() reply_markup = telegram.ReplyKeyboardRemove()
bot.send_message(chat_id=player.CHAT_ID, text=text, bot.send_message(chat_id=player.CHAT_ID, text=text,
reply_markup=reply_markup) 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"]) player.set_state('esqi', state["extra"])
text = "How important is it?" text = "How important is it?"
custom_keyboard = button_groups.importance custom_keyboard = button_groups.importance
reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard) reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard)
bot.send_message(chat_id=player.CHAT_ID, text=text, bot.send_message(chat_id=player.CHAT_ID, text=text,
reply_markup=reply_markup) 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"]) player.set_state('esqd', state["extra"])
text = "How difficult is it?" text = "How difficult is it?"
custom_keyboard = button_groups.difficulty custom_keyboard = button_groups.difficulty
reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard) reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard)
bot.send_message(chat_id=player.CHAT_ID, text=text, bot.send_message(chat_id=player.CHAT_ID, text=text,
reply_markup=reply_markup) 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 = questable.get_side_quest(db, player.CHAT_ID, state["extra"])
sq.delete_from_db() sq.delete_from_db()
drop_state(bot, update, player) drop_state(bot, update, player)