Merge pull request #241 from teloxide/v4.9

v4.9
This commit is contained in:
Temirkhan Myrzamadi 2020-07-30 11:27:04 +06:00 committed by GitHub
commit 34a35e690e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 2 deletions

View file

@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/official%20chat-t.me%2Fteloxide-blueviolet"> <img src="https://img.shields.io/badge/official%20chat-t.me%2Fteloxide-blueviolet">
</a> </a>
<a href="https://core.telegram.org/bots/api"> <a href="https://core.telegram.org/bots/api">
<img src="https://img.shields.io/badge/API coverage-Up to 0.4.7 (inclusively)-green.svg"> <img src="https://img.shields.io/badge/API coverage-Up to 0.4.9 (inclusively)-green.svg">
</a> </a>
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. 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.

View file

@ -25,13 +25,16 @@ pub struct Message {
/// Conversation the message belongs to. /// Conversation the message belongs to.
pub chat: Chat, pub chat: Chat,
/// Bot through which the message was sent.
pub via_bot: Option<User>,
#[serde(flatten)] #[serde(flatten)]
pub kind: MessageKind, pub kind: MessageKind,
} }
impl Message { impl Message {
pub fn new(id: i32, date: i32, chat: Chat, kind: MessageKind) -> Self { 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 { pub fn id(mut self, val: i32) -> Self {
@ -53,6 +56,11 @@ impl Message {
self.kind = val; self.kind = val;
self self
} }
pub fn via_bot(mut self, val: User) -> Self {
self.via_bot = Some(val);
self
}
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]

View file

@ -123,6 +123,7 @@ mod tests {
fn message() -> Message { fn message() -> Message {
Message { Message {
via_bot: None,
id: 0, id: 0,
date: 0, date: 0,
chat: Chat { chat: Chat {

View file

@ -179,6 +179,7 @@ mod test {
let expected = Update { let expected = Update {
id: 892_252_934, id: 892_252_934,
kind: UpdateKind::Message(Message { kind: UpdateKind::Message(Message {
via_bot: None,
id: 6557, id: 6557,
date: 1_569_518_342, date: 1_569_518_342,
chat: Chat { chat: Chat {