add comment
This commit is contained in:
4
bot.py
4
bot.py
@ -35,6 +35,7 @@ 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(' ')
|
||||||
|
|
||||||
|
# restart this bot
|
||||||
if command[0] == '/restart' and str(from_id) in config.ADMIN:
|
if command[0] == '/restart' and str(from_id) in config.ADMIN:
|
||||||
bot.sendMessage(chat_id, "即將更新並重新啟動")
|
bot.sendMessage(chat_id, "即將更新並重新啟動")
|
||||||
print("Restarting...")
|
print("Restarting...")
|
||||||
@ -56,6 +57,7 @@ def on_chat(msg):
|
|||||||
if chat_type == 'private':
|
if chat_type == 'private':
|
||||||
user.login_kcoj(msg['text'])
|
user.login_kcoj(msg['text'])
|
||||||
|
|
||||||
|
# homepage
|
||||||
elif command[0] == '/start' or command[0] == '首頁🏠':
|
elif command[0] == '/start' or command[0] == '首頁🏠':
|
||||||
if user.check_online(chat_id, msg['message_id']) == True:
|
if user.check_online(chat_id, msg['message_id']) == True:
|
||||||
user.display_main(chat_id)
|
user.display_main(chat_id)
|
||||||
@ -136,6 +138,7 @@ with open('users.json', 'r') as f:
|
|||||||
user = users_restore[key]
|
user = users_restore[key]
|
||||||
users[key] = kuser(user['userid'], user['username'], user['password'], user['status'], user['question'])
|
users[key] = kuser(user['userid'], user['username'], user['password'], user['status'], user['question'])
|
||||||
|
|
||||||
|
# start this bot
|
||||||
MessageLoop(bot, on_chat).run_as_thread()
|
MessageLoop(bot, on_chat).run_as_thread()
|
||||||
print("Started! Service is available.")
|
print("Started! Service is available.")
|
||||||
|
|
||||||
@ -144,6 +147,7 @@ while True:
|
|||||||
|
|
||||||
# keep alive
|
# keep alive
|
||||||
bot.getMe()
|
bot.getMe()
|
||||||
|
|
||||||
# backup
|
# backup
|
||||||
users_backup = {}
|
users_backup = {}
|
||||||
for key in users.keys():
|
for key in users.keys():
|
||||||
|
Reference in New Issue
Block a user