add group supportion
This commit is contained in:
66
bot.py
66
bot.py
@ -34,20 +34,28 @@ def on_chat(msg):
|
||||
# pre-treat the command
|
||||
command = [msg['text']]
|
||||
if msg['text'][0] == '/':
|
||||
command = msg['text'].replace('_', ' ').lower().split(' ')
|
||||
command[0] = command[0].replace(config.NAME, '')
|
||||
command = msg['text'].replace(config.NAME, '').replace('_', ' ').lower().split(' ')
|
||||
|
||||
# first-time user
|
||||
if user.status == '第一次用' and chat_type == 'private':
|
||||
user.new_user()
|
||||
if user.status == '第一次用':
|
||||
if chat_type == 'private':
|
||||
user.new_user()
|
||||
else:
|
||||
bot.sendMessage(chat_id, "請先私訊我登入 kCOJ", reply_to_message_id=msg['message_id'])
|
||||
|
||||
# press password
|
||||
elif user.status == '輸入學號' and chat_type == 'private':
|
||||
user.press_password(msg['text'])
|
||||
elif user.status == '輸入學號':
|
||||
if chat_type == 'private':
|
||||
user.press_password(msg['text'])
|
||||
else:
|
||||
bot.sendMessage(chat_id, "請先私訊我登入 kCOJ", reply_to_message_id=msg['message_id'])
|
||||
|
||||
# login
|
||||
elif user.status == '輸入密碼' and chat_type == 'private':
|
||||
user.login_kcoj(msg['text'])
|
||||
elif user.status == '輸入密碼':
|
||||
if chat_type == 'private':
|
||||
user.login_kcoj(msg['text'])
|
||||
else:
|
||||
bot.sendMessage(chat_id, "請先私訊我登入 kCOJ", reply_to_message_id=msg['message_id'])
|
||||
|
||||
elif user.status == '舊的密碼' and chat_type == 'private':
|
||||
if user.check_online() == True:
|
||||
@ -60,30 +68,17 @@ def on_chat(msg):
|
||||
elif user.status == '上傳答案' and chat_type == 'private':
|
||||
if user.check_online() == True:
|
||||
user.send_answer(msg['text'], '')
|
||||
|
||||
|
||||
elif command[0] == '/start' or command[0] == '首頁🏠':
|
||||
if user.check_online() == True:
|
||||
user.display_main()
|
||||
user.display_main(chat_id)
|
||||
|
||||
elif command[0] == '/question' or command[0] == '題庫📝' or command[0] == '更新🔃':
|
||||
if user.check_online() == True:
|
||||
if len(command) > 1:
|
||||
user.display_question(command[1])
|
||||
user.display_question(chat_id, command[1])
|
||||
else:
|
||||
user.display_questions()
|
||||
|
||||
elif command[0] == '/help' or command[0] == '幫助📚':
|
||||
if user.check_online() == True:
|
||||
user.help_you()
|
||||
|
||||
elif command[0] == '/password' or command[0] == '改密碼💱':
|
||||
if user.check_online() == True:
|
||||
user.press_oldpassword()
|
||||
|
||||
elif command[0] == '/logout' or command[0] == '登出🚪':
|
||||
user = kuser(from_id, bot)
|
||||
users[str(from_id)] = user
|
||||
user.logout_system()
|
||||
user.display_questions(chat_id)
|
||||
|
||||
elif command[0] == '/restart':
|
||||
if str(from_id) in config.ADMIN:
|
||||
@ -92,16 +87,29 @@ def on_chat(msg):
|
||||
time.sleep(1)
|
||||
os._exit(0)
|
||||
|
||||
elif (command[0] == '/help' or command[0] == '幫助📚') and chat_type == 'private':
|
||||
if user.check_online() == True:
|
||||
user.help_you()
|
||||
|
||||
elif (command[0] == '/password' or command[0] == '改密碼💱') and chat_type == 'private':
|
||||
if user.check_online() == True:
|
||||
user.press_oldpassword()
|
||||
|
||||
elif (command[0] == '/logout' or command[0] == '登出🚪') and chat_type == 'private':
|
||||
user = kuser(from_id, bot)
|
||||
users[str(from_id)] = user
|
||||
user.logout_system()
|
||||
|
||||
elif user.question != '題外':
|
||||
if user.check_online() == True:
|
||||
if command[0] == '/upload' or command[0] == '交作業📮':
|
||||
if (command[0] == '/upload' or command[0] == '交作業📮') and chat_type == 'private':
|
||||
user.upload_answer()
|
||||
elif command[0] == '/result' or command[0] == '看結果☑️':
|
||||
elif (command[0] == '/result' or command[0] == '看結果☑️') and chat_type == 'private':
|
||||
user.list_results()
|
||||
elif command[0] == '/passer' or command[0] == '通過者🌐':
|
||||
elif (command[0] == '/passer' or command[0] == '通過者🌐') and chat_type == 'private':
|
||||
user.list_passers()
|
||||
elif command[0] == '回題目📜':
|
||||
user.display_question(user.question)
|
||||
user.display_question(chat_id ,user.question)
|
||||
|
||||
elif content_type == 'document':
|
||||
if user.status == '上傳答案' or user.status == '查看題目':
|
||||
|
Reference in New Issue
Block a user