delete function separated
This commit is contained in:
8
bot.py
8
bot.py
@ -89,9 +89,9 @@ def on_chat(msg):
|
|||||||
users[str(from_id)] = user
|
users[str(from_id)] = user
|
||||||
user.logout_system()
|
user.logout_system()
|
||||||
|
|
||||||
elif command[0] == '回題目📜' and user.question != '題外':
|
elif (command[0] == '/delete' or command[0] == '刪除作業⚔️') and user.question != '題外':
|
||||||
if user.check_online() == True:
|
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 != '題外':
|
elif (command[0] == '/upload' or command[0] == '交作業📮') and user.question != '題外':
|
||||||
if user.check_online() == True:
|
if user.check_online() == True:
|
||||||
@ -105,6 +105,10 @@ def on_chat(msg):
|
|||||||
if user.check_online() == True:
|
if user.check_online() == True:
|
||||||
user.list_passers()
|
user.list_passers()
|
||||||
|
|
||||||
|
elif command[0] == '回題目📜' and user.question != '題外':
|
||||||
|
if user.check_online() == True:
|
||||||
|
user.display_question(chat_id ,user.question)
|
||||||
|
|
||||||
elif user.status == '舊的密碼':
|
elif user.status == '舊的密碼':
|
||||||
if user.check_online() == True:
|
if user.check_online() == True:
|
||||||
user.press_newpassword(msg['text'])
|
user.press_newpassword(msg['text'])
|
||||||
|
29
interface.py
29
interface.py
@ -217,25 +217,9 @@ class kuser:
|
|||||||
def send_answer(self, text, file_id):
|
def send_answer(self, text, file_id):
|
||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
if text != '':
|
if text != '':
|
||||||
if text == '首頁🏠':
|
f = open(self.username + self.question + '.c', 'w')
|
||||||
if self.check_online() == True:
|
f.write(text)
|
||||||
self.display_main(self.userid)
|
f.close()
|
||||||
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()
|
|
||||||
else:
|
else:
|
||||||
bot.download_file(file_id, self.username + self.question + '.c')
|
bot.download_file(file_id, self.username + self.question + '.c')
|
||||||
self.api.delete_answer(self.question)
|
self.api.delete_answer(self.question)
|
||||||
@ -254,6 +238,13 @@ class kuser:
|
|||||||
], resize_keyboard=True))
|
], resize_keyboard=True))
|
||||||
os.remove(self.username + self.question + '.c')
|
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):
|
def fail_send(self):
|
||||||
self.status = '正常使用'
|
self.status = '正常使用'
|
||||||
bot.sendMessage(self.userid, "檔案不能超過 20 MB!上傳失敗",
|
bot.sendMessage(self.userid, "檔案不能超過 20 MB!上傳失敗",
|
||||||
|
Reference in New Issue
Block a user