Add via_bot to Message

This commit is contained in:
Temirkhan Myrzamadi 2020-07-30 11:18:23 +06:00
parent 710675fdf6
commit f39be99644
3 changed files with 11 additions and 1 deletions

View file

@ -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)]

View file

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

View file

@ -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 {