diff --git a/bot.py b/bot.py index 0c06dab..fceb45c 100644 --- a/bot.py +++ b/bot.py @@ -89,9 +89,9 @@ def on_chat(msg): users[str(from_id)] = user user.logout_system() - elif command[0] == '回題目📜' and user.question != '題外': + elif (command[0] == '/delete' or command[0] == '刪除作業⚔️') and user.question != '題外': if user.check_online() == True: - user.display_question(chat_id ,user.question) + user.delete_answer() elif (command[0] == '/upload' or command[0] == '交作業📮') and user.question != '題外': if user.check_online() == True: @@ -105,6 +105,10 @@ def on_chat(msg): if user.check_online() == True: user.list_passers() + elif command[0] == '回題目📜' and user.question != '題外': + if user.check_online() == True: + user.display_question(chat_id ,user.question) + elif user.status == '舊的密碼': if user.check_online() == True: user.press_newpassword(msg['text']) diff --git a/interface.py b/interface.py index afb58f4..436048b 100644 --- a/interface.py +++ b/interface.py @@ -217,25 +217,9 @@ class kuser: def send_answer(self, text, file_id): self.status = '正常使用' if text != '': - if text == '首頁🏠': - if self.check_online() == True: - self.display_main(self.userid) - return - elif text == '回題目📜': - if self.check_online() == True: - self.display_question(self.question) - return - elif text == '刪除作業⚔️': - bot.sendMessage(self.userid, "移除成功" if self.api.delete_answer(self.question) == True else "移除失敗", - reply_markup=ReplyKeyboardMarkup(keyboard=[ - ["首頁🏠", "回題目📜"], - ["登出🚪", "改密碼💱", "幫助📚"] - ], resize_keyboard=True)) - return - else: - f = open(self.username + self.question + '.c', 'w') - f.write(text) - f.close() + f = open(self.username + self.question + '.c', 'w') + f.write(text) + f.close() else: bot.download_file(file_id, self.username + self.question + '.c') self.api.delete_answer(self.question) @@ -254,6 +238,13 @@ class kuser: ], resize_keyboard=True)) os.remove(self.username + self.question + '.c') + def delete_answer(self): + bot.sendMessage(self.userid, "移除成功" if self.api.delete_answer(self.question) == True else "移除失敗", + reply_markup=ReplyKeyboardMarkup(keyboard=[ + ["首頁🏠", "回題目📜"], + ["登出🚪", "改密碼💱", "幫助📚"] + ], resize_keyboard=True)) + def fail_send(self): self.status = '正常使用' bot.sendMessage(self.userid, "檔案不能超過 20 MB!上傳失敗",