mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Update README.md
This commit is contained in:
parent
a01a7b959a
commit
57e5469a3c
1 changed files with 5 additions and 3 deletions
|
@ -35,6 +35,8 @@ tokio = "0.2.11"
|
|||
```
|
||||
|
||||
## The ping-pong bot
|
||||
This bot has a single handler, which answers "pong" on each incoming message:
|
||||
|
||||
```rust
|
||||
use teloxide::prelude::*;
|
||||
|
||||
|
@ -44,11 +46,11 @@ async fn main() {
|
|||
}
|
||||
|
||||
async fn run() {
|
||||
let bot = Bot::from_env().enable_logging(crate_name!()).build();
|
||||
teloxide::enable_logging!();
|
||||
log::info!("Starting ping_pong_bot!");
|
||||
|
||||
// Create a dispatcher with a single message handler that answers "pong" to
|
||||
// each incoming message.
|
||||
let bot = Bot::from_env();
|
||||
|
||||
Dispatcher::<RequestError>::new(bot)
|
||||
.message_handler(&|ctx: DispatcherHandlerCtx<Message>| async move {
|
||||
ctx.answer("pong").send().await?;
|
||||
|
|
Loading…
Reference in a new issue