pub struct Message {
pub id: Uuid,
pub conversation_id: String,
pub user_id: String,
pub message_type: MessageType,
pub content: String,
pub attachments: Vec<Attachment>,
pub metadata: HashMap<String, Value>,
pub timestamp: DateTime<Utc>,
pub parent_id: Option<Uuid>,
pub flags: MessageFlags,
}Expand description
A message sent to the bot
Fields§
§id: UuidUnique message ID
conversation_id: StringConversation ID for context tracking
user_id: StringUser ID who sent the message
message_type: MessageTypeMessage type
content: StringMessage content
attachments: Vec<Attachment>Optional attachments
metadata: HashMap<String, Value>Message metadata
timestamp: DateTime<Utc>Timestamp when the message was created
parent_id: Option<Uuid>Optional parent message ID for threading
flags: MessageFlagsMessage flags
Implementations§
Source§impl Message
impl Message
Sourcepub fn text(content: impl Into<String>) -> Self
pub fn text(content: impl Into<String>) -> Self
Create a new text message
§Example
use universal_bot_core::Message;
let message = Message::text("Hello, bot!");
assert_eq!(message.content, "Hello, bot!");Sourcepub fn with_type(content: impl Into<String>, message_type: MessageType) -> Self
pub fn with_type(content: impl Into<String>, message_type: MessageType) -> Self
Create a new message with a specific type
Sourcepub fn with_conversation_id(self, id: impl Into<String>) -> Self
pub fn with_conversation_id(self, id: impl Into<String>) -> Self
Set the conversation ID
Sourcepub fn with_user_id(self, id: impl Into<String>) -> Self
pub fn with_user_id(self, id: impl Into<String>) -> Self
Set the user ID
Sourcepub fn with_attachment(self, attachment: Attachment) -> Self
pub fn with_attachment(self, attachment: Attachment) -> Self
Add an attachment
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
Add metadata
Sourcepub fn with_parent(self, parent_id: Uuid) -> Self
pub fn with_parent(self, parent_id: Uuid) -> Self
Set the parent message ID for threading
Sourcepub fn with_flags(self, flags: MessageFlags) -> Self
pub fn with_flags(self, flags: MessageFlags) -> Self
Set message flags
Sourcepub fn has_attachments(&self) -> bool
pub fn has_attachments(&self) -> bool
Check if this message has attachments
Sourcepub fn attachment_size(&self) -> usize
pub fn attachment_size(&self) -> usize
Get the total size of attachments in bytes
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'v_a> ValidateArgs<'v_a> for Message
impl<'v_a> ValidateArgs<'v_a> for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more