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

Method handleConfiguration

sticker/sticker.ts:292–337  ·  view source on GitHub ↗
(msg: Api.Message, args: string[], client: TelegramClient)

Source from the content-addressed store, hash-verified

290 if (args[0]?.toLowerCase() === "help") {
291 await msg.edit({ text: help_text, parseMode: "html", linkPreview: false });
292 return;
293 }
294
295 if (args.length === 0) { // Show current config
296 const defaultPack = await ConfigManager.get(CONFIG_KEYS.DEFAULT_PACK);
297 let text = "⚙️ <b>贴纸收藏插件设置</b>\n\n";
298 if (defaultPack) {
299 text += `当前默认贴纸包: <a href="https://t.me/addstickers/${htmlEscape(defaultPack)}">${htmlEscape(defaultPack)}</a>`;
300 } else {
301 const me = await safeGetMe(client);
302 if (!me) return;
303 if (me instanceof Api.User && me.username) {
304 text += `未设置默认贴纸包,将自动使用 <code>${htmlEscape(me.username)}_...</code> 系列包。`;
305 } else {
306 text += `未设置默认贴纸包,且您没有用户名,收藏前必须先设置一个默认包。`;
307 }
308 }
309 await msg.edit({ text, parseMode: "html", linkPreview: false });
310 return;
311 }
312
313 if (args.length === 1) {
314 if (args[0].toLowerCase() === "cancel") {
315 await ConfigManager.remove(CONFIG_KEYS.DEFAULT_PACK);
316 await msg.edit({ text: "✅ <b>已取消默认贴纸包。</b>", parseMode: "html" });
317 } else { // Set new default pack
318 const packName = args[0];
319 await msg.edit({ text: `🤔 <b>正在验证贴纸包</b> <code>${htmlEscape(packName)}</code>...`, parseMode: "html" });
320 try {
321 await client.invoke(new Api.messages.GetStickerSet({
322 stickerset: new Api.InputStickerSetShortName({ shortName: packName }),
323 hash: 0,
324 }));
325 await ConfigManager.set(CONFIG_KEYS.DEFAULT_PACK, packName);
326 await msg.edit({ text: `✅ <b>默认贴纸包已设置为:</b> <code>${htmlEscape(packName)}</code>`, parseMode: "html" });
327 } catch (error) {
328 throw new StickerError(`无法访问贴纸包 <code>${htmlEscape(packName)}</code>。请确保它存在且您有权访问。`);
329 }
330 }
331 } else {
332 throw new StickerError("参数错误。");
333 }
334 }
335
336 private async findOrCreatePack(
337 client: TelegramClient,
338 packName: string,
339 username: string,
340 stickerInfo: { isAnimated: boolean; isVideo: boolean; isStatic: boolean }

Callers 1

handleStickerMethod · 0.95

Calls 5

htmlEscapeFunction · 0.70
editMethod · 0.45
getMethod · 0.45
removeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected