mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 15:01:45 +01:00
Apply review suggestions
This commit is contained in:
parent
239ff94c0e
commit
1a76a0e34d
9 changed files with 20 additions and 17 deletions
|
@ -2,7 +2,7 @@ use std::{convert::TryInto, str::FromStr};
|
|||
|
||||
use teloxide::{prelude::*, utils::command::BotCommand};
|
||||
|
||||
use teloxide::core::types::ChatPermissions;
|
||||
use teloxide::types::ChatPermissions;
|
||||
|
||||
// Derive BotCommand to parse text with a command into this enumeration.
|
||||
//
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// The version of Heroku ping-pong-bot, which uses a webhook to receive updates
|
||||
// from Telegram, instead of long polling.
|
||||
|
||||
use teloxide::{dispatching::update_listeners, prelude::*};
|
||||
use teloxide::{dispatching::update_listeners, prelude::*, types::Update};
|
||||
|
||||
use std::{convert::Infallible, env, net::SocketAddr};
|
||||
use tokio::sync::mpsc;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// The version of ngrok ping-pong-bot, which uses a webhook to receive updates
|
||||
// from Telegram, instead of long polling.
|
||||
|
||||
use teloxide::{dispatching::update_listeners, prelude::*};
|
||||
use teloxide::{dispatching::update_listeners, prelude::*, types::Update};
|
||||
|
||||
use std::{convert::Infallible, net::SocketAddr};
|
||||
use tokio::sync::mpsc;
|
||||
|
|
|
@ -9,6 +9,7 @@ use states::*;
|
|||
use teloxide::{
|
||||
dispatching::dialogue::{serializer::Bincode, RedisStorage, Storage},
|
||||
prelude::*,
|
||||
RequestError,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ use states::*;
|
|||
use teloxide::{
|
||||
dispatching::dialogue::{serializer::JSON, SqliteStorage, Storage},
|
||||
prelude::*,
|
||||
RequestError,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
|
@ -120,9 +120,9 @@ impl<S, E> UpdateListener<E> for S where S: Stream<Item = Result<Update, E>> {}
|
|||
/// Returns a long polling update listener with `timeout` of 10 seconds.
|
||||
///
|
||||
/// See also: [`polling`](polling).
|
||||
pub fn polling_default<R, E>(requester: R) -> impl UpdateListener<E>
|
||||
pub fn polling_default<R>(requester: R) -> impl UpdateListener<R::Err>
|
||||
where
|
||||
R: Requester<Err = E>,
|
||||
R: Requester,
|
||||
<R as Requester>::GetUpdatesFaultTolerant: Send,
|
||||
{
|
||||
polling(requester, Some(Duration::from_secs(10)), None, None)
|
||||
|
@ -140,14 +140,14 @@ where
|
|||
/// See also: [`polling_default`](polling_default).
|
||||
///
|
||||
/// [`GetUpdates`]: crate::requests::GetUpdates
|
||||
pub fn polling<R, E>(
|
||||
pub fn polling<R>(
|
||||
requester: R,
|
||||
timeout: Option<Duration>,
|
||||
limit: Option<u8>,
|
||||
allowed_updates: Option<Vec<AllowedUpdate>>,
|
||||
) -> impl UpdateListener<E>
|
||||
) -> impl UpdateListener<R::Err>
|
||||
where
|
||||
R: Requester<Err = E>,
|
||||
R: Requester,
|
||||
<R as Requester>::GetUpdatesFaultTolerant: Send,
|
||||
{
|
||||
let timeout = timeout.map(|t| t.as_secs().try_into().expect("timeout is too big"));
|
||||
|
|
|
@ -64,7 +64,8 @@ pub mod error_handlers;
|
|||
pub mod prelude;
|
||||
pub mod utils;
|
||||
|
||||
pub use teloxide_core as core;
|
||||
#[doc(inline)]
|
||||
pub use teloxide_core::*;
|
||||
|
||||
use teloxide_core::requests::ResponseResult;
|
||||
#[cfg(feature = "macros")]
|
||||
|
|
|
@ -12,15 +12,15 @@ pub use crate::{
|
|||
respond,
|
||||
};
|
||||
|
||||
pub use teloxide_core::prelude::*;
|
||||
|
||||
pub use teloxide_core::{
|
||||
adaptors::AutoSend,
|
||||
requests::{Request, ResponseResult},
|
||||
types::{Message, Update},
|
||||
RequestError,
|
||||
types::Message,
|
||||
};
|
||||
|
||||
#[doc(inline)]
|
||||
pub use teloxide_core::prelude::*;
|
||||
|
||||
#[cfg(feature = "frunk")]
|
||||
// FIXME(waffle): use `docsrs` here when issue with combine is resolved <https://github.com/teloxide/teloxide/pull/305#issuecomment-716172103>
|
||||
#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "frunk")))]
|
||||
|
|
|
@ -56,8 +56,8 @@ fn attribute_prefix() {
|
|||
#[test]
|
||||
#[cfg(feature = "macros")]
|
||||
fn many_attributes() {
|
||||
#[command(rename = "lowercase")]
|
||||
#[derive(BotCommand, Debug, PartialEq)]
|
||||
#[command(rename = "lowercase")]
|
||||
enum DefaultCommands {
|
||||
#[command(prefix = "!", description = "desc")]
|
||||
Start,
|
||||
|
@ -71,8 +71,8 @@ fn many_attributes() {
|
|||
#[test]
|
||||
#[cfg(feature = "macros")]
|
||||
fn global_attributes() {
|
||||
#[command(prefix = "!", rename = "lowercase", description = "Bot commands")]
|
||||
#[derive(BotCommand, Debug, PartialEq)]
|
||||
#[command(prefix = "!", rename = "lowercase", description = "Bot commands")]
|
||||
enum DefaultCommands {
|
||||
#[command(prefix = "/")]
|
||||
Start,
|
||||
|
@ -87,8 +87,8 @@ fn global_attributes() {
|
|||
#[test]
|
||||
#[cfg(feature = "macros")]
|
||||
fn parse_command_with_bot_name() {
|
||||
#[command(rename = "lowercase")]
|
||||
#[derive(BotCommand, Debug, PartialEq)]
|
||||
#[command(rename = "lowercase")]
|
||||
enum DefaultCommands {
|
||||
#[command(prefix = "/")]
|
||||
Start,
|
||||
|
@ -104,9 +104,9 @@ fn parse_command_with_bot_name() {
|
|||
#[test]
|
||||
#[cfg(feature = "macros")]
|
||||
fn parse_with_split() {
|
||||
#[derive(BotCommand, Debug, PartialEq)]
|
||||
#[command(rename = "lowercase")]
|
||||
#[command(parse_with = "split")]
|
||||
#[derive(BotCommand, Debug, PartialEq)]
|
||||
enum DefaultCommands {
|
||||
Start(u8, String),
|
||||
Help,
|
||||
|
|
Loading…
Reference in a new issue