From c301b72f0cfa08ffc4b55d77a9fe82b66d0b107e Mon Sep 17 00:00:00 2001 From: Akulij Date: Thu, 5 Jun 2025 22:56:52 +0500 Subject: [PATCH] create MessageVariant --- src/botscript.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/botscript.rs b/src/botscript.rs index 04d3ac5..a1c99e5 100644 --- a/src/botscript.rs +++ b/src/botscript.rs @@ -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, + variants: Vec, handler: Option, } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct MessageVariant(String); + +impl MessageVariant { + pub fn get_name(&self) -> &str { + &self.0 + } +} + +impl PartialEq 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 {