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

Method tryHandleMediaTransform

rev/rev.ts:187–235  ·  view source on GitHub ↗
(
		msg: Api.Message,
		replyMsg: Api.Message,
		flipMode: FlipMode,
		invertColors: boolean,
		captionText?: string,
		captionEntities: any[] = []
	)

Source from the content-addressed store, hash-verified

185 }
186
187 // ==================== 媒体处理 ====================
188
189 private async tryHandleMediaTransform(
190 msg: Api.Message,
191 replyMsg: Api.Message,
192 flipMode: FlipMode,
193 invertColors: boolean,
194 captionText?: string,
195 captionEntities: any[] = []
196 ): Promise<boolean> {
197 const media = replyMsg.media;
198 if (!this.isSupportedMedia(media)) {
199 return false;
200 }
201
202 const client = msg.client;
203 if (!client) {
204 throw new Error('Telegram 客户端未就绪,无法处理媒体');
205 }
206
207 await this.safeEditMessage(msg, '🔄 正在处理媒体,请稍候...');
208
209 const { inputPath, outputPath, isGif, isWebm, isWebp } =
210 this.prepareMediaPaths(media);
211
212 try {
213 await this.downloadMedia(client, replyMsg, inputPath);
214 await this.transformMedia(
215 inputPath,
216 outputPath,
217 flipMode,
218 invertColors,
219 isGif,
220 isWebm
221 );
222 await this.sendTransformedMedia(
223 client,
224 msg,
225 replyMsg,
226 outputPath,
227 isWebm,
228 isWebp,
229 captionText,
230 captionEntities
231 );
232 await this.cleanupMessage(msg);
233 return true;
234 } finally {
235 this.cleanupFiles([inputPath, outputPath]);
236 }
237 }
238

Callers 1

handleReplyMessageMethod · 0.95

Calls 8

isSupportedMediaMethod · 0.95
safeEditMessageMethod · 0.95
prepareMediaPathsMethod · 0.95
downloadMediaMethod · 0.95
transformMediaMethod · 0.95
sendTransformedMediaMethod · 0.95
cleanupMessageMethod · 0.95
cleanupFilesMethod · 0.95

Tested by

no test coverage detected