🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🌐 chore: translate non-English comments to English in bot/ackPhrases (#12606)
LobeHub Botf234397bf892
diff --git a/src/server/services/bot/ackPhrases/index.ts b/src/server/services/bot/ackPhrases/index.tsindex d758dfa8b42..0f9917dbcc7 100644--- a/src/server/services/bot/ackPhrases/index.ts+++ b/src/server/services/bot/ackPhrases/index.ts@@ -8,17 +8,17 @@ function sample<T>(arr: T[]): T | undefined {}// ==========================================-// 3. 智能检测器 (The Brain)+// 3. Smart Detector (The Brain)// ==========================================/**- * 获取指定时区下的当前小时数 (0-23)+ * Get the current hour (0-23) in the specified timezone*/function getLocalHour(date: Date, timeZone?: string): number {if (!timeZone) return date.getHours();try {- // 使用 Intl API 将时间格式化为指定时区的小时数+ // Use the Intl API to format the time as the hour number in the specified timezoneconst formatter = new Intl.DateTimeFormat('en-US', {hour: 'numeric',hour12: false,@@ -26,11 +26,11 @@ function getLocalHour(date: Date, timeZone?: string): number {});const hourStr = formatter.format(date);- // 处理可能的 '24' 这种边缘情况(极少见,但为了稳健)+ // Handle the possible edge case of '24' (extremely rare, but for robustness)const hour = parseInt(hourStr, 10);return hour === 24 ? 0 : hour;} catch (e) {- // 如果时区无效,回退到服务器时间+ // If the timezone is invalid, fall back to server timeconsole.warn(`[getExtremeAck] Invalid timezone: ${timeZone}, falling back to server time.`);return date.getHours();}@@ -48,44 +48,44 @@ function getTimeSegment(hour: number): TimeSegment {function getContextType(content: string): ContextType {const lower = content.toLowerCase();- // 1. 🚨 Urgent (最高优先级)+ // 1. 🚨 Urgent (highest priority)if (/asap|urgent|emergency|!!!|quick|fast|hurry|立刻|马上|紧急/.test(lower)) {return 'urgent';}- // 2. 🐛 Debugging (特征明显)+ // 2. 🐛 Debugging (clear characteristics)if (/error|bug|fix|crash|fail|exception|undefined|null|报错|挂了|修复/.test(lower)) {return 'debugging';}- // 3. 💻 Coding (代码特征)+ // 3. 💻 Coding (code characteristics)if (/const |import |function |=> |class |return |<\/|npm |git |docker|sudo|pip|api|json/.test(lower)) {return 'coding';}- // 4. 👀 Review (请求查看)+ // 4. 👀 Review (request to look at)if (/review|check|look at|opinion|verify|audit|审查|看看|检查/.test(lower)) {return 'review';}- // 5. 📝 Planning (列表/计划)+ // 5. 📝 Planning (lists/plans)if (/plan|todo|list|roadmap|schedule|summary|agenda|计划|安排|总结/.test(lower)) {return 'planning';}- // 6. 📚 Explanation (提问/教学)+ // 6. 📚 Explanation (questions/teaching)if (/what is|how to|explain|guide|tutorial|teach|meaning|什么是|怎么做|解释/.test(lower)) {return 'explanation';}- // 7. 🎨 Creative (创作/设计)+ // 7. 🎨 Creative (creation/design)if (/design|draft|write|idea|brainstorm|generate|create|image|logo|设计|文案|生成/.test(lower)) {return 'creative';}- // 8. 🧠 Analysis (兜底的长思考)+ // 8. 🧠 Analysis (fallback for long thinking)if (content.includes('?') ||content.length > 60 ||@@ -94,22 +94,22 @@ function getContextType(content: string): ContextType {return 'analysis';}- // 9. 💬 Casual (短且非指令)+ // 9. 💬 Casual (short and non-instructive)if (/hello|hi|hey|thanks|cool|wow|lol|哈哈|你好|谢谢/.test(lower)) {return 'casual';}- // 10. 👌 Quick (兜底)+ // 10. 👌 Quick (fallback)return 'quick';}function humanizeText(text: string): string {- // 10% 的概率把首字母变成小写(显得随意)+ // 10% chance to lowercase the first letter (looks casual)if (Math.random() < 0.1) {text = text.charAt(0).toLowerCase() + text.slice(1);}- // 10% 的概率去掉末尾标点+ // 10% chance to remove trailing punctuationif (Math.random() < 0.1 && text.endsWith('.')) {text = text.slice(0, -1);}@@ -118,17 +118,17 @@ function humanizeText(text: string): string {}// ==========================================-// 4. 主入口+// 4. Main Entry// ==========================================export interface AckOptions {/**- * 强制指定时间 (用于测试)+ * Force a specific time (for testing)*/date?: Date;/**- * 用户所在的时区 (e.g. 'Asia/Shanghai', 'America/New_York')- * 如果不传,默认使用服务器时间+ * The user's timezone (e.g. 'Asia/Shanghai', 'America/New_York')+ * If not provided, defaults to server time*/timezone?: string;}@@ -136,23 +136,23 @@ export interface AckOptions {export function getExtremeAck(content: string = '', options: AckOptions = {}): string {const now = options.date || new Date();- // 计算用户当地时间的小时数+ // Calculate the hour in the user's local timeconst localHour = getLocalHour(now, options.timezone);const timeSeg = getTimeSegment(localHour);const contextType = getContextType(content);- // 筛选符合当前时间段和上下文的所有规则+ // Filter all rules that match the current time segment and contextconst candidates = VIBE_CORPUS.filter((rule) => {- // 检查时间匹配+ // Check time matchconst timeMatch = rule.time === 'all' || rule.time.includes(timeSeg);- // 检查上下文匹配+ // Check context matchconst contextMatch = rule.context === 'all' || rule.context.includes(contextType);return timeMatch && contextMatch;}).flatMap((rule) => rule.phrases);- // 如果没有匹配到任何规则,使用通用兜底+ // If no rules matched, use the universal fallbackif (candidates.length === 0) {return 'Processing...';}diff --git a/src/server/services/bot/ackPhrases/vibeMatrix.ts b/src/server/services/bot/ackPhrases/vibeMatrix.tsindex ddf3cd4ddbe..8a67fe9f432 100644--- a/src/server/services/bot/ackPhrases/vibeMatrix.ts+++ b/src/server/services/bot/ackPhrases/vibeMatrix.ts@@ -1,20 +1,20 @@// ==========================================-// 1. 定义类型+// 1. Type Definitions// ==========================================export type TimeSegment = 'early' | 'morning' | 'lunch' | 'afternoon' | 'evening' | 'night';export type ContextType =- | 'urgent' // 最高优先级- | 'debugging' // 错误修复- | 'coding' // 代码实现- | 'review' // 审查/检查- | 'planning' // 计划/列表- | 'analysis' // 深度思考- | 'explanation' // 解释/教学- | 'creative' // 创意/生成- | 'casual' // 闲聊- | 'quick'; // 兜底/短语+ | 'urgent' // highest priority+ | 'debugging' // error fixing+ | 'coding' // code implementation+ | 'review' // review/inspection+ | 'planning' // planning/lists+ | 'analysis' // deep thinking+ | 'explanation' // explanation/teaching+ | 'creative' // creativity/generation+ | 'casual' // casual chat+ | 'quick'; // fallback/phrases-// 为了方便配置,定义 'all' 类型+// Define the 'all' type for convenience in configurationexport type TimeRule = TimeSegment[] | 'all';export type ContextRule = ContextType[] | 'all';@@ -25,11 +25,11 @@ export interface VibeRule {}// ==========================================-// 2. 语料规则库 (Rule-Based Corpus)+// 2. Corpus Rule Library (Rule-Based Corpus)// ==========================================export const VIBE_CORPUS: VibeRule[] = [// =================================================================- // 🌍 GLOBAL / UNIVERSAL (通用回复)+ // 🌍 GLOBAL / UNIVERSAL (universal replies)// ================================================================={phrases: [