mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Merge branch 'dev' into improve-requests
This commit is contained in:
commit
f9d83832f3
79 changed files with 137 additions and 1005 deletions
|
@ -24,4 +24,4 @@ duang = "0.1.2"
|
|||
futures = "0.3.1"
|
||||
pin-project = "0.4.6"
|
||||
serde_with_macros = "1.0.1"
|
||||
either = "1.5.3"
|
||||
either = "1.5.3"
|
||||
|
|
|
@ -4,8 +4,8 @@ use tokio::io::AsyncWrite;
|
|||
use ::{bytes::Bytes, tokio::stream::Stream};
|
||||
|
||||
#[cfg(feature = "unstable-stream")]
|
||||
use crate::network::download_file_stream;
|
||||
use crate::{bot::Bot, network::download_file, DownloadError};
|
||||
use crate::net::download_file_stream;
|
||||
use crate::{bot::Bot, net::download_file, DownloadError};
|
||||
|
||||
impl Bot {
|
||||
/// Download a file from Telegram into `destination`.
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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> {}
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
|
@ -8,9 +8,7 @@ pub enum DispatchResult {
|
|||
}
|
||||
|
||||
pub mod chat;
|
||||
pub mod filters;
|
||||
mod handler;
|
||||
pub mod update_listeners;
|
||||
|
||||
pub use filters::Filter;
|
||||
pub use handler::*;
|
||||
|
|
|
@ -8,7 +8,7 @@ pub use bot::Bot;
|
|||
pub use errors::{ApiErrorKind, DownloadError, RequestError};
|
||||
|
||||
mod errors;
|
||||
mod network;
|
||||
mod net;
|
||||
|
||||
mod bot;
|
||||
pub mod dispatching;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::form_builder::FormBuilder,
|
||||
types::{InputFile, MaskPosition, True},
|
||||
Bot,
|
||||
|
@ -26,7 +26,7 @@ impl Request for AddStickerToSet<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"addStickerToSet",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::True,
|
||||
Bot,
|
||||
|
@ -34,7 +34,7 @@ impl Request for AnswerCallbackQuery<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"answerCallbackQuery",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{InlineQueryResult, True},
|
||||
Bot,
|
||||
|
@ -32,7 +32,7 @@ impl Request for AnswerInlineQuery<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"answerInlineQuery",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::True,
|
||||
Bot,
|
||||
|
@ -32,7 +32,7 @@ impl Request for AnswerPreCheckoutQuery<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"answerPreCheckoutQuery",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ShippingOption, True},
|
||||
Bot,
|
||||
|
@ -31,7 +31,7 @@ impl Request for AnswerShippingQuery<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"answerShippingQuery",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{InputFile, MaskPosition, True},
|
||||
Bot,
|
||||
|
@ -27,7 +27,7 @@ impl Request for CreateNewStickerSet<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"createNewStickerSet",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -26,7 +26,7 @@ impl Request for DeleteChatPhoto<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"deleteChatPhoto",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -31,7 +31,7 @@ impl Request for DeleteChatStickerSet<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"deleteChatStickerSet",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -37,7 +37,7 @@ impl Request for DeleteMessage<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"deleteMessage",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::True,
|
||||
Bot,
|
||||
|
@ -24,7 +24,7 @@ impl Request for DeleteStickerFromSet<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"deleteStickerFromSet",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::True,
|
||||
Bot,
|
||||
|
@ -27,7 +27,7 @@ impl Request for DeleteWebhook<'_> {
|
|||
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"deleteWebhook",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
|
||||
Bot,
|
||||
|
@ -34,7 +34,7 @@ impl Request for EditMessageCaption<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"editMessageCaption",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
|
@ -36,7 +36,7 @@ impl Request for EditMessageLiveLocation<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"editMessageLiveLocation",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, InputMedia, Message},
|
||||
Bot,
|
||||
|
@ -52,7 +52,7 @@ impl Request for EditMessageMedia<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"editMessageMedia",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
|
@ -32,7 +32,7 @@ impl Request for EditMessageReplyMarkup<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"editMessageReplyMarkup",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message, ParseMode},
|
||||
Bot,
|
||||
|
@ -35,7 +35,7 @@ impl Request for EditMessageText<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"editMessageText",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::ChatId,
|
||||
Bot,
|
||||
|
@ -41,7 +41,7 @@ impl Request for ExportChatInviteLink<'_> {
|
|||
|
||||
/// Returns the new invite link as `String` on success.
|
||||
async fn send(&self) -> ResponseResult<String> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"exportChatInviteLink",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message},
|
||||
Bot,
|
||||
|
@ -27,7 +27,7 @@ impl Request for ForwardMessage<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"forwardMessage",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{Chat, ChatId},
|
||||
Bot,
|
||||
|
@ -26,13 +26,8 @@ impl Request for GetChat<'_> {
|
|||
type Output = Chat;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Chat> {
|
||||
network::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getChat",
|
||||
&self,
|
||||
)
|
||||
.await
|
||||
net::request_json(self.bot.client(), self.bot.token(), "getChat", &self)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, ChatMember},
|
||||
Bot,
|
||||
|
@ -29,7 +29,7 @@ impl Request for GetChatAdministrators<'_> {
|
|||
/// On success, returns an array that contains information about all chat
|
||||
/// administrators except other bots.
|
||||
async fn send(&self) -> ResponseResult<Vec<ChatMember>> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getChatAdministrators",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, ChatMember},
|
||||
Bot,
|
||||
|
@ -25,7 +25,7 @@ impl Request for GetChatMember<'_> {
|
|||
type Output = ChatMember;
|
||||
|
||||
async fn send(&self) -> ResponseResult<ChatMember> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getChatMember",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::ChatId,
|
||||
Bot,
|
||||
|
@ -24,7 +24,7 @@ impl Request for GetChatMembersCount<'_> {
|
|||
type Output = i32;
|
||||
|
||||
async fn send(&self) -> ResponseResult<i32> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getChatMembersCount",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::File,
|
||||
Bot,
|
||||
|
@ -40,13 +40,8 @@ impl Request for GetFile<'_> {
|
|||
type Output = File;
|
||||
|
||||
async fn send(&self) -> ResponseResult<File> {
|
||||
network::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getFile",
|
||||
&self,
|
||||
)
|
||||
.await
|
||||
net::request_json(self.bot.client(), self.bot.token(), "getFile", &self)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, GameHighScore},
|
||||
Bot,
|
||||
|
@ -35,7 +35,7 @@ impl Request for GetGameHighScores<'_> {
|
|||
type Output = Vec<GameHighScore>;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Vec<GameHighScore>> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getGameHighScores",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::User,
|
||||
Bot,
|
||||
|
@ -23,13 +23,8 @@ impl Request for GetMe<'_> {
|
|||
/// Returns basic information about the bot.
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
async fn send(&self) -> ResponseResult<User> {
|
||||
network::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getMe",
|
||||
&self,
|
||||
)
|
||||
.await
|
||||
net::request_json(self.bot.client(), self.bot.token(), "getMe", &self)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::StickerSet,
|
||||
Bot,
|
||||
|
@ -24,7 +24,7 @@ impl Request for GetStickerSet<'_> {
|
|||
type Output = StickerSet;
|
||||
|
||||
async fn send(&self) -> ResponseResult<StickerSet> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getStickerSet",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{AllowedUpdate, Update},
|
||||
Bot,
|
||||
|
@ -34,7 +34,7 @@ impl Request for GetUpdates<'_> {
|
|||
type Output = Vec<Update>;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Vec<Update>> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getUpdates",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::UserProfilePhotos,
|
||||
Bot,
|
||||
|
@ -26,7 +26,7 @@ impl Request for GetUserProfilePhotos<'_> {
|
|||
type Output = UserProfilePhotos;
|
||||
|
||||
async fn send(&self) -> ResponseResult<UserProfilePhotos> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getUserProfilePhotos",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::WebhookInfo,
|
||||
Bot,
|
||||
|
@ -28,7 +28,7 @@ impl Request for GetWebhookInfo<'_> {
|
|||
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
async fn send(&self) -> ResponseResult<WebhookInfo> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"getWebhookInfo",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -33,7 +33,7 @@ impl Request for KickChatMember<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"kickChatMember",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -24,7 +24,7 @@ impl Request for LeaveChat<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"leaveChat",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -30,7 +30,7 @@ impl Request for PinChatMessage<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"pinChatMessage",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -37,7 +37,7 @@ impl Request for PromoteChatMember<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"promoteChatMember",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, ChatPermissions, True},
|
||||
Bot,
|
||||
|
@ -31,7 +31,7 @@ impl Request for RestrictChatMember<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"restrictChatMember",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -34,7 +34,7 @@ impl Request for SendAnimation<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendAnimation",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -38,7 +38,7 @@ impl Request for SendAudio<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendAudio",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -76,7 +76,7 @@ impl Request for SendChatAction<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendChatAction",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -31,7 +31,7 @@ impl Request for SendContact<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendContact",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -30,7 +30,7 @@ impl Request for SendDocument<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendDocument",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
|
@ -28,7 +28,7 @@ impl Request for SendGame<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendGame",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{InlineKeyboardMarkup, LabeledPrice, Message},
|
||||
Bot,
|
||||
|
@ -46,7 +46,7 @@ impl Request for SendInvoice<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendInvoice",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -30,7 +30,7 @@ impl Request for SendLocation<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendLocation",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputMedia, Message},
|
||||
Bot,
|
||||
|
@ -23,7 +23,7 @@ impl Request for SendMediaGroup<'_> {
|
|||
type Output = Vec<Message>;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Vec<Message>> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendMediaGroup",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -30,7 +30,7 @@ impl Request for SendMessage<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendMessage",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -26,7 +26,7 @@ impl Request for SendPhoto<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendPhoto",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -30,7 +30,7 @@ impl Request for SendPoll<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendPoll",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -26,7 +26,7 @@ impl Request for SendSticker<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendSticker",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, Message, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -33,7 +33,7 @@ impl Request for SendVenue<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendVenue",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -35,7 +35,7 @@ impl Request for SendVideo<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendVideo",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -30,7 +30,7 @@ impl Request for SendVideoNote<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendVideoNote",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{form_builder::FormBuilder, Request, ResponseResult},
|
||||
types::{ChatId, InputFile, Message, ParseMode, ReplyMarkup},
|
||||
Bot,
|
||||
|
@ -36,7 +36,7 @@ impl Request for SendVoice<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_multipart(
|
||||
net::request_multipart(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendVoice",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -27,7 +27,7 @@ impl Request for SetChatAdministratorCustomTitle<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"setChatAdministratorCustomTitle",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -29,7 +29,7 @@ impl Request for SetChatDescription<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"setChatDescription",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, ChatPermissions, True},
|
||||
Bot,
|
||||
|
@ -28,7 +28,7 @@ impl Request for SetChatPermissions<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"sendChatPermissions",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, InputFile, True},
|
||||
Bot,
|
||||
|
@ -28,7 +28,7 @@ impl Request for SetChatPhoto<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"setChatPhoto",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -29,7 +29,7 @@ impl Request for SetChatStickerSet<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"setChatStickerSet",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -28,7 +28,7 @@ impl Request for SetChatTitle<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"setChatTitle",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, Message},
|
||||
Bot,
|
||||
|
@ -37,7 +37,7 @@ impl Request for SetGameScore<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"setGameScore",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::True,
|
||||
Bot,
|
||||
|
@ -26,7 +26,7 @@ impl Request for SetStickerPositionInSet<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"setStickerPositionInSet",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{AllowedUpdate, InputFile, True},
|
||||
Bot,
|
||||
|
@ -40,7 +40,7 @@ impl Request for SetWebhook<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"setWebhook",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatOrInlineMessage, InlineKeyboardMarkup, Message},
|
||||
Bot,
|
||||
|
@ -33,7 +33,7 @@ impl Request for StopMessageLiveLocation<'_> {
|
|||
type Output = Message;
|
||||
|
||||
async fn send(&self) -> ResponseResult<Message> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"stopMessageLiveLocation",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, InlineKeyboardMarkup, Poll},
|
||||
Bot,
|
||||
|
@ -29,7 +29,7 @@ impl Request for StopPoll<'_> {
|
|||
///
|
||||
/// [`Poll`]: crate::types::Poll
|
||||
async fn send(&self) -> ResponseResult<Poll> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"stopPoll",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -28,7 +28,7 @@ impl Request for UnbanChatMember<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"unbanChatMember",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{ChatId, True},
|
||||
Bot,
|
||||
|
@ -28,7 +28,7 @@ impl Request for UnpinChatMessage<'_> {
|
|||
type Output = True;
|
||||
|
||||
async fn send(&self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"unpinChatMessage",
|
||||
|
|
|
@ -2,7 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use super::BotWrapper;
|
||||
use crate::{
|
||||
network,
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{File, InputFile},
|
||||
Bot,
|
||||
|
@ -29,7 +29,7 @@ impl Request for UploadStickerFile<'_> {
|
|||
type Output = File;
|
||||
|
||||
async fn send(&self) -> ResponseResult<File> {
|
||||
network::request_json(
|
||||
net::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"uploadStickerFile",
|
||||
|
|
Loading…
Reference in a new issue