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

Method createStickerSet

sticker/sticker.ts:403–444  ·  view source on GitHub ↗
(
    client: TelegramClient,
    me: Api.User,
    packName: string,
    stickerInfo: { isAnimated: boolean; isVideo: boolean; isStatic: boolean; emoji: string, document: Api.InputDocument }
  )

Source from the content-addressed store, hash-verified

401 // For other errors, we stop
402 throw new StickerError(`检查自动生成的贴纸包时出错: ${htmlEscape(error.message)}`);
403 }
404 }
405
406 throw new StickerError("自动创建贴纸包失败,已尝试超过50个。");
407 }
408
409 private async createStickerSet(
410 client: TelegramClient,
411 me: Api.User,
412 packName: string,
413 stickerInfo: { isAnimated: boolean; isVideo: boolean; isStatic: boolean; emoji: string, document: Api.InputDocument }
414 ): Promise<void> {
415 const username = this.getUsername(me);
416 let title = `${username ? `@${username}` : me.firstName || "我的"} 的收藏`;
417 if (stickerInfo.isAnimated) title += " (动态)";
418 else if (stickerInfo.isVideo) title += " (视频)";
419 else if (stickerInfo.isStatic) title += " (静态)";
420
421 try {
422 await client.invoke(new Api.stickers.CreateStickerSet({
423 userId: "me",
424 title: title,
425 shortName: packName,
426 stickers: [new Api.InputStickerSetItem({
427 document: stickerInfo.document,
428 emoji: stickerInfo.emoji,
429 })],
430 }));
431 } catch (error: any) {
432 let friendlyMessage = `创建贴纸包失败: ${error.message}`;
433 if (error.errorMessage) {
434 switch (error.errorMessage) {
435 case 'STICKER_VIDEO_LONG':
436 friendlyMessage = '视频贴纸时长不能超过3秒。';
437 break;
438 case 'STICKER_PNG_DIMENSIONS':
439 friendlyMessage = '静态贴纸尺寸必须为 512xN 或 Nx512 (一边为512px)。';
440 break;
441 case 'STICKERSET_INVALID':
442 friendlyMessage = '贴纸包名称无效或已被占用 (只能用字母、数字、下划线,且以字母开头)。';
443 break;
444 case 'PEER_ID_INVALID':
445 friendlyMessage = '无法与 @Stickers 机器人通信,请先私聊它一次。';
446 break;
447 }

Callers 1

handleStickerMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected