Crates.io | teloxide-listener |
lib.rs | teloxide-listener |
version | 0.1.0-beta.1 |
source | src |
created_at | 2022-03-11 03:21:34.607671 |
updated_at | 2022-03-11 03:21:34.607671 |
description | A listener extension for teloxide |
homepage | |
repository | https://github.com/PhotonQuantum/teloxide-listener |
max_upload_size | |
id | 547977 |
size | 17,071 |
A listener extension for teloxide.
Currently supports the following modes:
polling
webhook
(axum, need to be enabled by feature flag)Construct a Listener
builder, build it, and pass it to with_listener
versions of teloxide functions (e.g., repl_with_listener
).
There are two ways to construct a Listener
builder.
Listener::from_env
can be used to construct a Listener
from environment variables.
If compiled with webhook
feature enabled, it tries to read TELOXIDE_WEBHOOK_URL
, TELOXIDE_WEBHOOK_PATH
, and TELOXIDE_BIND_ADDR
to build a webhook updates listener first.
Otherwise, it falls back to long polling updates listener.
To customize the TELOXIDE_
prefix, use Listener::from_env_with_prefix
.
Listener
manuallyListener::Polling
- a long polling updates listener.Listener::Webhook
- a webhook updates listener.use teloxide_listener::Listener;
let listener = Listener::from_env().build(bot.clone());
teloxide::repls2::repl_with_listener(
bot,
|msg: Message, bot: Bot| async move {
bot.send_message(msg.chat.id, "pong").send().await?;
respond(())
},
listener,
)
This project is licensed under the MIT license.