mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-11 04:21:12 +01:00
added method exportChatInviteLink
This commit is contained in:
parent
e760c281b8
commit
2cb5adeebe
3 changed files with 84 additions and 1 deletions
|
@ -9,7 +9,8 @@ use crate::{
|
|||
SendLocation, SendMediaGroup, SendMessage, SendPhoto, SendPoll,
|
||||
SendVenue, SendVideo, SendVideoNote, SendVoice, SetChatDescription,
|
||||
SetChatStickerSet, StopMessageLiveLocation, UnbanChatMember,
|
||||
UnpinChatMessage, SetChatTitle, DeleteChatPhoto, SetChatPhoto
|
||||
UnpinChatMessage, SetChatTitle, DeleteChatPhoto, SetChatPhoto,
|
||||
ExportCharInviteLink
|
||||
},
|
||||
types::{ChatAction, ChatId, ChatPermissions, InputFile, InputMedia},
|
||||
};
|
||||
|
@ -390,4 +391,14 @@ impl Bot {
|
|||
{
|
||||
SetChatPhoto::new(self, chat_id, photo)
|
||||
}
|
||||
|
||||
pub fn export_chat_invite_link<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
) -> ExportCharInviteLink
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
ExportCharInviteLink::new(self, chat_id)
|
||||
}
|
||||
}
|
||||
|
|
70
src/requests/export_chat_invite_link.rs
Normal file
70
src/requests/export_chat_invite_link.rs
Normal file
|
@ -0,0 +1,70 @@
|
|||
use async_trait::async_trait;
|
||||
|
||||
use crate::bot::Bot;
|
||||
use crate::types::ChatId;
|
||||
use crate::requests::{ResponseResult, Request};
|
||||
use crate::network;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ExportCharInviteLink<'a> {
|
||||
#[serde(skip_serializing)]
|
||||
bot: &'a Bot,
|
||||
|
||||
chat_id: ChatId
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Request for ExportCharInviteLink<'_> {
|
||||
type Output = String;
|
||||
|
||||
async fn send_boxed(self) -> ResponseResult<Self::Output> {
|
||||
self.send().await
|
||||
}
|
||||
}
|
||||
|
||||
impl ExportCharInviteLink<'_> {
|
||||
async fn send(self) -> ResponseResult<String> {
|
||||
network::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"exportChatInviteLink",
|
||||
&self
|
||||
).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ExportCharInviteLink<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>
|
||||
{
|
||||
Self {
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn chat_id<C>(mut self, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
self.chat_id = chat_id.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn serialize() {
|
||||
let bot = Bot::new("token");
|
||||
let chat_id = 123;
|
||||
let method = ExportCharInviteLink::new(&bot, chat_id);
|
||||
|
||||
let expected = r#"{"chat_id":123}"#;
|
||||
let actual = serde_json::to_string::<ExportCharInviteLink>(&method).unwrap();
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ pub use answer_shipping_query::*;
|
|||
pub use delete_chat_photo::*;
|
||||
pub use delete_chat_sticker_set::*;
|
||||
pub use edit_message_live_location::*;
|
||||
pub use export_chat_invite_link::*;
|
||||
pub use forward_message::*;
|
||||
pub use get_chat::*;
|
||||
pub use get_chat_member::*;
|
||||
|
@ -52,6 +53,7 @@ mod answer_shipping_query;
|
|||
mod delete_chat_photo;
|
||||
mod delete_chat_sticker_set;
|
||||
mod edit_message_live_location;
|
||||
mod export_chat_invite_link;
|
||||
mod forward_message;
|
||||
mod get_chat;
|
||||
mod get_chat_member;
|
||||
|
|
Loading…
Reference in a new issue