walrus_channel/message.rs
1//! Channel message types.
2
3use compact_str::CompactString;
4
5/// A message received from or sent to a channel.
6#[derive(Debug, Clone)]
7pub struct ChannelMessage {
8 /// Platform chat/channel ID.
9 pub chat_id: i64,
10 /// Platform sender user ID.
11 pub sender_id: i64,
12 /// Display name of the sender.
13 pub sender_name: CompactString,
14 /// Whether the sender is a bot.
15 pub is_bot: bool,
16 /// Whether this message is from a group chat (vs DM).
17 pub is_group: bool,
18 /// Message text content.
19 pub content: String,
20 /// Attached files or media.
21 pub attachments: Vec<Attachment>,
22 /// Message ID being replied to, if any.
23 pub reply_to: Option<i32>,
24 /// Unix timestamp when the message was created.
25 pub timestamp: u64,
26}
27
28/// A file or media attachment.
29#[derive(Debug, Clone)]
30pub struct Attachment {
31 /// Type of attachment.
32 pub kind: AttachmentKind,
33 /// URL or path to the attachment.
34 pub url: String,
35 /// Optional human-readable name.
36 pub name: Option<String>,
37}
38
39/// Type of attachment content.
40#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub enum AttachmentKind {
42 /// Image file (PNG, JPG, etc.).
43 Image,
44 /// Generic file.
45 File,
46 /// Audio file.
47 Audio,
48 /// Video file.
49 Video,
50}
51
52impl From<ChannelMessage> for wcore::model::Message {
53 fn from(msg: ChannelMessage) -> Self {
54 wcore::model::Message::user(msg.content)
55 }
56}