Merge branch 'dev' into improve-requests

This commit is contained in:
Temirkhan Myrzamadi 2020-01-24 07:16:21 +06:00 committed by GitHub
commit f9d83832f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 137 additions and 1005 deletions

View file

@ -4,8 +4,8 @@ use tokio::io::AsyncWrite;
use ::{bytes::Bytes, tokio::stream::Stream}; use ::{bytes::Bytes, tokio::stream::Stream};
#[cfg(feature = "unstable-stream")] #[cfg(feature = "unstable-stream")]
use crate::network::download_file_stream; use crate::net::download_file_stream;
use crate::{bot::Bot, network::download_file, DownloadError}; use crate::{bot::Bot, net::download_file, DownloadError};
impl Bot { impl Bot {
/// Download a file from Telegram into `destination`. /// Download a file from Telegram into `destination`.

View file

@ -1,110 +0,0 @@
use crate::{dispatching::Filter, types::Message};
pub struct CommandFilter {
command: String,
}
impl Filter<Message> for CommandFilter {
fn test(&self, value: &Message) -> bool {
match value.text() {
Some(text) => match text.split_whitespace().next() {
Some(command) => self.command == command,
None => false,
},
None => false,
}
}
}
impl CommandFilter {
pub fn new<T>(command: T) -> Self
where
T: Into<String>,
{
Self {
command: '/'.to_string() + &command.into(),
}
}
pub fn with_prefix<T>(command: T, prefix: T) -> Self
where
T: Into<String>,
{
Self {
command: prefix.into() + &command.into(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::types::{
Chat, ChatKind, ForwardKind, MediaKind, MessageKind, Sender, User,
};
#[test]
fn commands_are_equal() {
let filter = CommandFilter::new("command".to_string());
let message = create_message_with_text("/command".to_string());
assert!(filter.test(&message));
}
#[test]
fn commands_are_not_equal() {
let filter = CommandFilter::new("command".to_string());
let message =
create_message_with_text("/not_equal_command".to_string());
assert_eq!(filter.test(&message), false);
}
#[test]
fn command_have_args() {
let filter = CommandFilter::new("command".to_string());
let message =
create_message_with_text("/command arg1 arg2".to_string());
assert!(filter.test(&message));
}
#[test]
fn message_have_only_whitespace() {
let filter = CommandFilter::new("command".to_string());
let message = create_message_with_text(" ".to_string());
assert_eq!(filter.test(&message), false);
}
fn create_message_with_text(text: String) -> Message {
Message {
id: 0,
date: 0,
chat: Chat {
id: 0,
kind: ChatKind::Private {
type_: (),
username: None,
first_name: None,
last_name: None,
},
photo: None,
},
kind: MessageKind::Common {
from: Sender::User(User {
id: 0,
is_bot: false,
first_name: "".to_string(),
last_name: None,
username: None,
language_code: None,
}),
forward_kind: ForwardKind::Origin {
reply_to_message: None,
},
edit_date: None,
media_kind: MediaKind::Text {
text,
entities: vec![],
},
reply_markup: None,
},
}
}
}

View file

@ -1,379 +0,0 @@
/// Filter that determines that particular event
/// is suitable for particular handler.
pub trait Filter<T> {
/// Passes (return true) if event is suitable (otherwise return false)
fn test(&self, value: &T) -> bool;
}
/// ```
/// use teloxide::dispatching::filters::Filter;
///
/// let closure = |i: &i32| -> bool { *i >= 42 };
/// assert!(closure.test(&42));
/// assert!(closure.test(&100));
///
/// assert_eq!(closure.test(&41), false);
/// assert_eq!(closure.test(&0), false);
/// ```
impl<T, F: Fn(&T) -> bool> Filter<T> for F {
fn test(&self, value: &T) -> bool {
(self)(value)
}
}
/// ```
/// use teloxide::dispatching::filters::Filter;
///
/// assert!(true.test(&()));
/// assert_eq!(false.test(&()), false);
/// ```
impl<T> Filter<T> for bool {
fn test(&self, _: &T) -> bool {
*self
}
}
/// And filter.
///
/// Passes if both underlying filters pass.
///
/// **NOTE**: if one of filters don't pass
/// it is **not** guaranteed that other will be executed.
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{And, Filter};
///
/// // Note: bool can be treated as `Filter` that always return self.
/// assert_eq!(And::new(true, false).test(&()), false);
/// assert_eq!(And::new(true, false).test(&()), false);
/// assert!(And::new(true, true).test(&()));
/// assert!(And::new(true, And::new(|_: &()| true, true)).test(&()));
/// ```
#[derive(Debug, Clone, Copy)]
pub struct And<A, B>(A, B);
impl<A, B> And<A, B> {
pub fn new(a: A, b: B) -> Self {
And(a, b)
}
}
impl<T, A, B> Filter<T> for And<A, B>
where
A: Filter<T>,
B: Filter<T>,
{
fn test(&self, value: &T) -> bool {
self.0.test(value) && self.1.test(value)
}
}
/// Alias for [`And::new`]
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{and, Filter};
///
/// assert!(and(true, true).test(&()));
/// assert_eq!(and(true, false).test(&()), false);
/// ```
///
/// [`And::new`]: crate::dispatching::filters::And::new
pub fn and<A, B>(a: A, b: B) -> And<A, B> {
And::new(a, b)
}
/// Or filter.
///
/// Passes if at least one underlying filters passes.
///
/// **NOTE**: if one of filters passes
/// it is **not** guaranteed that other will be executed.
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{Filter, Or};
///
/// // Note: bool can be treated as `Filter` that always return self.
/// assert!(Or::new(true, false).test(&()));
/// assert!(Or::new(false, true).test(&()));
/// assert!(Or::new(false, Or::new(|_: &()| true, false)).test(&()));
/// assert_eq!(Or::new(false, false).test(&()), false);
/// ```
#[derive(Debug, Clone, Copy)]
pub struct Or<A, B>(A, B);
impl<A, B> Or<A, B> {
pub fn new(a: A, b: B) -> Self {
Or(a, b)
}
}
impl<T, A, B> Filter<T> for Or<A, B>
where
A: Filter<T>,
B: Filter<T>,
{
fn test(&self, value: &T) -> bool {
self.0.test(value) || self.1.test(value)
}
}
/// Alias for [`Or::new`]
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{or, Filter};
///
/// assert!(or(true, false).test(&()));
/// assert_eq!(or(false, false).test(&()), false);
/// ```
///
/// [`Or::new`]: crate::dispatching::filters::Or::new
pub fn or<A, B>(a: A, b: B) -> Or<A, B> {
Or::new(a, b)
}
/// Not filter.
///
/// Passes if underlying filter don't pass.
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{Filter, Not};
///
/// // Note: bool can be treated as `Filter` that always return self.
/// assert!(Not::new(false).test(&()));
/// assert_eq!(Not::new(true).test(&()), false);
/// ```
#[derive(Debug, Clone, Copy)]
pub struct Not<A>(A);
impl<A> Not<A> {
pub fn new(a: A) -> Self {
Not(a)
}
}
impl<T, A> Filter<T> for Not<A>
where
A: Filter<T>,
{
fn test(&self, value: &T) -> bool {
!self.0.test(value)
}
}
/// Alias for [`Not::new`]
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{not, Filter};
///
/// assert!(not(false).test(&()));
/// assert_eq!(not(true).test(&()), false);
/// ```
///
/// [`Not::new`]: crate::dispatching::filters::Not::new
pub fn not<A>(a: A) -> Not<A> {
Not::new(a)
}
/// Return [filter] that passes if and only if all of the given filters passes.
///
/// **NOTE**: if one of filters don't pass
/// it is **not** guaranteed that other will be executed.
///
/// ## Examples
/// ```
/// use teloxide::{all, dispatching::filters::Filter};
///
/// assert!(all![true].test(&()));
/// assert!(all![true, true].test(&()));
/// assert!(all![true, true, true].test(&()));
///
/// assert_eq!(all![false].test(&()), false);
/// assert_eq!(all![true, false].test(&()), false);
/// assert_eq!(all![false, true].test(&()), false);
/// assert_eq!(all![false, false].test(&()), false);
/// ```
///
/// [filter]: crate::dispatching::filters::Filter
#[macro_export]
macro_rules! all {
($one:expr) => { $one };
($head:expr, $($tail:tt)+) => {
$crate::dispatching::filters::And::new(
$head,
$crate::all!($($tail)+)
)
};
}
/// Return [filter] that passes if any of the given filters passes.
///
/// **NOTE**: if one of filters passes
/// it is **not** guaranteed that other will be executed.
///
/// ## Examples
/// ```
/// use teloxide::{any, dispatching::filters::Filter};
///
/// assert!(any![true].test(&()));
/// assert!(any![true, true].test(&()));
/// assert!(any![false, true].test(&()));
/// assert!(any![true, false, true].test(&()));
///
/// assert_eq!(any![false].test(&()), false);
/// assert_eq!(any![false, false].test(&()), false);
/// assert_eq!(any![false, false, false].test(&()), false);
/// ```
///
/// [filter]: crate::dispatching::filters::Filter
#[macro_export]
macro_rules! any {
($one:expr) => { $one };
($head:expr, $($tail:tt)+) => {
$crate::dispatching::filters::Or::new(
$head,
$crate::all!($($tail)+)
)
};
}
/// Simple wrapper around `Filter` that adds `|` and `&` operators.
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{f, And, Filter, Or, F};
///
/// let flt1 = |i: &i32| -> bool { *i > 17 };
/// let flt2 = |i: &i32| -> bool { *i < 42 };
/// let flt3 = |i: &i32| -> bool { *i % 2 == 0 };
///
/// let and = f(flt1) & flt2;
/// assert!(and.test(&19)); // both filters pass
///
/// assert_eq!(and.test(&50), false); // `flt2` doesn't pass
/// assert_eq!(and.test(&16), false); // `flt1` doesn't pass
///
/// let or = f(flt1) | flt3;
/// assert!(or.test(&19)); // `flt1` passes
/// assert!(or.test(&16)); // `flt2` passes
/// assert!(or.test(&20)); // both pass
///
/// assert_eq!(or.test(&17), false); // both don't pass
///
/// // Note: only first filter in chain should be wrapped in `f(...)`
/// let complicated: F<Or<And<_, _>, _>> = f(flt1) & flt2 | flt3;
/// assert!(complicated.test(&2)); // `flt3` passes
/// assert!(complicated.test(&21)); // `flt1` and `flt2` pass
///
/// assert_eq!(complicated.test(&15), false); // `flt1` and `flt3` don't pass
/// assert_eq!(complicated.test(&43), false); // `flt2` and `flt3` don't pass
/// ```
pub struct F<A>(A);
/// Constructor fn for [F]
///
/// [F]: crate::dispatching::filters::F;
pub fn f<A>(a: A) -> F<A> {
F(a)
}
impl<T, A> Filter<T> for F<A>
where
A: Filter<T>,
{
fn test(&self, value: &T) -> bool {
self.0.test(value)
}
}
impl<A, B> std::ops::BitAnd<B> for F<A> {
type Output = F<And<A, B>>;
fn bitand(self, other: B) -> Self::Output {
f(and(self.0, other))
}
}
impl<A, B> std::ops::BitOr<B> for F<A> {
type Output = F<Or<A, B>>;
fn bitor(self, other: B) -> Self::Output {
f(or(self.0, other))
}
}
/* workaround for `E0207` compiler error */
/// Extensions for filters
pub trait FilterExt<T> {
/// Alias for [`Not::new`]
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{Filter, FilterExt};
///
/// let flt = |i: &i32| -> bool { *i > 0 };
/// let flt = flt.not();
/// assert!(flt.test(&-1));
/// assert_eq!(flt.test(&1), false);
/// ```
///
/// [`Not::new`]: crate::dispatching::filters::Not::new
fn not(self) -> Not<Self>
where
Self: Sized,
{
Not::new(self)
}
/// Alias for [`And::new`]
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{Filter, FilterExt};
///
/// let flt = |i: &i32| -> bool { *i > 0 };
/// let flt = flt.and(|i: &i32| *i < 42);
///
/// assert!(flt.test(&1));
/// assert_eq!(flt.test(&-1), false);
/// assert_eq!(flt.test(&43), false);
/// ```
///
/// [`Not::new`]: crate::dispatching::filters::And::new
fn and<B>(self, other: B) -> And<Self, B>
where
Self: Sized,
{
And::new(self, other)
}
/// Alias for [`Or::new`]
///
/// ## Examples
/// ```
/// use teloxide::dispatching::filters::{Filter, FilterExt};
///
/// let flt = |i: &i32| -> bool { *i < 0 };
/// let flt = flt.or(|i: &i32| *i > 42);
///
/// assert!(flt.test(&-1));
/// assert!(flt.test(&43));
/// assert_eq!(flt.test(&17), false);
/// ```
///
/// [`Not::new`]: crate::dispatching::filters::Or::new
fn or<B>(self, other: B) -> Or<Self, B>
where
Self: Sized,
{
Or::new(self, other)
}
}
// All methods implemented via defaults
impl<T, F> FilterExt<T> for F where F: Filter<T> {}

View file

@ -1,100 +0,0 @@
use crate::{dispatching::Filter, types::Message};
/// Filter which compare caption of media with another text.
/// Returns true if the caption of media is equal to another text, otherwise
/// false.
///
/// NOTE: filter compares only caption of media, does not compare text of
/// message!
///
/// If you want to compare text of message use
/// [MessageTextFilter]
///
/// If you want to compare text and caption use
/// [MessageTextCaptionFilter]
///
/// [MessageTextFilter]: crate::dispatching::filters::MessageTextFilter
/// [MessageTextCaptionFilter]:
/// crate::dispatching::filters::MessageTextCaptionFilter
pub struct MessageCaptionFilter {
text: String,
}
impl Filter<Message> for MessageCaptionFilter {
fn test(&self, value: &Message) -> bool {
match value.caption() {
Some(caption) => self.text == caption,
None => false,
}
}
}
impl MessageCaptionFilter {
pub fn new<T>(text: T) -> Self
where
T: Into<String>,
{
Self { text: text.into() }
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::types::{
Chat, ChatKind, ForwardKind, MediaKind, MessageKind, Sender, User,
};
#[test]
fn captions_are_equal() {
let filter = MessageCaptionFilter::new("caption".to_string());
let message = create_message_with_caption("caption".to_string());
assert!(filter.test(&message));
}
#[test]
fn captions_are_not_equal() {
let filter = MessageCaptionFilter::new("caption".to_string());
let message =
create_message_with_caption("not equal caption".to_string());
assert_eq!(filter.test(&message), false);
}
fn create_message_with_caption(caption: String) -> Message {
Message {
id: 0,
date: 0,
chat: Chat {
id: 0,
kind: ChatKind::Private {
type_: (),
username: None,
first_name: None,
last_name: None,
},
photo: None,
},
kind: MessageKind::Common {
from: Sender::User(User {
id: 0,
is_bot: false,
first_name: "".to_string(),
last_name: None,
username: None,
language_code: None,
}),
forward_kind: ForwardKind::Origin {
reply_to_message: None,
},
edit_date: None,
media_kind: MediaKind::Photo {
photo: vec![],
caption: Some(caption),
caption_entities: vec![],
media_group_id: None,
},
reply_markup: None,
},
}
}
}

View file

@ -1,95 +0,0 @@
use crate::{dispatching::Filter, types::Message};
/// Filter which compare message text with another text.
/// Returns true if the message text is equal to another text, otherwise false.
///
/// NOTE: filter compares only text message, does not compare caption of media!
///
/// If you want to compare caption use
/// [MessageCaptionFilter]
///
/// If you want to compare text and caption use
/// [MessageTextCaptionFilter]
///
/// [MessageCaptionFilter]: crate::dispatching::filters::MessageCaptionFilter
/// [MessageTextCaptionFilter]:
/// crate::dispatching::filters::MessageTextCaptionFilter
pub struct MessageTextFilter {
text: String,
}
impl Filter<Message> for MessageTextFilter {
fn test(&self, value: &Message) -> bool {
match value.text() {
Some(text) => self.text == text,
None => false,
}
}
}
impl MessageTextFilter {
pub fn new<T>(text: T) -> Self
where
T: Into<String>,
{
Self { text: text.into() }
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::types::{
Chat, ChatKind, ForwardKind, MediaKind, MessageKind, Sender, User,
};
#[test]
fn texts_are_equal() {
let filter = MessageTextFilter::new("text");
let message = create_message_with_text("text".to_string());
assert!(filter.test(&message));
}
#[test]
fn texts_are_not_equal() {
let filter = MessageTextFilter::new("text");
let message = create_message_with_text("not equal text".to_string());
assert_eq!(filter.test(&message), false);
}
fn create_message_with_text(text: String) -> Message {
Message {
id: 0,
date: 0,
chat: Chat {
id: 0,
kind: ChatKind::Private {
type_: (),
username: None,
first_name: None,
last_name: None,
},
photo: None,
},
kind: MessageKind::Common {
from: Sender::User(User {
id: 0,
is_bot: false,
first_name: "".to_string(),
last_name: None,
username: None,
language_code: None,
}),
forward_kind: ForwardKind::Origin {
reply_to_message: None,
},
edit_date: None,
media_kind: MediaKind::Text {
text,
entities: vec![],
},
reply_markup: None,
},
}
}
}

View file

@ -1,152 +0,0 @@
use crate::{dispatching::Filter, types::Message};
/// Filter which compare message text or caption of media with another text.
/// Returns true if the message text or caption of media is equal to another
/// text, otherwise false.
///
/// NOTE: filter compares text of message or if it is not exists, compares
/// caption of the message!
///
/// If you want to compare only caption use
/// [MessageCaptionFilter]
///
/// If you want to compare only text use
/// [MessageTextFilter]
///
/// [MessageCaptionFilter]: crate::dispatching::filters::MessageCaptionFilter
/// [MessageTextFilter]: crate::dispatching::filters::MessageTextFilter
pub struct MessageTextCaptionFilter {
text: String,
}
impl Filter<Message> for MessageTextCaptionFilter {
fn test(&self, value: &Message) -> bool {
match value.text() {
Some(text) => self.text == text,
None => match value.caption() {
Some(caption) => self.text == caption,
None => false,
},
}
}
}
impl MessageTextCaptionFilter {
pub fn new<T>(text: T) -> Self
where
T: Into<String>,
{
Self { text: text.into() }
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::types::{
Chat, ChatKind, ForwardKind, MediaKind, MessageKind, Sender, User,
};
#[test]
fn texts_are_equal() {
let filter = MessageTextCaptionFilter::new("text");
let message = create_message_with_text("text".to_string());
assert!(filter.test(&message));
}
#[test]
fn texts_are_not_equal() {
let filter = MessageTextCaptionFilter::new("text");
let message = create_message_with_text("not equal text".to_string());
assert_eq!(filter.test(&message), false);
}
fn create_message_with_text(text: String) -> Message {
Message {
id: 0,
date: 0,
chat: Chat {
id: 0,
kind: ChatKind::Private {
type_: (),
username: None,
first_name: None,
last_name: None,
},
photo: None,
},
kind: MessageKind::Common {
from: Sender::User(User {
id: 0,
is_bot: false,
first_name: "".to_string(),
last_name: None,
username: None,
language_code: None,
}),
forward_kind: ForwardKind::Origin {
reply_to_message: None,
},
edit_date: None,
media_kind: MediaKind::Text {
text,
entities: vec![],
},
reply_markup: None,
},
}
}
#[test]
fn captions_are_equal() {
let filter = MessageTextCaptionFilter::new("caption".to_string());
let message = create_message_with_caption("caption".to_string());
assert!(filter.test(&message));
}
#[test]
fn captions_are_not_equal() {
let filter = MessageTextCaptionFilter::new("caption".to_string());
let message =
create_message_with_caption("not equal caption".to_string());
assert_eq!(filter.test(&message), false);
}
fn create_message_with_caption(caption: String) -> Message {
Message {
id: 0,
date: 0,
chat: Chat {
id: 0,
kind: ChatKind::Private {
type_: (),
username: None,
first_name: None,
last_name: None,
},
photo: None,
},
kind: MessageKind::Common {
from: Sender::User(User {
id: 0,
is_bot: false,
first_name: "".to_string(),
last_name: None,
username: None,
language_code: None,
}),
forward_kind: ForwardKind::Origin {
reply_to_message: None,
},
edit_date: None,
media_kind: MediaKind::Photo {
photo: vec![],
caption: Some(caption),
caption_entities: vec![],
media_group_id: None,
},
reply_markup: None,
},
}
}
}

View file

@ -1,15 +0,0 @@
//! Filters of messages.
pub use main::*;
pub use command::*;
pub use message_caption::*;
pub use message_text::*;
pub use message_text_caption::*;
mod main;
mod command;
mod message_caption;
mod message_text;
mod message_text_caption;

View file

@ -8,9 +8,7 @@ pub enum DispatchResult {
} }
pub mod chat; pub mod chat;
pub mod filters;
mod handler; mod handler;
pub mod update_listeners; pub mod update_listeners;
pub use filters::Filter;
pub use handler::*; pub use handler::*;

View file

@ -8,7 +8,7 @@ pub use bot::Bot;
pub use errors::{ApiErrorKind, DownloadError, RequestError}; pub use errors::{ApiErrorKind, DownloadError, RequestError};
mod errors; mod errors;
mod network; mod net;
mod bot; mod bot;
pub mod dispatching; pub mod dispatching;

View file

@ -1,5 +1,5 @@
use crate::{ use crate::{
network, net,
requests::form_builder::FormBuilder, requests::form_builder::FormBuilder,
types::{InputFile, MaskPosition, True}, types::{InputFile, MaskPosition, True},
Bot, Bot,
@ -26,7 +26,7 @@ impl Request for AddStickerToSet<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"addStickerToSet", "addStickerToSet",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::True, types::True,
Bot, Bot,
@ -34,7 +34,7 @@ impl Request for AnswerCallbackQuery<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"answerCallbackQuery", "answerCallbackQuery",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{InlineQueryResult, True}, types::{InlineQueryResult, True},
Bot, Bot,
@ -32,7 +32,7 @@ impl Request for AnswerInlineQuery<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"answerInlineQuery", "answerInlineQuery",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::True, types::True,
Bot, Bot,
@ -32,7 +32,7 @@ impl Request for AnswerPreCheckoutQuery<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"answerPreCheckoutQuery", "answerPreCheckoutQuery",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ShippingOption, True}, types::{ShippingOption, True},
Bot, Bot,
@ -31,7 +31,7 @@ impl Request for AnswerShippingQuery<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"answerShippingQuery", "answerShippingQuery",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{InputFile, MaskPosition, True}, types::{InputFile, MaskPosition, True},
Bot, Bot,
@ -27,7 +27,7 @@ impl Request for CreateNewStickerSet<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"createNewStickerSet", "createNewStickerSet",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -26,7 +26,7 @@ impl Request for DeleteChatPhoto<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"deleteChatPhoto", "deleteChatPhoto",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -31,7 +31,7 @@ impl Request for DeleteChatStickerSet<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"deleteChatStickerSet", "deleteChatStickerSet",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -37,7 +37,7 @@ impl Request for DeleteMessage<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"deleteMessage", "deleteMessage",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::True, types::True,
Bot, Bot,
@ -24,7 +24,7 @@ impl Request for DeleteStickerFromSet<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"deleteStickerFromSet", "deleteStickerFromSet",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::True, types::True,
Bot, Bot,
@ -27,7 +27,7 @@ impl Request for DeleteWebhook<'_> {
#[allow(clippy::trivially_copy_pass_by_ref)] #[allow(clippy::trivially_copy_pass_by_ref)]
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"deleteWebhook", "deleteWebhook",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
Bot, Bot,
@ -34,7 +34,7 @@ impl Request for EditMessageCaption<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"editMessageCaption", "editMessageCaption",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
Bot, Bot,
@ -36,7 +36,7 @@ impl Request for EditMessageLiveLocation<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"editMessageLiveLocation", "editMessageLiveLocation",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatOrInlineMessage, InlineKeyboardMarkup, InputMedia, Message}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, InputMedia, Message},
Bot, Bot,
@ -52,7 +52,7 @@ impl Request for EditMessageMedia<'_> {
} }
} }
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"editMessageMedia", "editMessageMedia",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
Bot, Bot,
@ -32,7 +32,7 @@ impl Request for EditMessageReplyMarkup<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"editMessageReplyMarkup", "editMessageReplyMarkup",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
Bot, Bot,
@ -35,7 +35,7 @@ impl Request for EditMessageText<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"editMessageText", "editMessageText",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::ChatId, types::ChatId,
Bot, Bot,
@ -41,7 +41,7 @@ impl Request for ExportChatInviteLink<'_> {
/// Returns the new invite link as `String` on success. /// Returns the new invite link as `String` on success.
async fn send(&self) -> ResponseResult<String> { async fn send(&self) -> ResponseResult<String> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"exportChatInviteLink", "exportChatInviteLink",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, Message}, types::{ChatId, Message},
Bot, Bot,
@ -27,7 +27,7 @@ impl Request for ForwardMessage<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"forwardMessage", "forwardMessage",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{Chat, ChatId}, types::{Chat, ChatId},
Bot, Bot,
@ -26,12 +26,7 @@ impl Request for GetChat<'_> {
type Output = Chat; type Output = Chat;
async fn send(&self) -> ResponseResult<Chat> { async fn send(&self) -> ResponseResult<Chat> {
network::request_json( net::request_json(self.bot.client(), self.bot.token(), "getChat", &self)
self.bot.client(),
self.bot.token(),
"getChat",
&self,
)
.await .await
} }
} }

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, ChatMember}, types::{ChatId, ChatMember},
Bot, Bot,
@ -29,7 +29,7 @@ impl Request for GetChatAdministrators<'_> {
/// On success, returns an array that contains information about all chat /// On success, returns an array that contains information about all chat
/// administrators except other bots. /// administrators except other bots.
async fn send(&self) -> ResponseResult<Vec<ChatMember>> { async fn send(&self) -> ResponseResult<Vec<ChatMember>> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"getChatAdministrators", "getChatAdministrators",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, ChatMember}, types::{ChatId, ChatMember},
Bot, Bot,
@ -25,7 +25,7 @@ impl Request for GetChatMember<'_> {
type Output = ChatMember; type Output = ChatMember;
async fn send(&self) -> ResponseResult<ChatMember> { async fn send(&self) -> ResponseResult<ChatMember> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"getChatMember", "getChatMember",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::ChatId, types::ChatId,
Bot, Bot,
@ -24,7 +24,7 @@ impl Request for GetChatMembersCount<'_> {
type Output = i32; type Output = i32;
async fn send(&self) -> ResponseResult<i32> { async fn send(&self) -> ResponseResult<i32> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"getChatMembersCount", "getChatMembersCount",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::File, types::File,
Bot, Bot,
@ -40,12 +40,7 @@ impl Request for GetFile<'_> {
type Output = File; type Output = File;
async fn send(&self) -> ResponseResult<File> { async fn send(&self) -> ResponseResult<File> {
network::request_json( net::request_json(self.bot.client(), self.bot.token(), "getFile", &self)
self.bot.client(),
self.bot.token(),
"getFile",
&self,
)
.await .await
} }
} }

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatOrInlineMessage, GameHighScore}, types::{ChatOrInlineMessage, GameHighScore},
Bot, Bot,
@ -35,7 +35,7 @@ impl Request for GetGameHighScores<'_> {
type Output = Vec<GameHighScore>; type Output = Vec<GameHighScore>;
async fn send(&self) -> ResponseResult<Vec<GameHighScore>> { async fn send(&self) -> ResponseResult<Vec<GameHighScore>> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"getGameHighScores", "getGameHighScores",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::User, types::User,
Bot, Bot,
@ -23,12 +23,7 @@ impl Request for GetMe<'_> {
/// Returns basic information about the bot. /// Returns basic information about the bot.
#[allow(clippy::trivially_copy_pass_by_ref)] #[allow(clippy::trivially_copy_pass_by_ref)]
async fn send(&self) -> ResponseResult<User> { async fn send(&self) -> ResponseResult<User> {
network::request_json( net::request_json(self.bot.client(), self.bot.token(), "getMe", &self)
self.bot.client(),
self.bot.token(),
"getMe",
&self,
)
.await .await
} }
} }

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::StickerSet, types::StickerSet,
Bot, Bot,
@ -24,7 +24,7 @@ impl Request for GetStickerSet<'_> {
type Output = StickerSet; type Output = StickerSet;
async fn send(&self) -> ResponseResult<StickerSet> { async fn send(&self) -> ResponseResult<StickerSet> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"getStickerSet", "getStickerSet",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{AllowedUpdate, Update}, types::{AllowedUpdate, Update},
Bot, Bot,
@ -34,7 +34,7 @@ impl Request for GetUpdates<'_> {
type Output = Vec<Update>; type Output = Vec<Update>;
async fn send(&self) -> ResponseResult<Vec<Update>> { async fn send(&self) -> ResponseResult<Vec<Update>> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"getUpdates", "getUpdates",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::UserProfilePhotos, types::UserProfilePhotos,
Bot, Bot,
@ -26,7 +26,7 @@ impl Request for GetUserProfilePhotos<'_> {
type Output = UserProfilePhotos; type Output = UserProfilePhotos;
async fn send(&self) -> ResponseResult<UserProfilePhotos> { async fn send(&self) -> ResponseResult<UserProfilePhotos> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"getUserProfilePhotos", "getUserProfilePhotos",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::WebhookInfo, types::WebhookInfo,
Bot, Bot,
@ -28,7 +28,7 @@ impl Request for GetWebhookInfo<'_> {
#[allow(clippy::trivially_copy_pass_by_ref)] #[allow(clippy::trivially_copy_pass_by_ref)]
async fn send(&self) -> ResponseResult<WebhookInfo> { async fn send(&self) -> ResponseResult<WebhookInfo> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"getWebhookInfo", "getWebhookInfo",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -33,7 +33,7 @@ impl Request for KickChatMember<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"kickChatMember", "kickChatMember",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -24,7 +24,7 @@ impl Request for LeaveChat<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"leaveChat", "leaveChat",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -30,7 +30,7 @@ impl Request for PinChatMessage<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"pinChatMessage", "pinChatMessage",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -37,7 +37,7 @@ impl Request for PromoteChatMember<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"promoteChatMember", "promoteChatMember",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, ChatPermissions, True}, types::{ChatId, ChatPermissions, True},
Bot, Bot,
@ -31,7 +31,7 @@ impl Request for RestrictChatMember<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"restrictChatMember", "restrictChatMember",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
@ -34,7 +34,7 @@ impl Request for SendAnimation<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendAnimation", "sendAnimation",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
@ -38,7 +38,7 @@ impl Request for SendAudio<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendAudio", "sendAudio",

View file

@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -76,7 +76,7 @@ impl Request for SendChatAction<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendChatAction", "sendChatAction",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, Message, ReplyMarkup}, types::{ChatId, Message, ReplyMarkup},
Bot, Bot,
@ -31,7 +31,7 @@ impl Request for SendContact<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendContact", "sendContact",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
@ -30,7 +30,7 @@ impl Request for SendDocument<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendDocument", "sendDocument",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{InlineKeyboardMarkup, Message}, types::{InlineKeyboardMarkup, Message},
Bot, Bot,
@ -28,7 +28,7 @@ impl Request for SendGame<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendGame", "sendGame",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{InlineKeyboardMarkup, LabeledPrice, Message}, types::{InlineKeyboardMarkup, LabeledPrice, Message},
Bot, Bot,
@ -46,7 +46,7 @@ impl Request for SendInvoice<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendInvoice", "sendInvoice",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, Message, ReplyMarkup}, types::{ChatId, Message, ReplyMarkup},
Bot, Bot,
@ -30,7 +30,7 @@ impl Request for SendLocation<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendLocation", "sendLocation",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatId, InputMedia, Message}, types::{ChatId, InputMedia, Message},
Bot, Bot,
@ -23,7 +23,7 @@ impl Request for SendMediaGroup<'_> {
type Output = Vec<Message>; type Output = Vec<Message>;
async fn send(&self) -> ResponseResult<Vec<Message>> { async fn send(&self) -> ResponseResult<Vec<Message>> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendMediaGroup", "sendMediaGroup",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, Message, ParseMode, ReplyMarkup}, types::{ChatId, Message, ParseMode, ReplyMarkup},
Bot, Bot,
@ -30,7 +30,7 @@ impl Request for SendMessage<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendMessage", "sendMessage",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
@ -26,7 +26,7 @@ impl Request for SendPhoto<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendPhoto", "sendPhoto",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, Message, ReplyMarkup}, types::{ChatId, Message, ReplyMarkup},
Bot, Bot,
@ -30,7 +30,7 @@ impl Request for SendPoll<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendPoll", "sendPoll",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatId, InputFile, Message, ReplyMarkup}, types::{ChatId, InputFile, Message, ReplyMarkup},
Bot, Bot,
@ -26,7 +26,7 @@ impl Request for SendSticker<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendSticker", "sendSticker",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, Message, ReplyMarkup}, types::{ChatId, Message, ReplyMarkup},
Bot, Bot,
@ -33,7 +33,7 @@ impl Request for SendVenue<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendVenue", "sendVenue",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
@ -35,7 +35,7 @@ impl Request for SendVideo<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendVideo", "sendVideo",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatId, InputFile, Message, ReplyMarkup}, types::{ChatId, InputFile, Message, ReplyMarkup},
Bot, Bot,
@ -30,7 +30,7 @@ impl Request for SendVideoNote<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendVideoNote", "sendVideoNote",

View file

@ -1,6 +1,6 @@
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{form_builder::FormBuilder, Request, ResponseResult}, requests::{form_builder::FormBuilder, Request, ResponseResult},
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup}, types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
Bot, Bot,
@ -36,7 +36,7 @@ impl Request for SendVoice<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_multipart( net::request_multipart(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendVoice", "sendVoice",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -27,7 +27,7 @@ impl Request for SetChatAdministratorCustomTitle<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"setChatAdministratorCustomTitle", "setChatAdministratorCustomTitle",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -29,7 +29,7 @@ impl Request for SetChatDescription<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"setChatDescription", "setChatDescription",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, ChatPermissions, True}, types::{ChatId, ChatPermissions, True},
Bot, Bot,
@ -28,7 +28,7 @@ impl Request for SetChatPermissions<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"sendChatPermissions", "sendChatPermissions",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, InputFile, True}, types::{ChatId, InputFile, True},
Bot, Bot,
@ -28,7 +28,7 @@ impl Request for SetChatPhoto<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"setChatPhoto", "setChatPhoto",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -29,7 +29,7 @@ impl Request for SetChatStickerSet<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"setChatStickerSet", "setChatStickerSet",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -28,7 +28,7 @@ impl Request for SetChatTitle<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"setChatTitle", "setChatTitle",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatOrInlineMessage, Message}, types::{ChatOrInlineMessage, Message},
Bot, Bot,
@ -37,7 +37,7 @@ impl Request for SetGameScore<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"setGameScore", "setGameScore",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::True, types::True,
Bot, Bot,
@ -26,7 +26,7 @@ impl Request for SetStickerPositionInSet<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"setStickerPositionInSet", "setStickerPositionInSet",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{AllowedUpdate, InputFile, True}, types::{AllowedUpdate, InputFile, True},
Bot, Bot,
@ -40,7 +40,7 @@ impl Request for SetWebhook<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"setWebhook", "setWebhook",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message}, types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
Bot, Bot,
@ -33,7 +33,7 @@ impl Request for StopMessageLiveLocation<'_> {
type Output = Message; type Output = Message;
async fn send(&self) -> ResponseResult<Message> { async fn send(&self) -> ResponseResult<Message> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"stopMessageLiveLocation", "stopMessageLiveLocation",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, InlineKeyboardMarkup, Poll}, types::{ChatId, InlineKeyboardMarkup, Poll},
Bot, Bot,
@ -29,7 +29,7 @@ impl Request for StopPoll<'_> {
/// ///
/// [`Poll`]: crate::types::Poll /// [`Poll`]: crate::types::Poll
async fn send(&self) -> ResponseResult<Poll> { async fn send(&self) -> ResponseResult<Poll> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"stopPoll", "stopPoll",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -28,7 +28,7 @@ impl Request for UnbanChatMember<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"unbanChatMember", "unbanChatMember",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{ChatId, True}, types::{ChatId, True},
Bot, Bot,
@ -28,7 +28,7 @@ impl Request for UnpinChatMessage<'_> {
type Output = True; type Output = True;
async fn send(&self) -> ResponseResult<True> { async fn send(&self) -> ResponseResult<True> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"unpinChatMessage", "unpinChatMessage",

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use super::BotWrapper; use super::BotWrapper;
use crate::{ use crate::{
network, net,
requests::{Request, ResponseResult}, requests::{Request, ResponseResult},
types::{File, InputFile}, types::{File, InputFile},
Bot, Bot,
@ -29,7 +29,7 @@ impl Request for UploadStickerFile<'_> {
type Output = File; type Output = File;
async fn send(&self) -> ResponseResult<File> { async fn send(&self) -> ResponseResult<File> {
network::request_json( net::request_json(
self.bot.client(), self.bot.client(),
self.bot.token(), self.bot.token(),
"uploadStickerFile", "uploadStickerFile",