feature: variants #22
@ -501,10 +501,32 @@ pub struct BotMessage {
|
|||||||
|
|
||||||
/// flag options to command is meta, so it will be appended to user.metas in db
|
/// flag options to command is meta, so it will be appended to user.metas in db
|
||||||
meta: Option<bool>,
|
meta: Option<bool>,
|
||||||
|
variants: Vec<MessageVariant>,
|
||||||
|
|
||||||
handler: Option<BotFunction>,
|
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 {
|
impl BotMessage {
|
||||||
pub fn fill_literal(self, l: String) -> Self {
|
pub fn fill_literal(self, l: String) -> Self {
|
||||||
BotMessage {
|
BotMessage {
|
||||||
@ -542,6 +564,10 @@ impl BotMessage {
|
|||||||
pub fn meta(&self) -> bool {
|
pub fn meta(&self) -> bool {
|
||||||
self.meta.unwrap_or(false)
|
self.meta.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn variants(&self) -> &[MessageVariant] {
|
||||||
|
&self.variants
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BotMessage {
|
impl BotMessage {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user