MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / translateToChinese

Function translateToChinese

service/service.ts:164–204  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

162 if (line.includes("Started:") || line.includes("启动时间:")) {
163 // 提取时间部分并格式化
164 const timeMatch = line.match(/(启动时间:|Started:)\s*(.+)/);
165 if (timeMatch) {
166 const [, , timePart] = timeMatch;
167 const formattedTime = formatChineseTime(timePart);
168 translatedLine = `启动时间: ${formattedTime}`;
169 }
170 }
171
172 // 应用其他翻译映射
173 for (const [english, chinese] of Object.entries(STATUS_TRANSLATIONS)) {
174 translatedLine = translatedLine.replace(english, chinese);
175 }
176
177 // 特殊处理时间单位
178 translatedLine = translatedLine.replace(/(\d+)h/g, "$1小时");
179 translatedLine = translatedLine.replace(/(\d+)min/g, "$1分钟");
180 translatedLine = translatedLine.replace(/(\d+)s\b/g, "$1秒");
181 translatedLine = translatedLine.replace(/(\d+\.\d+)s\b/g, "$1秒");
182
183 // 内存单位翻译
184 translatedLine = translatedLine.replace(/(\d+\.\d+)M\b/g, "$1MB");
185 translatedLine = translatedLine.replace(/(\d+\.\d+)G\b/g, "$1GB");
186 translatedLine = translatedLine.replace(/(\d+)M\b/g, "$1MB");
187 translatedLine = translatedLine.replace(/(\d+)G\b/g, "$1GB");
188
189 translatedLines.push(translatedLine);
190 }
191
192 return translatedLines.join("\n");
193}
194
195// 获取机器人运行时间
196function getBotUptime(): string {
197 const uptime = process.uptime();
198 const days = Math.floor(uptime / 86400);
199 const hours = Math.floor((uptime % 86400) / 3600);
200 const minutes = Math.floor((uptime % 3600) / 60);
201 const seconds = Math.floor(uptime % 60);
202
203 const parts: string[] = [];
204 if (days > 0) parts.push(`${days}天`);
205 if (hours > 0) parts.push(`${hours}小时`);
206 if (minutes > 0) parts.push(`${minutes}分钟`);
207 if (seconds > 0) parts.push(`${seconds}秒`);

Callers 1

handleServiceRequestFunction · 0.85

Calls 1

formatChineseTimeFunction · 0.85

Tested by

no test coverage detected