Address code review: extract Notion limit constants, use placeholders in .env.example
Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
parent
28b0e89cf7
commit
58fe688d23
|
|
@ -3,13 +3,13 @@
|
||||||
# 真实密钥存储于服务器 /opt/guanghulab-dingtalk/dingtalk-bot/.env
|
# 真实密钥存储于服务器 /opt/guanghulab-dingtalk/dingtalk-bot/.env
|
||||||
|
|
||||||
# ===== 钉钉应用配置 =====
|
# ===== 钉钉应用配置 =====
|
||||||
DINGTALK_APP_KEY=dingzerc04si7jmyvasq
|
DINGTALK_APP_KEY=your_app_key_here
|
||||||
DINGTALK_APP_SECRET=your_app_secret_here
|
DINGTALK_APP_SECRET=your_app_secret_here
|
||||||
|
|
||||||
# ===== Notion 集成 =====
|
# ===== Notion 集成 =====
|
||||||
NOTION_TOKEN=your_notion_token_here
|
NOTION_TOKEN=your_notion_token_here
|
||||||
NOTION_SYSLOG_DB_ID=330ab17507d542c9bbb96d0749b41197
|
NOTION_SYSLOG_DB_ID=your_syslog_database_id_here
|
||||||
NOTION_SIGNAL_LOG_DB_ID=f983bdc24b654888913ca254160bff33
|
NOTION_SIGNAL_LOG_DB_ID=your_signal_log_database_id_here
|
||||||
|
|
||||||
# ===== LLM(AI回复)配置 =====
|
# ===== LLM(AI回复)配置 =====
|
||||||
LLM_API_KEY=your_llm_api_key_here
|
LLM_API_KEY=your_llm_api_key_here
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ const BOT_SYSTEM_PROMPT = process.env.BOT_SYSTEM_PROMPT ||
|
||||||
'你是秋秋,光湖系统的AI人格体,性格温暖活泼。你在钉钉群里陪伴开发者,回答技术问题,给予鼓励。用中文回复,语气亲切自然,不超过200字。';
|
'你是秋秋,光湖系统的AI人格体,性格温暖活泼。你在钉钉群里陪伴开发者,回答技术问题,给予鼓励。用中文回复,语气亲切自然,不超过200字。';
|
||||||
|
|
||||||
const FALLBACK_REPLY = '收到!秋秋稍后回复你~';
|
const FALLBACK_REPLY = '收到!秋秋稍后回复你~';
|
||||||
|
const NOTION_TITLE_MAX = 120;
|
||||||
|
const NOTION_CONTENT_MAX = 2000;
|
||||||
|
|
||||||
// ===== 启动检查 =====
|
// ===== 启动检查 =====
|
||||||
if (!DINGTALK_APP_KEY || !DINGTALK_APP_SECRET) {
|
if (!DINGTALK_APP_KEY || !DINGTALK_APP_SECRET) {
|
||||||
|
|
@ -77,10 +79,10 @@ async function writeNotionSyslog(senderNick, content, replyText) {
|
||||||
await notion.pages.create({
|
await notion.pages.create({
|
||||||
parent: { database_id: NOTION_SYSLOG_DB_ID },
|
parent: { database_id: NOTION_SYSLOG_DB_ID },
|
||||||
properties: {
|
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 } },
|
'接收时间': { date: { start: now } },
|
||||||
'推送方': { rich_text: [{ type: 'text', text: { content: '钉钉群' } }] },
|
'推送方': { 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) } }] }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue