feature: variants #22

Merged
akulij merged 19 commits from dev into main 2025-06-05 20:53:03 +00:00
Showing only changes of commit c301b72f0c - Show all commits

View File

@ -501,10 +501,32 @@ pub struct BotMessage {
/// flag options to command is meta, so it will be appended to user.metas in db
meta: Option<bool>,
variants: Vec<MessageVariant>,
handler: Option<BotFunction>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MessageVariant(String);
impl MessageVariant {
pub fn get_name(&self) -> &str {
&self.0
}
}
impl PartialEq<String> for &MessageVariant {
fn eq(&self, other: &String) -> bool {
self.0 == *other
}
}
impl PartialEq<&str> for &MessageVariant {
fn eq(&self, other: &&str) -> bool {
self.0 == *other
}
}
impl BotMessage {
pub fn fill_literal(self, l: String) -> Self {
BotMessage {
@ -542,6 +564,10 @@ impl BotMessage {
pub fn meta(&self) -> bool {
self.meta.unwrap_or(false)
}
pub fn variants(&self) -> &[MessageVariant] {
&self.variants
}
}
impl BotMessage {