restart on non-login status
This commit is contained in:
15
bot.py
15
bot.py
@ -35,8 +35,14 @@ def on_chat(msg):
|
|||||||
if msg['text'].startswith('/'):
|
if msg['text'].startswith('/'):
|
||||||
command = msg['text'].replace(config.NAME, '').replace('_', ' ').lower().split(' ')
|
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
|
# first-time user
|
||||||
if user.status == '第一次用':
|
elif user.status == '第一次用':
|
||||||
if chat_type == 'private':
|
if chat_type == 'private':
|
||||||
user.new_user()
|
user.new_user()
|
||||||
elif msg['text'].startswith('/'):
|
elif msg['text'].startswith('/'):
|
||||||
@ -67,13 +73,6 @@ def on_chat(msg):
|
|||||||
else:
|
else:
|
||||||
user.display_questions(chat_id)
|
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':
|
elif command[0] == '/ping':
|
||||||
bot.sendMessage(chat_id, "*PONG*",
|
bot.sendMessage(chat_id, "*PONG*",
|
||||||
parse_mode='Markdown',
|
parse_mode='Markdown',
|
||||||
|
Reference in New Issue
Block a user