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

Class TelegraphFeature

ai/ai.ts:4194–4321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4192
4193class TelegraphFeature extends BaseFeatureHandler {
4194 readonly name = "Telegraph 管理";
4195 readonly command = "telegraph";
4196 readonly description = "管理 Telegraph";
4197
4198 constructor(configManagerPromise: Promise<ConfigManager>) {
4199 super(configManagerPromise);
4200 }
4201
4202 async execute(
4203 msg: Api.Message,
4204 args: string[],
4205 _prefixes: string[],
4206 ): Promise<void> {
4207 const configManager = await this.getConfigManager();
4208 const config = configManager.getConfig();
4209
4210 if (args.length < 2) {
4211 await this.showTelegraphStatus(msg, config);
4212 return;
4213 }
4214
4215 const action = args[1].toLowerCase();
4216 if (action === "on") {
4217 await this.enableTelegraph(msg, configManager);
4218 return;
4219 }
4220 if (action === "off") {
4221 await this.disableTelegraph(msg, configManager);
4222 return;
4223 }
4224 if (action === "limit") {
4225 requireUser(args.length >= 3, "参数格式错误");
4226 await this.setTelegraphLimit(msg, args, configManager);
4227 return;
4228 }
4229 if (action === "del") {
4230 requireUser(args.length >= 3, "参数格式错误");
4231 await this.deleteTelegraphItem(msg, args, configManager);
4232 return;
4233 }
4234 await this.showTelegraphStatus(msg, config);
4235 }
4236
4237 private async showTelegraphStatus(
4238 msg: Api.Message,
4239 config: DB,
4240 ): Promise<void> {
4241 let status =
4242 `📰 <b>Telegraph 状态:</b>\n\n` +
4243 `🌐 当前状态: ${config.telegraph.enabled ? "开启" : "关闭"}\n` +
4244 `📊 限制数量: <code>${config.telegraph.limit}</code>\n` +
4245 `📈 记录数量: <code>${config.telegraph.list.length}/${config.telegraph.limit}</code>`;
4246
4247 if (config.telegraph.list.length > 0) {
4248 status += "\n\n";
4249 config.telegraph.list.forEach((item, index) => {
4250 status += `${index + 1}. <a href="${item.url}">🔗 ${item.title}</a>\n`;
4251 });

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected