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

Method handle

gif/gif.ts:71–111  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

69 }
70 }
71
72 public async handle(msg: Api.Message) {
73 const args = msg.message.substring(4).trim().toLowerCase();
74
75 // 检查是否有帮助参数
76 if (args === "help" || args === "h") {
77 await this.showHelp(msg);
78 return;
79 }
80
81 // 检查是否有清理参数
82 if (args === "clear" || args === "c") {
83 await this.clearTempFiles(msg);
84 return;
85 }
86
87 // 获取回复的消息
88 const repliedMsg = await safeGetReplyMessage(msg);
89 if (!repliedMsg) {
90 await msg.edit({
91 text: "❌ 请回复一个包含 GIF 或视频的消息后使用此命令。\n\n💡 请回复 GIF 或视频后再试。"
92 });
93 return;
94 }
95
96 // 检查消息类型
97 if (!this.isValidMedia(repliedMsg)) {
98 await msg.edit({
99 text: "❌ 回复的消息不包含 GIF 或视频文件。\n\n支持的格式:GIF、MP4、AVI、MOV、WEBM 等视频格式。"
100 });
101 return;
102 }
103
104 try {
105 await this.convertToSticker(msg, repliedMsg);
106 } catch (error: any) {
107 console.error("GIF转贴纸失败:", error);
108 await msg.edit({
109 text: `❌ 转换失败:${error.message}\n\n💡 请检查支持的格式和限制。`
110 });
111 }
112 }
113
114 private async showHelp(msg: Api.Message) {

Callers 1

gifFunction · 0.95

Calls 6

showHelpMethod · 0.95
clearTempFilesMethod · 0.95
isValidMediaMethod · 0.95
convertToStickerMethod · 0.95
errorMethod · 0.80
editMethod · 0.45

Tested by

no test coverage detected