robotnik/src/plugin.rs

38 lines
982 B
Rust
Raw Normal View History

2025-11-22 12:20:56 +00:00
//! Plugin command definitions.
// Dear future me: If you forget the JSON translations in the future you'll
// thank me for the comment overkill.
use std::fmt::Display;
use serde::{Deserialize, Serialize};
2025-11-22 12:20:56 +00:00
/// Message types accepted from plugins.
#[derive(Debug, Deserialize, Serialize)]
2025-11-22 12:20:56 +00:00
pub enum PluginMsg {
/// Plugin message indicating the bot should send a [`message`] to [`channel`].
/// {
/// "SendMessage": {
/// "channel": "channel_name",
/// "message": "your message here"
/// }
///
/// }
SendMessage {
/// The IRC channel to send the [`message`] to.
channel: String,
/// The [`message`] to send.
message: String,
},
}
2025-11-22 12:20:56 +00:00
impl Display for PluginMsg {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::SendMessage { channel, message } => {
write!(f, "[{channel}]: {message}")
}
}
}
}