mirror of
https://github.com/yshtcn/DiaryAssistant_bot.git
synced 2025-12-16 19:30:19 +08:00
- 把get方法提交数据改成了post
This commit is contained in:
parent
f3f4b2be49
commit
63a134a37d
@ -68,7 +68,6 @@ def set_bot_commands():
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
return f"An error occurred: {err}"
|
return f"An error occurred: {err}"
|
||||||
|
|
||||||
set_bot_commands()
|
|
||||||
|
|
||||||
# 尝试从文件中加载黑名单
|
# 尝试从文件中加载黑名单
|
||||||
try:
|
try:
|
||||||
@ -122,21 +121,26 @@ def process_message_queue():
|
|||||||
message_queue = []
|
message_queue = []
|
||||||
|
|
||||||
# 遍历消息队列,尝试发送消息
|
# 遍历消息队列,尝试发送消息
|
||||||
|
remaining_messages = []
|
||||||
for message in message_queue:
|
for message in message_queue:
|
||||||
chat_id = message['chat_id']
|
chat_id = message['chat_id']
|
||||||
text = message['text']
|
text = message['text']
|
||||||
try:
|
try:
|
||||||
url = URL + "sendMessage"
|
url = URL + "sendMessage"
|
||||||
params = {'chat_id': chat_id, 'text': text}
|
payload = {'chat_id': chat_id, 'text': text}
|
||||||
r = requests.get(url, params=params, proxies=proxies)
|
r = requests.post(url, json=payload, proxies=proxies)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
message_queue.remove(message)
|
continue
|
||||||
|
else:
|
||||||
|
remaining_messages.append(message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error sending message: {e}")
|
print(f"Error sending message: {e}")
|
||||||
|
remaining_messages.append(message)
|
||||||
|
|
||||||
# 将更新后的消息队列保存回文件
|
# 将更新后(或未成功发送的)消息队列保存回文件
|
||||||
with open('message_queue.json', 'w') as f:
|
with open('message_queue.json', 'w') as f:
|
||||||
json.dump(message_queue, f)
|
json.dump(remaining_messages, f)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 主程序逻辑
|
# 主程序逻辑
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user