mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Merge pull request #26 from Mr-Andersen/dev
+Message::text(&self); message_kind->kind; IncomingMessage->CommonMes…
This commit is contained in:
commit
84548b0727
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