From f39be996442a745033f0f43be8ae2b775c475663 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Thu, 30 Jul 2020 11:18:23 +0600 Subject: [PATCH 1/2] Add via_bot to Message --- src/types/message.rs | 10 +++++++++- src/types/message_entity.rs | 1 + src/types/update.rs | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/types/message.rs b/src/types/message.rs index 1ef77430..6404ebad 100644 --- a/src/types/message.rs +++ b/src/types/message.rs @@ -25,13 +25,16 @@ pub struct Message { /// Conversation the message belongs to. pub chat: Chat, + /// Bot through which the message was sent. + pub via_bot: Option, + #[serde(flatten)] pub kind: MessageKind, } impl Message { pub fn new(id: i32, date: i32, chat: Chat, kind: MessageKind) -> Self { - Self { id, date, chat, kind } + Self { id, date, chat, kind, via_bot: None } } pub fn id(mut self, val: i32) -> Self { @@ -53,6 +56,11 @@ impl Message { self.kind = val; self } + + pub fn via_bot(mut self, val: User) -> Self { + self.via_bot = Some(val); + self + } } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/src/types/message_entity.rs b/src/types/message_entity.rs index 1a4df44f..c39459be 100644 --- a/src/types/message_entity.rs +++ b/src/types/message_entity.rs @@ -123,6 +123,7 @@ mod tests { fn message() -> Message { Message { + via_bot: None, id: 0, date: 0, chat: Chat { diff --git a/src/types/update.rs b/src/types/update.rs index 28d052ef..6b047dcf 100644 --- a/src/types/update.rs +++ b/src/types/update.rs @@ -179,6 +179,7 @@ mod test { let expected = Update { id: 892_252_934, kind: UpdateKind::Message(Message { + via_bot: None, id: 6557, date: 1_569_518_342, chat: Chat { From bb5899d6d286b46645b922e902a1eaee1fd222f7 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Thu, 30 Jul 2020 11:19:41 +0600 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa0176be..938beffc 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ - + A full-featured framework that empowers you to easily build [Telegram bots](https://telegram.org/blog/bot-revolution) using the [`async`/`.await`](https://rust-lang.github.io/async-book/01_getting_started/01_chapter.html) syntax in [Rust](https://www.rust-lang.org/). It handles all the difficult stuff so you can focus only on your business logic.