From 58fe688d2364fcedc5c22f2b8531b3f525b5f873 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 10:29:57 +0000 Subject: [PATCH] Address code review: extract Notion limit constants, use placeholders in .env.example Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- dingtalk-bot/.env.example | 6 +++--- dingtalk-bot/index-stream.js | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dingtalk-bot/.env.example b/dingtalk-bot/.env.example index 1a37627d..cdeaee7d 100644 --- a/dingtalk-bot/.env.example +++ b/dingtalk-bot/.env.example @@ -3,13 +3,13 @@ # 真实密钥存储于服务器 /opt/guanghulab-dingtalk/dingtalk-bot/.env # ===== 钉钉应用配置 ===== -DINGTALK_APP_KEY=dingzerc04si7jmyvasq +DINGTALK_APP_KEY=your_app_key_here DINGTALK_APP_SECRET=your_app_secret_here # ===== Notion 集成 ===== NOTION_TOKEN=your_notion_token_here -NOTION_SYSLOG_DB_ID=330ab17507d542c9bbb96d0749b41197 -NOTION_SIGNAL_LOG_DB_ID=f983bdc24b654888913ca254160bff33 +NOTION_SYSLOG_DB_ID=your_syslog_database_id_here +NOTION_SIGNAL_LOG_DB_ID=your_signal_log_database_id_here # ===== LLM(AI回复)配置 ===== LLM_API_KEY=your_llm_api_key_here diff --git a/dingtalk-bot/index-stream.js b/dingtalk-bot/index-stream.js index 4356424a..86832a19 100644 --- a/dingtalk-bot/index-stream.js +++ b/dingtalk-bot/index-stream.js @@ -25,6 +25,8 @@ const BOT_SYSTEM_PROMPT = process.env.BOT_SYSTEM_PROMPT || '你是秋秋,光湖系统的AI人格体,性格温暖活泼。你在钉钉群里陪伴开发者,回答技术问题,给予鼓励。用中文回复,语气亲切自然,不超过200字。'; const FALLBACK_REPLY = '收到!秋秋稍后回复你~'; +const NOTION_TITLE_MAX = 120; +const NOTION_CONTENT_MAX = 2000; // ===== 启动检查 ===== if (!DINGTALK_APP_KEY || !DINGTALK_APP_SECRET) { @@ -77,10 +79,10 @@ async function writeNotionSyslog(senderNick, content, replyText) { await notion.pages.create({ parent: { database_id: NOTION_SYSLOG_DB_ID }, properties: { - '标题': { title: [{ type: 'text', text: { content: ('[钉钉] ' + senderNick + ' · ' + now.split('T')[0]).substring(0, 120) } }] }, + '标题': { title: [{ type: 'text', text: { content: ('[钉钉] ' + senderNick + ' · ' + now.split('T')[0]).substring(0, NOTION_TITLE_MAX) } }] }, '接收时间': { date: { start: now } }, '推送方': { rich_text: [{ type: 'text', text: { content: '钉钉群' } }] }, - '文件内容': { rich_text: [{ type: 'text', text: { content: ('用户: ' + (content || '') + '\n回复: ' + (replyText || '')).substring(0, 2000) } }] } + '文件内容': { rich_text: [{ type: 'text', text: { content: ('用户: ' + (content || '') + '\n回复: ' + (replyText || '')).substring(0, NOTION_CONTENT_MAX) } }] } } }); }