mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
Don't define async fn run()
rustc now emits enough good compiler error messages for procedural macros such as `#[tokio::main]`.
This commit is contained in:
parent
b10288f751
commit
b253b7eec2
11 changed files with 30 additions and 95 deletions
25
README.md
25
README.md
|
@ -342,31 +342,6 @@ async fn handle_message(
|
|||
|
||||
[More examples!](./examples)
|
||||
|
||||
## Recommendations
|
||||
- Use this pattern:
|
||||
|
||||
```rust
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
// Your logic here...
|
||||
}
|
||||
```
|
||||
|
||||
Instead of this:
|
||||
|
||||
```rust
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Your logic here...
|
||||
}
|
||||
```
|
||||
|
||||
The second one produces very strange compiler messages due to the `#[tokio::main]` macro. However, the examples in this README use the second variant for brevity.
|
||||
|
||||
## FAQ
|
||||
**Q: Where I can ask questions?**
|
||||
|
||||
|
|
|
@ -155,10 +155,6 @@ async fn action(
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting admin_bot...");
|
||||
|
||||
|
|
|
@ -27,10 +27,6 @@ use teloxide::prelude::*;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting dialogue_bot...");
|
||||
|
||||
|
|
|
@ -7,10 +7,6 @@ type TeleBot = AutoSend<Bot>;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting dices_bot...");
|
||||
|
||||
|
|
|
@ -19,7 +19,21 @@ use reqwest::{StatusCode, Url};
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting heroku_ping_pong_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
||||
let cloned_bot = bot.clone();
|
||||
teloxide::repl_with_listener(
|
||||
bot,
|
||||
|message| async move {
|
||||
message.answer("pong").await?;
|
||||
respond(())
|
||||
},
|
||||
webhook(cloned_bot).await,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn handle_rejection(error: warp::Rejection) -> Result<impl warp::Reply, Infallible> {
|
||||
|
@ -75,21 +89,3 @@ pub async fn webhook(bot: AutoSend<Bot>) -> impl update_listeners::UpdateListene
|
|||
state.1.clone()
|
||||
})
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting heroku_ping_pong_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
||||
let cloned_bot = bot.clone();
|
||||
teloxide::repl_with_listener(
|
||||
bot,
|
||||
|message| async move {
|
||||
message.answer("pong").await?;
|
||||
respond(())
|
||||
},
|
||||
webhook(cloned_bot).await,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -9,10 +9,6 @@ use tokio_stream::wrappers::UnboundedReceiverStream;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
let bot = Bot::from_env().auto_send();
|
||||
// Create a new dispatcher to handle incoming queries
|
||||
Dispatcher::new(bot)
|
||||
|
|
|
@ -19,7 +19,21 @@ use reqwest::{StatusCode, Url};
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting ngrok_ping_pong_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
||||
let cloned_bot = bot.clone();
|
||||
teloxide::repl_with_listener(
|
||||
bot,
|
||||
|message| async move {
|
||||
message.answer("pong").await?;
|
||||
respond(())
|
||||
},
|
||||
webhook(cloned_bot).await,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn handle_rejection(error: warp::Rejection) -> Result<impl warp::Reply, Infallible> {
|
||||
|
@ -67,21 +81,3 @@ pub async fn webhook(bot: AutoSend<Bot>) -> impl update_listeners::UpdateListene
|
|||
state.1.clone()
|
||||
})
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting ngrok_ping_pong_bot...");
|
||||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
||||
let cloned_bot = bot.clone();
|
||||
teloxide::repl_with_listener(
|
||||
bot,
|
||||
|message| async move {
|
||||
message.answer("pong").await?;
|
||||
respond(())
|
||||
},
|
||||
webhook(cloned_bot).await,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -27,10 +27,6 @@ type In = DialogueWithCx<AutoSend<Bot>, Message, Dialogue, StorageError>;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
let bot = Bot::from_env().auto_send();
|
||||
Dispatcher::new(bot)
|
||||
.messages_handler(DialogueDispatcher::with_storage(
|
||||
|
|
|
@ -12,10 +12,6 @@ lazy_static! {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting shared_state_bot...");
|
||||
|
||||
|
|
|
@ -37,10 +37,6 @@ async fn answer(
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
run().await;
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting simple_commands_bot...");
|
||||
|
||||
|
|
|
@ -80,10 +80,6 @@
|
|||
//!
|
||||
//! #[tokio::main]
|
||||
//! async fn main() {
|
||||
//! run().await;
|
||||
//! }
|
||||
//!
|
||||
//! async fn run() {
|
||||
//! teloxide::enable_logging!();
|
||||
//! log::info!("Starting dialogue_bot!");
|
||||
//!
|
||||
|
|
Loading…
Add table
Reference in a new issue