mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 23:57:38 +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
|
## The ping-pong bot
|
||||||
|
This bot has a single handler, which answers "pong" on each incoming message:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use teloxide::prelude::*;
|
use teloxide::prelude::*;
|
||||||
|
|
||||||
|
@ -44,11 +46,11 @@ async fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn run() {
|
async fn run() {
|
||||||
let bot = Bot::from_env().enable_logging(crate_name!()).build();
|
teloxide::enable_logging!();
|
||||||
log::info!("Starting ping_pong_bot!");
|
log::info!("Starting ping_pong_bot!");
|
||||||
|
|
||||||
// Create a dispatcher with a single message handler that answers "pong" to
|
let bot = Bot::from_env();
|
||||||
// each incoming message.
|
|
||||||
Dispatcher::<RequestError>::new(bot)
|
Dispatcher::<RequestError>::new(bot)
|
||||||
.message_handler(&|ctx: DispatcherHandlerCtx<Message>| async move {
|
.message_handler(&|ctx: DispatcherHandlerCtx<Message>| async move {
|
||||||
ctx.answer("pong").send().await?;
|
ctx.answer("pong").send().await?;
|
||||||
|
|
Loading…
Add table
Reference in a new issue