| 256 | if ( |
| 257 | attributes.some((attr: any) => attr instanceof Api.DocumentAttributeSticker) |
| 258 | ) { |
| 259 | return "[贴纸]"; |
| 260 | } |
| 261 | if ( |
| 262 | attributes.some( |
| 263 | (attr: any) => |
| 264 | attr instanceof Api.DocumentAttributeAudio && Boolean(attr.voice), |
| 265 | ) |
| 266 | ) { |
| 267 | return "[语音]"; |
| 268 | } |
| 269 | if ( |
| 270 | attributes.some((attr: any) => attr instanceof Api.DocumentAttributeAudio) |
| 271 | ) { |
| 272 | return "[音频]"; |
| 273 | } |
| 274 | if ( |
| 275 | attributes.some((attr: any) => attr instanceof Api.DocumentAttributeVideo) |
| 276 | ) { |
| 277 | return "[视频]"; |
| 278 | } |
| 279 | if ( |
| 280 | attributes.some( |
| 281 | (attr: any) => attr instanceof Api.DocumentAttributeAnimated, |
| 282 | ) |
| 283 | ) { |
| 284 | return "[动图]"; |
| 285 | } |
| 286 | return "[文档]"; |
| 287 | } |
| 288 | |
| 289 | function buildMessageText(message: any): string { |
| 290 | const rawText = String(message?.message || message?.text || "").trim(); |
| 291 | |
| 292 | if (message?.className === "MessageService") { |
| 293 | return rawText || describeServiceMessage(message); |
| 294 | } |
| 295 | |
| 296 | let placeholder = ""; |
| 297 | if (message?.photo) { |