mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
- Add Rust orchestrator with async bootstrap pattern - Implement CLI with clap (start, stats, health subcommands) - Add protocol stubs (LSP, MCP, ACP, ABP) - Python bindings via pyo3 (_core module) - Use maturin as build backend - Add tombi.toml for schema config
45 lines
1.0 KiB
Rust
45 lines
1.0 KiB
Rust
//! Message types for AstrBot Core
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct Message {
|
|
pub id: String,
|
|
pub content: String,
|
|
pub sender: String,
|
|
pub timestamp: f64,
|
|
pub message_type: MessageType,
|
|
pub metadata: Option<serde_json::Value>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Default)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum MessageType {
|
|
#[default]
|
|
Text,
|
|
Image,
|
|
Audio,
|
|
Video,
|
|
File,
|
|
System,
|
|
Unknown,
|
|
}
|
|
|
|
impl Message {
|
|
#[must_use]
|
|
pub fn new(id: String, content: String, sender: String) -> Self {
|
|
Self {
|
|
id,
|
|
content,
|
|
sender,
|
|
timestamp: std::time::SystemTime::now()
|
|
.duration_since(std::time::UNIX_EPOCH)
|
|
.map(|d| d.as_secs_f64())
|
|
.unwrap_or_default(),
|
|
message_type: MessageType::Text,
|
|
metadata: None,
|
|
}
|
|
}
|
|
}
|