| 352 | |
| 353 | const media = message.media; |
| 354 | |
| 355 | if (media.className === "MessageMediaPhoto") { |
| 356 | return MEDIA_TYPES.PHOTO + " " + mediaCaption; |
| 357 | } else if (media.className === "MessageMediaDocument") { |
| 358 | const doc = media.document; |
| 359 | const attributes = doc.attributes || []; |
| 360 | |
| 361 | const isVideo = attributes.some((attr: any) => attr.className === "DocumentAttributeVideo"); |
| 362 | const isVoice = attributes.some((attr: any) => attr.className === "DocumentAttributeAudio" && attr.voice); |
| 363 | const isAudio = attributes.some((attr: any) => attr.className === "DocumentAttributeAudio"); |
| 364 | const isSticker = attributes.some((attr: any) => attr.className === "DocumentAttributeSticker"); |
| 365 | const isAnimation = attributes.some((attr: any) => attr.className === "DocumentAttributeAnimated"); |
| 366 | |
| 367 | if (isSticker) return MEDIA_TYPES.STICKER + " " + mediaCaption; |
| 368 | if (isAnimation) return MEDIA_TYPES.ANIMATION + " " + mediaCaption; |
| 369 | if (isVideo) return MEDIA_TYPES.VIDEO + " " + mediaCaption; |
| 370 | if (isVoice) return MEDIA_TYPES.VOICE + " " + mediaCaption; |
| 371 | if (isAudio) return MEDIA_TYPES.AUDIO + " " + mediaCaption; |
| 372 | return MEDIA_TYPES.DOCUMENT + " " + mediaCaption; |
| 373 | } else if (media.className === "MessageMediaContact") { |
| 374 | return MEDIA_TYPES.CONTACT + " " + mediaCaption; |
| 375 | } else if (media.className === "MessageMediaGeo" || media.className === "MessageMediaVenue") { |
| 376 | return MEDIA_TYPES.LOCATION + " " + mediaCaption; |
| 377 | } else if (media.className === "MessageMediaPoll") { |
| 378 | return MEDIA_TYPES.POLL + " " + mediaCaption; |
| 379 | } else if (media.className === "MessageMediaWebPage") { |
| 380 | return MEDIA_TYPES.WEB_PAGE + " " + mediaCaption; |
| 381 | } else if (media.className === "MessageMediaDice") { |
| 382 | return MEDIA_TYPES.DICE + " " + mediaCaption; |
| 383 | } else if (media.className === "MessageMediaGame") { |
| 384 | return MEDIA_TYPES.GAME + " " + mediaCaption; |
| 385 | } |
| 386 | |
| 387 | return mediaCaption; |
| 388 | } |
| 389 | |
| 390 | // 解析实体参数 |
| 391 | private parseEntity(argStr: string): string | number { |
| 392 | // 尝试解析为数字ID |
| 393 | const num = parseInt(argStr); |
| 394 | if (!isNaN(num)) { |
| 395 | return num; |
| 396 | } |
| 397 | // 否则作为用户名返回 |