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