mirror of
https://github.com/yshtcn/DiaryAssistant_bot.git
synced 2025-12-17 11:50:19 +08:00
bug修复
- 修复了存在多个同样id的问题 - 调整了回复的样式 - 最后的结束语句是/done - 成功收到数据会循环把信息发出去,每次结束时还会补发。
This commit is contained in:
parent
2f086c561f
commit
5902f18819
@ -145,18 +145,23 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
chat_id_str = str(chat_id)
|
||||||
|
|
||||||
if unique_id not in blacklist:
|
if unique_id not in blacklist:
|
||||||
# 处理“done”命令
|
# 处理“done”命令
|
||||||
if message_text.lower() == "/todaydone":
|
if message_text.lower() == "/done":
|
||||||
send_message(chat_id, "\n".join(user_data[chat_id]))
|
send_message(chat_id_str, "\n\n".join(user_data[chat_id_str]))
|
||||||
user_data[chat_id] = []
|
user_data[chat_id_str] = []
|
||||||
|
blacklist.append(unique_id)
|
||||||
else:
|
else:
|
||||||
send_message(chat_id, f"{message_text_with_datetime}")
|
send_message(chat_id_str, f"{message_text_with_datetime}")
|
||||||
if chat_id not in user_data:
|
if chat_id_str not in user_data:
|
||||||
user_data[chat_id] = []
|
user_data[chat_id_str] = []
|
||||||
user_data[chat_id].append(message_text)
|
user_data[chat_id_str].append(message_text)
|
||||||
blacklist.append(unique_id) # 添加到黑名单
|
blacklist.append(unique_id) # 添加到黑名单
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 保存数据到文件
|
# 保存数据到文件
|
||||||
with open('user_data.json', 'w') as f:
|
with open('user_data.json', 'w') as f:
|
||||||
json.dump(user_data, f)
|
json.dump(user_data, f)
|
||||||
@ -170,13 +175,15 @@ def main():
|
|||||||
with open('blacklist.json', 'w') as f:
|
with open('blacklist.json', 'w') as f:
|
||||||
json.dump(blacklist, f)
|
json.dump(blacklist, f)
|
||||||
|
|
||||||
|
print("process message queue...")
|
||||||
process_message_queue()
|
process_message_queue()
|
||||||
else:
|
else:
|
||||||
print(f"{URL} Received updates: {updates}")
|
print(f"{URL} Received updates: {updates}")
|
||||||
print("Error or no updates; retrying in 5 seconds...")
|
print("Error or no updates; retrying in 5 seconds...")
|
||||||
time.sleep(5) # 等待5秒再重试
|
time.sleep(5) # 等待5秒再重试
|
||||||
|
|
||||||
|
print("process message queue...")
|
||||||
|
process_message_queue()
|
||||||
# 每1分钟检查一次
|
# 每1分钟检查一次
|
||||||
time.sleep(15)
|
time.sleep(15)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user