mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
Add ReactionType
struct
This commit is contained in:
parent
cfa67610f6
commit
77882d97f7
2 changed files with 54 additions and 0 deletions
|
@ -103,6 +103,7 @@ pub use poll_answer::*;
|
|||
pub use poll_type::*;
|
||||
pub use pre_checkout_query::*;
|
||||
pub use proximity_alert_triggered::*;
|
||||
pub use reaction_type::*;
|
||||
pub use reply_keyboard_markup::*;
|
||||
pub use reply_keyboard_remove::*;
|
||||
pub use reply_markup::*;
|
||||
|
@ -215,6 +216,7 @@ mod poll_answer;
|
|||
mod poll_type;
|
||||
mod pre_checkout_query;
|
||||
mod proximity_alert_triggered;
|
||||
mod reaction_type;
|
||||
mod reply_keyboard_markup;
|
||||
mod reply_keyboard_remove;
|
||||
mod reply_markup;
|
||||
|
|
52
crates/teloxide-core/src/types/reaction_type.rs
Normal file
52
crates/teloxide-core/src/types/reaction_type.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The reaction type is based on an emoji.
|
||||
#[serde_with::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ReactionType {
|
||||
/// Kind of this reaction type - emoji or custom emoji.
|
||||
#[serde(flatten)]
|
||||
pub kind: ReactionTypeKind,
|
||||
}
|
||||
|
||||
/// Kind of a [`ReactionType`] - emoji or custom emoji.
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ReactionTypeKind {
|
||||
/// "emoji" or "custom_emoji" reaction
|
||||
Emoji {
|
||||
/// Reaction emoji. Currently, it can be one of "👍", "👎", "❤", "🔥",
|
||||
/// "🥰", "👏", "😁", "🤔", "🤯", "😱", "🤬", "😢", "🎉", "🤩",
|
||||
/// "🤮", "💩", "🙏", "👌", "🕊", "🤡", "🥱", "🥴", "😍", "🐳",
|
||||
/// "❤🔥", "🌚", "🌭", "💯", "🤣", "⚡", "🍌", "🏆", "💔", "🤨",
|
||||
/// "😐", "🍓", "🍾", "💋", "🖕", "😈", "😴", "😭", "🤓", "👻",
|
||||
/// "👨💻", "👀", "🎃", "🙈", "😇", "😨", "🤝", "✍", "🤗", "🫡",
|
||||
/// "🎅", "🎄", "☃", "💅", "🤪", "🗿", "🆒", "💘", "🙉", "🦄", "😘",
|
||||
/// "💊", "🙊", "😎", "👾", "🤷♂", "🤷", "🤷♀", "😡"
|
||||
emoji: String,
|
||||
},
|
||||
/// Custom emoji sticker.
|
||||
CustomEmoji {
|
||||
/// Custom emoji identifier.
|
||||
custom_emoji_id: String,
|
||||
},
|
||||
}
|
||||
|
||||
impl ReactionType {
|
||||
#[must_use]
|
||||
pub fn emoji(&self) -> Option<&String> {
|
||||
match &self.kind {
|
||||
ReactionTypeKind::Emoji { emoji } => Some(emoji),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn custom_emoji_id(&self) -> Option<&String> {
|
||||
match &self.kind {
|
||||
ReactionTypeKind::CustomEmoji { custom_emoji_id } => Some(custom_emoji_id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue