MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / detectMessageType

Function detectMessageType

packages/parser/src/formats/utils/telegram-utils.ts:96–117  ·  view source on GitHub ↗
(msg: TelegramMessage)

Source from the content-addressed store, hash-verified

94 * 检测消息类型
95 */
96export function detectMessageType(msg: TelegramMessage): MessageType {
97 // Service 消息 → 系统消息
98 if (msg.type === 'service') return MessageType.SYSTEM
99
100 // 贴纸
101 if (msg.media_type === 'sticker') return MessageType.IMAGE
102 // 图片
103 if (msg.photo) return MessageType.IMAGE
104 // 动画 (GIF)
105 if (msg.media_type === 'animation') return MessageType.IMAGE
106 // 视频
107 if (msg.media_type === 'video_file') return MessageType.VIDEO
108 // 语音
109 if (msg.media_type === 'voice_message') return MessageType.VOICE
110 // 视频留言
111 if (msg.media_type === 'video_message') return MessageType.VIDEO
112 // 文件
113 if (msg.file && !msg.media_type) return MessageType.FILE
114
115 // 默认文本
116 return MessageType.TEXT
117}
118
119/**
120 * 构建消息内容

Callers 2

parseTelegramSingleFunction · 0.90
parseTelegramFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected