Skip to content

Commit 6ef495f

Browse files
committed
TASK: Add "_cmd" to functions bound to commands
This is to better differentiate between internal logic and method calls to command handler functions
1 parent 863a7c7 commit 6ef495f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

main.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
lang_list = ["de", "en", "nl", "eo", "br", "es", "ru", "fa"]
3535

3636

37-
def start(bot, update):
37+
def start_cmd(bot, update):
3838
chat_id = update.message.chat_id
3939
user_id = update.message.from_user.id
4040
message_id = update.message.message_id
@@ -51,7 +51,7 @@ def start(bot, update):
5151
db.add_user(user_id, "en", first_name, last_name, username)
5252
if chat_id > 0:
5353
# ask user for language:
54-
language(bot, update)
54+
language_cmd(bot, update)
5555
return
5656

5757
# check if user already has got a game (in the same chat):
@@ -103,7 +103,7 @@ def join_secret(bot, update):
103103
# TODO send message that user joined
104104

105105

106-
def stop(bot, update):
106+
def stop_cmd(bot, update):
107107
user_id = update.message.from_user.id
108108
state_handler = StateHandler.get_instance()
109109
user = state_handler.get_user(user_id)
@@ -118,11 +118,11 @@ def help_def(bot, update):
118118
pass
119119

120120

121-
def stats(bot, update):
121+
def stats_cmd(bot, update):
122122
bot.sendMessage(chat_id=update.message.chat_id, text=get_user_stats(update.message.from_user.id))
123123

124124

125-
def language(bot, update):
125+
def language_cmd(bot, update):
126126
lang_de_button = InlineKeyboardButton(text="Deutsch \U0001F1E9\U0001F1EA", callback_data="ch_lang_de")
127127
lang_en_button = InlineKeyboardButton(text="Englisch \U0001F1FA\U0001F1F8", callback_data="ch_lang_en")
128128
lang_nl_button = InlineKeyboardButton(text="Nederlands \U0001F1F3\U0001F1F1", callback_data="ch_lang_nl")
@@ -148,7 +148,7 @@ def language(bot, update):
148148
reply_markup=lang_keyboard, message_id=update.message.message_id)
149149

150150

151-
def comment(bot, update):
151+
def comment_cmd(bot, update):
152152
user_id = update.message.from_user.id
153153
chat_id = update.message.chat_id
154154
first_name = update.message.from_user.first_name
@@ -248,7 +248,7 @@ def callback_eval(bot, update):
248248
change_language(bot=bot, update=update, lang_id=lang_id)
249249

250250
elif query_data == "com_ch_lang":
251-
language(bot, update)
251+
language_cmd(bot, update)
252252

253253
elif query_data == "cancel_comment":
254254
cancel(bot, update)
@@ -299,7 +299,7 @@ def game_commands(bot, update):
299299

300300
if chat_id > 0:
301301
# ask user for language if it's a private chat:
302-
language(bot, update)
302+
language_cmd(bot, update)
303303

304304
return
305305

@@ -320,12 +320,12 @@ def get_translations_of_string(string):
320320
return strings
321321

322322

323-
start_handler = CommandHandler(get_translations_of_string("startCmd"), start)
324-
stop_handler = CommandHandler(get_translations_of_string("stopCmd"), stop)
325-
stats_handler = CommandHandler('stats', stats)
326-
language_handler = CommandHandler('language', language)
323+
start_handler = CommandHandler(get_translations_of_string("startCmd"), start_cmd)
324+
stop_handler = CommandHandler(get_translations_of_string("stopCmd"), stop_cmd)
325+
stats_handler = CommandHandler('stats', stats_cmd)
326+
language_handler = CommandHandler('language', language_cmd)
327327
callback_handler = CallbackQueryHandler(callback_eval)
328-
comment_handler = CommandHandler('comment', comment)
328+
comment_handler = CommandHandler('comment', comment_cmd)
329329
cancel_handler = CommandHandler(get_translations_of_string("cancel"), cancel)
330330
answer_handler = CommandHandler('answer', answer)
331331

0 commit comments

Comments
 (0)