Update README.md

This commit is contained in:
Temirkhan Myrzamadi 2020-02-13 23:07:28 +06:00 committed by GitHub
parent a01a7b959a
commit 57e5469a3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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?;