Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions raw/src/requests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub mod send_photo;
pub mod send_poll;
pub mod send_venue;
pub mod send_video;
pub mod set_chat_description;
pub mod stop_message_live_location;
pub mod stop_poll;
pub mod unban_chat_member;
Expand Down Expand Up @@ -66,6 +67,7 @@ pub use self::send_photo::*;
pub use self::send_poll::*;
pub use self::send_venue::*;
pub use self::send_video::*;
pub use self::set_chat_description::*;
pub use self::stop_message_live_location::*;
pub use self::stop_poll::*;
pub use self::unban_chat_member::*;
Expand Down
2 changes: 1 addition & 1 deletion raw/src/requests/send_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ where
where
T: Into<Cow<'s, str>>,
{
let mut rq = self.to_source_chat().text(text);
let mut rq = send_message::CanSendMessage::text(&self.to_source_chat(), text);
rq.reply_to(self.to_message_id());
rq
}
Expand Down
53 changes: 53 additions & 0 deletions raw/src/requests/set_chat_description.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use std::borrow::Cow;

use crate::requests::*;
use crate::types::*;

/// Use this method to set group descriptions.
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
#[must_use = "requests do nothing unless sent"]
pub struct SetChatDescription<'s> {
chat_id: ChatRef,
description: Cow<'s, str>,
}

impl<'c, 's> Request for SetChatDescription<'s> {
type Type = JsonRequestType<Self>;
type Response = JsonIdResponse<bool>;

fn serialize(&self) -> Result<HttpRequest, Error> {
Self::Type::serialize(RequestUrl::method("setChatDescription"), self)
}
}

impl<'s> SetChatDescription<'s> {
pub fn new<C, D>(chat: C, description: D) -> Self
where
C: ToChatRef,
D: Into<Cow<'s, str>>,
{
SetChatDescription {
chat_id: chat.to_chat_ref(),
description: description.into(),
}
}
}

/// Set chat description.
pub trait CanSetChatDescription {
fn text<'s, T>(&self, text: T) -> SetChatDescription<'s>
where
T: Into<Cow<'s, str>>;
}

impl<C> CanSetChatDescription for C
where
C: ToChatRef,
{
fn text<'s, D>(&self, text: D) -> SetChatDescription<'s>
where
D: Into<Cow<'s, str>>,
{
SetChatDescription::new(self, text)
}
}
11 changes: 11 additions & 0 deletions raw/src/types/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct Group {
/// You can generate a new invite link by using the
/// export_invite_link method.
pub invite_link: Option<String>,
/// The group's description.
pub description: Option<String>,
}

/// This object represents a supergroup.
Expand All @@ -47,6 +49,8 @@ pub struct Supergroup {
/// You can generate a new invite link by using the
/// export_invite_link method.
pub invite_link: Option<String>,
/// The group's description.
pub description: Option<String>,
}

/// This object represents a channel.
Expand All @@ -62,6 +66,8 @@ pub struct Channel {
/// You can generate a new invite link by using the
/// export_invite_link method.
pub invite_link: Option<String>,
/// Channel description
pub description: Option<String>,
}

/// This object represents a private, group or supergroup.
Expand Down Expand Up @@ -138,18 +144,21 @@ impl<'de> Deserialize<'de> for Chat {
title: required_field!(title),
all_members_are_administrators: required_field!(all_members_are_administrators),
invite_link: raw.invite_link,
description: raw.description,
}),
"supergroup" => Chat::Supergroup(Supergroup {
id: raw.id.into(),
title: required_field!(title),
username: raw.username,
invite_link: raw.invite_link,
description: raw.description,
}),
"channel" => Chat::Channel(Channel {
id: raw.id.into(),
title: required_field!(title),
username: raw.username,
invite_link: raw.invite_link,
description: raw.description,
}),
_ => Chat::Unknown(raw),
})
Expand Down Expand Up @@ -179,4 +188,6 @@ pub struct RawChat {
pub language_code: Option<String>,
/// True if a group has ‘All Members Are Admins’ enabled.
pub all_members_are_administrators: Option<bool>,
/// The group's description
pub description: Option<String>,
}