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
|
# pre-treat the command
|
||||||
command = [msg['text']]
|
command = [msg['text']]
|
||||||
if msg['text'][0] == '/':
|
if msg['text'][0] == '/':
|
||||||
command = msg['text'].replace('_', ' ').lower().split(' ')
|
command = msg['text'].replace(config.NAME, '').replace('_', ' ').lower().split(' ')
|
||||||
command[0] = command[0].replace(config.NAME, '')
|
|
||||||
|
|
||||||
# first-time user
|
# first-time user
|
||||||
if user.status == '第一次用' and chat_type == 'private':
|
if user.status == '第一次用':
|
||||||
user.new_user()
|
if chat_type == 'private':
|
||||||
|
user.new_user()
|
||||||
|
else:
|
||||||
|
bot.sendMessage(chat_id, "請先私訊我登入 kCOJ", reply_to_message_id=msg['message_id'])
|
||||||
|
|
||||||
# press password
|
# press password
|
||||||
elif user.status == '輸入學號' and chat_type == 'private':
|
elif user.status == '輸入學號':
|
||||||
user.press_password(msg['text'])
|
if chat_type == 'private':
|
||||||
|
user.press_password(msg['text'])
|
||||||
|
else:
|
||||||
|
bot.sendMessage(chat_id, "請先私訊我登入 kCOJ", reply_to_message_id=msg['message_id'])
|
||||||
|
|
||||||
# login
|
# login
|
||||||
elif user.status == '輸入密碼' and chat_type == 'private':
|
elif user.status == '輸入密碼':
|
||||||
user.login_kcoj(msg['text'])
|
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':
|
elif user.status == '舊的密碼' and chat_type == 'private':
|
||||||
if user.check_online() == True:
|
if user.check_online() == True:
|
||||||
@ -60,30 +68,17 @@ def on_chat(msg):
|
|||||||
elif user.status == '上傳答案' and chat_type == 'private':
|
elif user.status == '上傳答案' and chat_type == 'private':
|
||||||
if user.check_online() == True:
|
if user.check_online() == True:
|
||||||
user.send_answer(msg['text'], '')
|
user.send_answer(msg['text'], '')
|
||||||
|
|
||||||
elif command[0] == '/start' or command[0] == '首頁🏠':
|
elif command[0] == '/start' or command[0] == '首頁🏠':
|
||||||
if user.check_online() == True:
|
if user.check_online() == True:
|
||||||
user.display_main()
|
user.display_main(chat_id)
|
||||||
|
|
||||||
elif command[0] == '/question' or command[0] == '題庫📝' or command[0] == '更新🔃':
|
elif command[0] == '/question' or command[0] == '題庫📝' or command[0] == '更新🔃':
|
||||||
if user.check_online() == True:
|
if user.check_online() == True:
|
||||||
if len(command) > 1:
|
if len(command) > 1:
|
||||||
user.display_question(command[1])
|
user.display_question(chat_id, command[1])
|
||||||
else:
|
else:
|
||||||
user.display_questions()
|
user.display_questions(chat_id)
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
||||||
elif command[0] == '/restart':
|
elif command[0] == '/restart':
|
||||||
if str(from_id) in config.ADMIN:
|
if str(from_id) in config.ADMIN:
|
||||||
@ -92,16 +87,29 @@ def on_chat(msg):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
os._exit(0)
|
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 != '題外':
|
elif user.question != '題外':
|
||||||
if user.check_online() == True:
|
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()
|
user.upload_answer()
|
||||||
elif command[0] == '/result' or command[0] == '看結果☑️':
|
elif (command[0] == '/result' or command[0] == '看結果☑️') and chat_type == 'private':
|
||||||
user.list_results()
|
user.list_results()
|
||||||
elif command[0] == '/passer' or command[0] == '通過者🌐':
|
elif (command[0] == '/passer' or command[0] == '通過者🌐') and chat_type == 'private':
|
||||||
user.list_passers()
|
user.list_passers()
|
||||||
elif command[0] == '回題目📜':
|
elif command[0] == '回題目📜':
|
||||||
user.display_question(user.question)
|
user.display_question(chat_id ,user.question)
|
||||||
|
|
||||||
elif content_type == 'document':
|
elif content_type == 'document':
|
||||||
if user.status == '上傳答案' or user.status == '查看題目':
|
if user.status == '上傳答案' or user.status == '查看題目':
|
||||||
|
70
interface.py
70
interface.py
@ -10,8 +10,8 @@ import access
|
|||||||
import config, promote
|
import config, promote
|
||||||
|
|
||||||
class kuser:
|
class kuser:
|
||||||
def __init__(self, chat_id, bot):
|
def __init__(self, from_id, bot):
|
||||||
self.chat_id = chat_id
|
self.from_id = from_id
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.username = ''
|
self.username = ''
|
||||||
self.password = ''
|
self.password = ''
|
||||||
@ -26,19 +26,19 @@ class kuser:
|
|||||||
def press_username(self):
|
def press_username(self):
|
||||||
self.status = '輸入學號'
|
self.status = '輸入學號'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
self.bot.sendMessage(self.chat_id, "請輸入您的學號:", reply_markup=ReplyKeyboardRemove())
|
self.bot.sendMessage(self.from_id, "請輸入您的學號:", reply_markup=ReplyKeyboardRemove())
|
||||||
|
|
||||||
def press_password(self, text):
|
def press_password(self, text):
|
||||||
self.status = '輸入密碼'
|
self.status = '輸入密碼'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
self.username = text
|
self.username = text
|
||||||
self.bot.sendMessage(self.chat_id, "輸入完可刪除訊息以策安全!\n"
|
self.bot.sendMessage(self.from_id, "輸入完可刪除訊息以策安全!\n"
|
||||||
"請輸入您的密碼:", reply_markup=ReplyKeyboardRemove())
|
"請輸入您的密碼:", reply_markup=ReplyKeyboardRemove())
|
||||||
|
|
||||||
def press_oldpassword(self):
|
def press_oldpassword(self):
|
||||||
self.status = '舊的密碼'
|
self.status = '舊的密碼'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
self.bot.sendMessage(self.chat_id, "請輸入要原本的舊密碼:",
|
self.bot.sendMessage(self.from_id, "請輸入要原本的舊密碼:",
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠"]
|
["首頁🏠"]
|
||||||
], resize_keyboard=True))
|
], resize_keyboard=True))
|
||||||
@ -47,19 +47,19 @@ class kuser:
|
|||||||
self.status = '修改密碼'
|
self.status = '修改密碼'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
if text != self.password:
|
if text != self.password:
|
||||||
self.display_main()
|
self.display_main(self.from_id)
|
||||||
else:
|
else:
|
||||||
self.bot.sendMessage(self.chat_id, "使用此功能請務必小心!\n"
|
self.bot.sendMessage(self.from_id, "使用此功能請務必小心!\n"
|
||||||
"請輸入要設定的新密碼:", reply_markup=ReplyKeyboardRemove())
|
"請輸入要設定的新密碼:", reply_markup=ReplyKeyboardRemove())
|
||||||
|
|
||||||
def change_password(self, text):
|
def change_password(self, text):
|
||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
if text == "首頁🏠":
|
if text == "首頁🏠":
|
||||||
self.display_main()
|
self.display_main(self.from_id)
|
||||||
else:
|
else:
|
||||||
self.password = text
|
self.password = text
|
||||||
self.bot.sendMessage(self.chat_id, "修改成功" if self.api.change_password(self.password) == True else "修改失敗",
|
self.bot.sendMessage(self.from_id, "修改成功" if self.api.change_password(self.password) == True else "修改失敗",
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠"]
|
["首頁🏠"]
|
||||||
], resize_keyboard=True))
|
], resize_keyboard=True))
|
||||||
@ -68,14 +68,14 @@ class kuser:
|
|||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
self.password = text
|
self.password = text
|
||||||
self.bot.sendMessage(self.chat_id, "登入中...", reply_markup=ReplyKeyboardRemove())
|
self.bot.sendMessage(self.from_id, "登入中...", reply_markup=ReplyKeyboardRemove())
|
||||||
if self.check_online() == True:
|
if self.check_online() == True:
|
||||||
self.display_main()
|
self.display_main(self.from_id)
|
||||||
|
|
||||||
def fail_login(self):
|
def fail_login(self):
|
||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
self.bot.sendMessage(self.chat_id, "哇...登入失敗,讓我們重新開始一次", reply_markup=ReplyKeyboardRemove())
|
self.bot.sendMessage(self.from_id, "哇...登入失敗,讓我們重新開始一次", reply_markup=ReplyKeyboardRemove())
|
||||||
self.press_username()
|
self.press_username()
|
||||||
|
|
||||||
def check_online(self): # edit
|
def check_online(self): # edit
|
||||||
@ -83,7 +83,7 @@ class kuser:
|
|||||||
result = self.api.check_online()
|
result = self.api.check_online()
|
||||||
if result == None:
|
if result == None:
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
self.bot.sendMessage(self.chat_id, "郭老 Online Judge 離線中!",
|
self.bot.sendMessage(self.from_id, "郭老 Online Judge 離線中!",
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠"]
|
["首頁🏠"]
|
||||||
], resize_keyboard=True))
|
], resize_keyboard=True))
|
||||||
@ -101,10 +101,10 @@ class kuser:
|
|||||||
def logout_system(self):
|
def logout_system(self):
|
||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
self.bot.sendMessage(self.chat_id, "您現在已經是登出的狀態。", reply_markup=ReplyKeyboardRemove())
|
self.bot.sendMessage(self.from_id, "您現在已經是登出的狀態。", reply_markup=ReplyKeyboardRemove())
|
||||||
self.press_username()
|
self.press_username()
|
||||||
|
|
||||||
def display_main(self):
|
def display_main(self, chat_id):
|
||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
q_dict = self.api.list_questions()
|
q_dict = self.api.list_questions()
|
||||||
@ -114,7 +114,7 @@ class kuser:
|
|||||||
q_str += "📗<b>" + key + "</b> (DL: " + q_dict[key][0] + ")\n [[" + q_dict[key][2] + "]]"
|
q_str += "📗<b>" + key + "</b> (DL: " + q_dict[key][0] + ")\n [[" + q_dict[key][2] + "]]"
|
||||||
q_str += "⚠️" if q_dict[key][2] == '未繳' else "✅"
|
q_str += "⚠️" if q_dict[key][2] == '未繳' else "✅"
|
||||||
q_str += " /question_" + key + "\n\n"
|
q_str += " /question_" + key + "\n\n"
|
||||||
self.bot.sendMessage(self.chat_id, "💁 <b>" + self.username + "</b> " + config.NAME + "\n"
|
self.bot.sendMessage(chat_id, "💁 <b>" + self.username + "</b> " + config.NAME + "\n"
|
||||||
"➖➖➖➖➖\n"
|
"➖➖➖➖➖\n"
|
||||||
"📝<i>可繳交的作業</i>\n\n" + q_str + \
|
"📝<i>可繳交的作業</i>\n\n" + q_str + \
|
||||||
"➖➖➖➖➖\n" + choice(promote.sentences),
|
"➖➖➖➖➖\n" + choice(promote.sentences),
|
||||||
@ -122,9 +122,9 @@ class kuser:
|
|||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["題庫📝"],
|
["題庫📝"],
|
||||||
["登出🚪", "改密碼💱", "幫助📚"]
|
["登出🚪", "改密碼💱", "幫助📚"]
|
||||||
], resize_keyboard=True))
|
], resize_keyboard=True) if chat_id == self.from_id else ReplyKeyboardRemove())
|
||||||
|
|
||||||
def display_questions(self):
|
def display_questions(self, chat_id):
|
||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
q_dict = self.api.list_questions()
|
q_dict = self.api.list_questions()
|
||||||
@ -134,7 +134,7 @@ class kuser:
|
|||||||
q_str += "<b>" + key + "</b> (DL: " + q_dict[key][0] + ")\n [[" + q_dict[key][2] + "]]"
|
q_str += "<b>" + key + "</b> (DL: " + q_dict[key][0] + ")\n [[" + q_dict[key][2] + "]]"
|
||||||
q_str += "⚠️" if q_dict[key][2] == '未繳' else "✅"
|
q_str += "⚠️" if q_dict[key][2] == '未繳' else "✅"
|
||||||
q_str += " /question_" + key + "\n\n"
|
q_str += " /question_" + key + "\n\n"
|
||||||
reply = self.bot.sendMessage(self.chat_id, "💁 <b>" + self.username + "</b> " + config.NAME + "\n"
|
reply = self.bot.sendMessage(chat_id, "💁 <b>" + self.username + "</b> " + config.NAME + "\n"
|
||||||
"➖➖➖➖➖\n"
|
"➖➖➖➖➖\n"
|
||||||
"📝<i>所有作業</i>\n\n" + q_str + \
|
"📝<i>所有作業</i>\n\n" + q_str + \
|
||||||
"➖➖➖➖➖\n" + choice(promote.sentences),
|
"➖➖➖➖➖\n" + choice(promote.sentences),
|
||||||
@ -142,10 +142,10 @@ class kuser:
|
|||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠", "更新🔃"],
|
["首頁🏠", "更新🔃"],
|
||||||
["登出🚪", "改密碼💱", "幫助📚"]
|
["登出🚪", "改密碼💱", "幫助📚"]
|
||||||
], resize_keyboard=True))
|
], resize_keyboard=True) if chat_id == self.from_id else ReplyKeyboardRemove())
|
||||||
self.bot.sendMessage(self.chat_id, "點我到題庫頂", reply_to_message_id=reply['message_id'])
|
self.bot.sendMessage(self.from_id, "點我到題庫頂", reply_to_message_id=reply['message_id'])
|
||||||
|
|
||||||
def display_question(self, number):
|
def display_question(self, chat_id, number):
|
||||||
self.status = '查看題目'
|
self.status = '查看題目'
|
||||||
self.question = number
|
self.question = number
|
||||||
content = self.api.show_question(number)
|
content = self.api.show_question(number)
|
||||||
@ -155,18 +155,18 @@ class kuser:
|
|||||||
q_str += "📗" if q[1] == '期限未到' else "📕"
|
q_str += "📗" if q[1] == '期限未到' else "📕"
|
||||||
q_str += "*" + number + "* (DL: " + q[0] + ")\n [[[" + q[2] + "]]]"
|
q_str += "*" + number + "* (DL: " + q[0] + ")\n [[[" + q[2] + "]]]"
|
||||||
q_str += "⚠️" if q[2] == '未繳' else "✅"
|
q_str += "⚠️" if q[2] == '未繳' else "✅"
|
||||||
reply = self.bot.sendMessage(self.chat_id, q_str + "\n\n```\n" + content + "\n```",
|
reply = self.bot.sendMessage(chat_id, q_str + "\n\n```\n" + content + "\n```",
|
||||||
parse_mode='Markdown',
|
parse_mode='Markdown',
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠", "題庫📝"],
|
["首頁🏠", "題庫📝"],
|
||||||
["交作業📮" if q[1] == '期限未到' else '', "看結果☑️" if q[2] == '已繳' else '', "通過者🌐"],
|
["交作業📮" if q[1] == '期限未到' else '', "看結果☑️" if q[2] == '已繳' else '', "通過者🌐"],
|
||||||
["登出🚪", "改密碼💱", "幫助📚"]
|
["登出🚪", "改密碼💱", "幫助📚"]
|
||||||
], resize_keyboard=True))
|
], resize_keyboard=True) if chat_id == self.from_id else ReplyKeyboardRemove())
|
||||||
self.bot.sendMessage(self.chat_id, "點我到題目頂", reply_to_message_id=reply['message_id'])
|
self.bot.sendMessage(chat_id, "點我到題目頂", reply_to_message_id=reply['message_id'])
|
||||||
|
|
||||||
def help_you(self):
|
def help_you(self):
|
||||||
self.question = '題外'
|
self.question = '題外'
|
||||||
self.bot.sendMessage(self.chat_id, "這裡是 kC Online Judge Bot!\n"
|
self.bot.sendMessage(self.from_id, "這裡是 kC Online Judge Bot!\n"
|
||||||
"可以簡稱 kCOJ Bot,目前定居於 [" + config.NAME + "]\n"
|
"可以簡稱 kCOJ Bot,目前定居於 [" + config.NAME + "]\n"
|
||||||
"作用是讓大家可以方便的透過我使用郭老程設課的 Online Judge\n"
|
"作用是讓大家可以方便的透過我使用郭老程設課的 Online Judge\n"
|
||||||
"➡️[傳送門](" + config.URL + ")\n"
|
"➡️[傳送門](" + config.URL + ")\n"
|
||||||
@ -198,7 +198,7 @@ class kuser:
|
|||||||
q_str += "📗" if q[1] == '期限未到' else "📕"
|
q_str += "📗" if q[1] == '期限未到' else "📕"
|
||||||
q_str += "<b>" + self.question + "</b> (DL: " + q[0] + ")\n [[" + q[2] + "]]"
|
q_str += "<b>" + self.question + "</b> (DL: " + q[0] + ")\n [[" + q[2] + "]]"
|
||||||
q_str += "⚠️" if q[2] == '未繳' else "✅"
|
q_str += "⚠️" if q[2] == '未繳' else "✅"
|
||||||
self.bot.sendMessage(self.chat_id, q_str + "\n\n現在請把你的程式碼讓我看看(請別超過 20 MB)\n"
|
self.bot.sendMessage(self.from_id, q_str + "\n\n現在請把你的程式碼讓我看看(請別超過 20 MB)\n"
|
||||||
"可以使用「文字訊息」或是「傳送檔案」的方式", parse_mode='HTML',
|
"可以使用「文字訊息」或是「傳送檔案」的方式", parse_mode='HTML',
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["刪除作業⚔️"] if self.api.list_questions()[self.question][2] == '已繳' else [],
|
["刪除作業⚔️"] if self.api.list_questions()[self.question][2] == '已繳' else [],
|
||||||
@ -210,14 +210,14 @@ class kuser:
|
|||||||
if text != '':
|
if text != '':
|
||||||
if text == '首頁🏠':
|
if text == '首頁🏠':
|
||||||
if self.check_online() == True:
|
if self.check_online() == True:
|
||||||
self.display_main()
|
self.display_main(self.from_id)
|
||||||
return
|
return
|
||||||
elif text == '回題目📜':
|
elif text == '回題目📜':
|
||||||
if self.check_online() == True:
|
if self.check_online() == True:
|
||||||
self.display_question(self.question)
|
self.display_question(self.question)
|
||||||
return
|
return
|
||||||
elif text == '刪除作業⚔️':
|
elif text == '刪除作業⚔️':
|
||||||
self.bot.sendMessage(self.chat_id, "移除成功" if self.api.delete_answer(self.question) == True else "移除失敗",
|
self.bot.sendMessage(self.from_id, "移除成功" if self.api.delete_answer(self.question) == True else "移除失敗",
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠", "回題目📜"],
|
["首頁🏠", "回題目📜"],
|
||||||
["登出🚪", "改密碼💱", "幫助📚"]
|
["登出🚪", "改密碼💱", "幫助📚"]
|
||||||
@ -231,14 +231,14 @@ class kuser:
|
|||||||
self.bot.download_file(file_id, self.username + self.question + '.c')
|
self.bot.download_file(file_id, self.username + self.question + '.c')
|
||||||
self.api.delete_answer(self.question)
|
self.api.delete_answer(self.question)
|
||||||
if self.api.upload_answer(self.question, self.username + self.question + '.c') == True:
|
if self.api.upload_answer(self.question, self.username + self.question + '.c') == True:
|
||||||
self.bot.sendMessage(self.chat_id, "上傳成功",
|
self.bot.sendMessage(self.from_id, "上傳成功",
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠", "回題目📜"],
|
["首頁🏠", "回題目📜"],
|
||||||
["看結果☑️"],
|
["看結果☑️"],
|
||||||
["登出🚪", "改密碼💱", "幫助📚"]
|
["登出🚪", "改密碼💱", "幫助📚"]
|
||||||
], resize_keyboard=True))
|
], resize_keyboard=True))
|
||||||
else:
|
else:
|
||||||
self.bot.sendMessage(self.chat_id, "上傳失敗",
|
self.bot.sendMessage(self.from_id, "上傳失敗",
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠", "回題目📜"],
|
["首頁🏠", "回題目📜"],
|
||||||
["登出🚪", "改密碼💱", "幫助📚"]
|
["登出🚪", "改密碼💱", "幫助📚"]
|
||||||
@ -247,7 +247,7 @@ class kuser:
|
|||||||
|
|
||||||
def fail_send(self):
|
def fail_send(self):
|
||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
self.bot.sendMessage(self.chat_id, "檔案不能超過 20 MB!上傳失敗",
|
self.bot.sendMessage(self.from_id, "檔案不能超過 20 MB!上傳失敗",
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠", "回題目📜"],
|
["首頁🏠", "回題目📜"],
|
||||||
["登出🚪", "改密碼💱", "幫助📚"]
|
["登出🚪", "改密碼💱", "幫助📚"]
|
||||||
@ -264,13 +264,13 @@ class kuser:
|
|||||||
q_str += "<code>\n"
|
q_str += "<code>\n"
|
||||||
for passer in self.api.list_passers(self.question):
|
for passer in self.api.list_passers(self.question):
|
||||||
q_str += "\n" + passer
|
q_str += "\n" + passer
|
||||||
reply = self.bot.sendMessage(self.chat_id, q_str + "</code>",
|
reply = self.bot.sendMessage(self.from_id, q_str + "</code>",
|
||||||
parse_mode='HTML',
|
parse_mode='HTML',
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠", "回題目📜"],
|
["首頁🏠", "回題目📜"],
|
||||||
["登出🚪", "改密碼💱", "幫助📚"]
|
["登出🚪", "改密碼💱", "幫助📚"]
|
||||||
], resize_keyboard=True))
|
], resize_keyboard=True))
|
||||||
self.bot.sendMessage(self.chat_id, "點我到名單頂", reply_to_message_id=reply['message_id'])
|
self.bot.sendMessage(self.from_id, "點我到名單頂", reply_to_message_id=reply['message_id'])
|
||||||
|
|
||||||
def list_results(self):
|
def list_results(self):
|
||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
@ -283,7 +283,7 @@ class kuser:
|
|||||||
q_str += "\n測試編號 <code>" + result[0] + "</code>:"
|
q_str += "\n測試編號 <code>" + result[0] + "</code>:"
|
||||||
q_str += "✔️ " if result[1] == '通過測試' else "❌ "
|
q_str += "✔️ " if result[1] == '通過測試' else "❌ "
|
||||||
q_str += result[1]
|
q_str += result[1]
|
||||||
self.bot.sendMessage(self.chat_id, q_str,
|
self.bot.sendMessage(self.from_id, q_str,
|
||||||
parse_mode='HTML',
|
parse_mode='HTML',
|
||||||
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
reply_markup=ReplyKeyboardMarkup(keyboard=[
|
||||||
["首頁🏠", "回題目📜"],
|
["首頁🏠", "回題目📜"],
|
||||||
|
Reference in New Issue
Block a user