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

Class ShiftPlugin

shift/shift.ts:1244–2097  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1242 }
1243 lowdb = null;
1244 }
1245
1246 description: string = `智能转发助手 - 自动转发消息到指定目标\n\n${help_text}`;
1247 cmdHandlers: Record<string, (msg: Api.Message) => Promise<void>> = {
1248 shift: async (msg) => {
1249 const client = await getGlobalClient();
1250 if (!client) {
1251 await msg.edit({
1252 text: "❌ <b>客户端未初始化</b>",
1253 parseMode: "html",
1254 });
1255 return;
1256 }
1257
1258 // 标准参数解析模式
1259 const lines = msg.message?.trim()?.split(/\r?\n/g) || [];
1260 const parts = lines?.[0]?.split(/\s+/) || [];
1261 const [, ...args] = parts; // 跳过命令本身
1262 const sub = (args[0] || "").toLowerCase();
1263
1264 // 无参数时显示帮助
1265 if (!sub) {
1266 await msg.edit({
1267 text: HELP_TEXT,
1268 parseMode: "html",
1269 linkPreview: false,
1270 });
1271 return;
1272 }
1273
1274 // 处理 help 命令
1275 if (sub === "help" || sub === "h") {
1276 await msg.edit({
1277 text: HELP_TEXT,
1278 parseMode: "html",
1279 linkPreview: false,
1280 });
1281 return;
1282 }
1283
1284 try {
1285 // Migrate command - 迁移到 lowdb
1286 if (sub === "migrate") {
1287 if (await migrateToLowdb()) {
1288 await msg.edit({
1289 text: `✅ <b>成功迁移到 lowdb 数据库</b>\n\n性能提升,功能增强!`,
1290 parseMode: "html",
1291 });
1292 } else {
1293 await msg.edit({
1294 text: `❌ <b>迁移失败或无需迁移</b>`,
1295 parseMode: "html",
1296 });
1297 }
1298 return;
1299 }
1300
1301 // Export command - 导出规则

Callers

nothing calls this directly

Calls 15

migrateToLowdbFunction · 0.85
exportRulesFunction · 0.85
importRulesFunction · 0.85
resolveTargetFunction · 0.85
normalizeChatIdFunction · 0.85
isCircularForwardFunction · 0.85
saveShiftRuleFunction · 0.85
getAllShiftRulesFunction · 0.85
parseIndicesFunction · 0.85
deleteShiftRuleFunction · 0.85
writeMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected