mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
commit
34a35e690e
4 changed files with 12 additions and 2 deletions
|
@ -15,7 +15,7 @@
|
|||
<img src="https://img.shields.io/badge/official%20chat-t.me%2Fteloxide-blueviolet">
|
||||
</a>
|
||||
<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 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.
|
||||
|
|
|
@ -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<User>,
|
||||
|
||||
#[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)]
|
||||
|
|
|
@ -123,6 +123,7 @@ mod tests {
|
|||
|
||||
fn message() -> Message {
|
||||
Message {
|
||||
via_bot: None,
|
||||
id: 0,
|
||||
date: 0,
|
||||
chat: Chat {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue