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

Method handleConfigCommand

im/im.ts:301–456  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

299 description: "图片监控配置:启用、监控群组、默认操作",
300 category: "插件配置",
301 icon: "🖼️",
302 getSchema: (): PanelSettingField[] => [
303 {
304 "key": "enabled",
305 "label": "启用监控",
306 "type": "boolean",
307 "description": "开启图片监控过滤"
308 },
309 {
310 "key": "defaultAction",
311 "label": "默认操作",
312 "type": "select",
313 "options": [
314 {
315 "value": "delete",
316 "label": "删除"
317 },
318 {
319 "value": "ban",
320 "label": "封禁"
321 }
322 ],
323 "description": "违规图片的默认处理方式"
324 }
325],
326 getValues: async (): Promise<Record<string, unknown>> => {
327 const db = await JSONFilePreset<Config>(path.join(createDirectoryInAssets("image_monitor"), "config.json"), DEFAULT_CONFIG);
328 return db.data as Record<string, unknown>;
329 },
330 setValues: async (patch: Record<string, unknown>): Promise<void> => {
331 const db = await JSONFilePreset<Config>(path.join(createDirectoryInAssets("image_monitor"), "config.json"), DEFAULT_CONFIG);
332 Object.assign(db.data, patch);
333 await db.write();
334 },
335 };
336 };
337
338 // 不忽略编辑消息
339 ignoreEdited = false
340
341 private async handleConfigCommand(msg: Api.Message): Promise<void> {
342 const client = await getGlobalClient();
343 if (!client) return;
344
345 const args = msg.text?.split(" ").slice(1) || [];
346 const subCommand = args[0]?.toLowerCase();
347 const config = await ConfigManager.getConfig();
348
349 try {
350 switch (subCommand) {
351 case "on":
352 config.enabled = true;
353 await ConfigManager.saveConfig();
354 await MessageManager.edit(msg, "✅ 图片监控已启用。");
355 break;
356 case "off":
357 config.enabled = false;
358 await ConfigManager.saveConfig();

Callers

nothing calls this directly

Calls 6

getPeerIdFunction · 0.85
errorMethod · 0.80
htmlEscapeFunction · 0.70
getConfigMethod · 0.45
saveConfigMethod · 0.45
editMethod · 0.45

Tested by

no test coverage detected