From d408d78303b0c0a209968bd11de54e2741f036b7 Mon Sep 17 00:00:00 2001 From: yshtcn Date: Mon, 25 Sep 2023 17:13:54 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0GPT=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AF=AD=20-=20=E7=AE=80=E5=8C=96=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Diary Assistant.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Diary Assistant.py b/Diary Assistant.py index 3773b66..0b7ef8f 100644 --- a/Diary Assistant.py +++ b/Diary Assistant.py @@ -53,17 +53,18 @@ def set_bot_commands(): try: set_commands_url = URL + "setMyCommands" commands = [ - {"command": "start", "description": "首次使用向导/显示帮助。"}, - {"command": "done", "description": "结束记录:发送并开始新的记录。"}, - {"command": "check", "description": "检查记录,已有记录。"}, - {"command": "removelast", "description": "删除最后一条记录。"} + {"command": "/start", "description": "首次使用"}, + {"command": "/tips", "description": "GPT提示语"}, + {"command": "/done", "description": "结束记录"}, + {"command": "/check", "description": "检查记录"}, + {"command": "/removelast", "description": "删除最后记录"} ] response = requests.post(set_commands_url, json={"commands": commands}, proxies=proxies) response.raise_for_status() # 如果响应状态码不是200,引发HTTPError异常 return response.json() except requests.HTTPError as http_err: - return f"HTTP error occurred: {http_err}" + return f"HTTP error occurred: {http_err} - {response.text}" except Exception as err: return f"An error occurred: {err}" @@ -186,7 +187,11 @@ def main(): # 处理特殊命令 if message_text.lower() == "/start": send_message(chat_id_str, f"#使用帮助\n欢迎使日记助手,你可以直接开始发送要记录的内容.随时可以发送: \n/check 查看已记录的内容,并继续记录。\n /done 记录完毕,把记录发送给您,并开启新的记录。\n /removelast 删除最后一条信息。注意:直接编辑信息并不会修改错误的记录!") - blacklist.append(unique_id) + blacklist.append(unique_id) + if message_text.lower() == "/tips": + current_date = datetime.now().strftime("%Y年%m月%d日") + send_message(chat_id_str, f"Dear ChatGPT, 今天是{current_date}. 我希望你能成为我的日记助手。请注意: 在这一天里,无论我输入什么内容,你都只需要回复: \"####\" . 只有当我输入\"Hi ChatGPT, 让我们结束今天的日记\"时,你才开始执行我规定的任务.") + blacklist.append(unique_id) elif message_text.lower() == "/done": main_text="\n\n".join(user_data[chat_id_str]) send_message(chat_id_str, f"#二次确认\n你真的要结束本次记录吗?确认请点击: /confirmdone \n如果不想结束本次记录,直接忽视这条信息、继续发送信息或使用其他指令都可以。")