mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 06:51:01 +01:00
Hot fixes
This commit is contained in:
parent
d803d8197a
commit
4b0dea21f1
3 changed files with 12 additions and 13 deletions
|
@ -6,9 +6,10 @@ async fn main() {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
log::info!("Starting the ping-pong bot!");
|
log::info!("Starting the ping-pong bot!");
|
||||||
|
|
||||||
Dispatcher::new(Bot::new("MyAwesomeToken"))
|
Dispatcher::<RequestError>::new(Bot::new("MyAwesomeToken"))
|
||||||
.message_handler(|ctx: HandlerCtx<Message>| async move {
|
.message_handler(&|ctx: DispatcherHandlerCtx<Message>| async move {
|
||||||
ctx.reply("pong").await
|
ctx.answer("pong").send().await?;
|
||||||
|
Ok(())
|
||||||
})
|
})
|
||||||
.dispatch()
|
.dispatch()
|
||||||
.await;
|
.await;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
mod download;
|
mod download;
|
||||||
|
@ -11,24 +12,21 @@ pub struct Bot {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bot {
|
impl Bot {
|
||||||
pub fn new<S>(token: S) -> Self
|
pub fn new<S>(token: S) -> Arc<Self>
|
||||||
where
|
where
|
||||||
S: Into<String>,
|
S: Into<String>,
|
||||||
{
|
{
|
||||||
Bot {
|
Self::with_client(token, Client::new())
|
||||||
token: token.into(),
|
|
||||||
client: Client::new(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_client<S>(token: S, client: Client) -> Self
|
pub fn with_client<S>(token: S, client: Client) -> Arc<Self>
|
||||||
where
|
where
|
||||||
S: Into<String>,
|
S: Into<String>,
|
||||||
{
|
{
|
||||||
Bot {
|
Arc::new(Bot {
|
||||||
token: token.into(),
|
token: token.into(),
|
||||||
client,
|
client,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,9 @@ where
|
||||||
{
|
{
|
||||||
/// Constructs a new dispatcher with this `bot`.
|
/// Constructs a new dispatcher with this `bot`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(bot: Bot) -> Self {
|
pub fn new(bot: Arc<Bot>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
bot: Arc::new(bot),
|
bot,
|
||||||
handlers_error_handler: Box::new(LoggingErrorHandler::new(
|
handlers_error_handler: Box::new(LoggingErrorHandler::new(
|
||||||
"An error from a Dispatcher's handler",
|
"An error from a Dispatcher's handler",
|
||||||
)),
|
)),
|
||||||
|
|
Loading…
Reference in a new issue