mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
+Message::text(&self); message_kind->kind; IncomingMessage->CommonMessage
This commit is contained in:
parent
ced6bd8e69
commit
ccbfee24b8
1 changed files with 15 additions and 2 deletions
|
@ -11,13 +11,26 @@ pub struct Message {
|
|||
pub date: i32,
|
||||
pub chat: Chat,
|
||||
#[serde(flatten)]
|
||||
pub message_kind: MessageKind,
|
||||
pub kind: MessageKind,
|
||||
}
|
||||
|
||||
impl Message {
|
||||
fn text(&self) -> Option<&str> {
|
||||
if let MessageKind::CommonMessage {
|
||||
media_kind: MediaKind::Text {
|
||||
ref text, ..
|
||||
}, .. } = self.kind {
|
||||
Some(text)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Clone)]
|
||||
#[serde(untagged)]
|
||||
pub enum MessageKind {
|
||||
IncomingMessage {
|
||||
CommonMessage {
|
||||
#[serde(flatten)]
|
||||
from: Sender,
|
||||
#[serde(flatten)]
|
||||
|
|
Loading…
Reference in a new issue