From c93b3c20b30825388f3c984a449d5845bf9a87d5 Mon Sep 17 00:00:00 2001 From: PinLin Date: Thu, 31 Aug 2017 00:39:56 +0800 Subject: [PATCH] restart on non-login status --- bot.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bot.py b/bot.py index ecbe5c4..ce2518d 100644 --- a/bot.py +++ b/bot.py @@ -35,8 +35,14 @@ def on_chat(msg): if msg['text'].startswith('/'): command = msg['text'].replace(config.NAME, '').replace('_', ' ').lower().split(' ') + if command[0] == '/restart' and str(from_id) in config.ADMIN: + bot.sendMessage(chat_id, "即將更新並重新啟動") + print("Restarting...") + time.sleep(1) + os._exit(0) + # first-time user - if user.status == '第一次用': + elif user.status == '第一次用': if chat_type == 'private': user.new_user() elif msg['text'].startswith('/'): @@ -67,13 +73,6 @@ def on_chat(msg): else: user.display_questions(chat_id) - elif command[0] == '/restart': - if str(from_id) in config.ADMIN: - bot.sendMessage(chat_id, "即將更新並重新啟動") - print("Restarting...") - time.sleep(1) - os._exit(0) - elif command[0] == '/ping': bot.sendMessage(chat_id, "*PONG*", parse_mode='Markdown',