mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
commit
64b781128e
7 changed files with 94 additions and 2 deletions
|
@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [unreleased]
|
||||
|
||||
## [0.5.2] - 2021-08-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- Depend on a correct `futures` version (v0.3.15).
|
||||
|
||||
## [0.5.1] - 2021-08-05
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "teloxide"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
edition = "2018"
|
||||
description = "An elegant Telegram bots framework for Rust"
|
||||
repository = "https://github.com/teloxide/teloxide"
|
||||
|
@ -87,7 +87,7 @@ mime = "0.3"
|
|||
derive_more = "0.99"
|
||||
thiserror = "1.0"
|
||||
async-trait = "0.1"
|
||||
futures = "0.3"
|
||||
futures = "0.3.15"
|
||||
pin-project = "1.0"
|
||||
serde_with_macros = "1.4"
|
||||
|
||||
|
|
|
@ -411,6 +411,7 @@ A: Yes. You can setup any logger, for example, [fern], e.g. teloxide has no spec
|
|||
## Community bots
|
||||
Feel free to propose your own bot to our collection!
|
||||
|
||||
- [WaffleLapkin/crate_upd_bot](https://github.com/WaffleLapkin/crate_upd_bot) -- A bot that notifies about crate updates.
|
||||
- [dracarys18/grpmr-rs](https://github.com/dracarys18/grpmr-rs) -- A telegram group manager bot with variety of extra features.
|
||||
- [steadylearner/subreddit_reader](https://github.com/steadylearner/Rust-Full-Stack/tree/master/commits/teloxide/subreddit_reader) -- A bot that shows the latest posts at Rust subreddit.
|
||||
- [ArtHome12/vzmuinebot](https://github.com/ArtHome12/vzmuinebot) -- Telegram bot for food menu navigate.
|
||||
|
@ -424,6 +425,8 @@ Feel free to propose your own bot to our collection!
|
|||
- [msfjarvis/walls-bot-rs](https://github.com/msfjarvis/walls-bot-rs) -- Telegram bot for my wallpapers collection, in Rust.
|
||||
- [MustafaSalih1993/Miss-Vodka-Telegram-Bot](https://github.com/MustafaSalih1993/Miss-Vodka-Telegram-Bot) -- A telegram bot written in rust using "Teloxide" library.
|
||||
- [x13a/tg-prompt](https://github.com/x13a/tg-prompt) -- Telegram prompt.
|
||||
- [magnickolas/remindee-bot](https://github.com/magnickolas/remindee-bot) -- Telegram bot for managing reminders.
|
||||
- [cyberknight777/knight-bot](https://gitlab.com/cyberknight777/knight-bot) -- A telegram bot with variety of fun features.
|
||||
|
||||
## Contributing
|
||||
See [CONRIBUTING.md](https://github.com/teloxide/teloxide/blob/master/CONTRIBUTING.md).
|
||||
|
|
14
examples/inline_bot/Cargo.toml
Normal file
14
examples/inline_bot/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "inline_bot"
|
||||
version = "0.1.0"
|
||||
authors = ["Colin Diener <colin@colind.me>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
teloxide = { path = "../../", features = ["macros", "auto-send"] }
|
||||
log = "0.4.8"
|
||||
pretty_env_logger = "0.4.0"
|
||||
tokio = { version = "1.3.0", features = ["rt-multi-thread", "macros"] }
|
||||
tokio-stream = "0.1.3"
|
65
examples/inline_bot/src/main.rs
Normal file
65
examples/inline_bot/src/main.rs
Normal file
|
@ -0,0 +1,65 @@
|
|||
use teloxide::{
|
||||
prelude::*,
|
||||
types::{
|
||||
InlineQueryResult, InlineQueryResultArticle, InputMessageContent, InputMessageContentText,
|
||||
},
|
||||
Bot,
|
||||
};
|
||||
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)
|
||||
.inline_queries_handler(|rx: DispatcherHandlerRx<AutoSend<Bot>, InlineQuery>| {
|
||||
UnboundedReceiverStream::new(rx).for_each_concurrent(None, |query| async move {
|
||||
// First, create your actual response
|
||||
let google_search = InlineQueryResultArticle::new(
|
||||
// Each item needs a unique ID, as well as the response container for the items.
|
||||
// These can be whatever, as long as they don't conflict.
|
||||
"01".to_string(),
|
||||
// What the user will actually see
|
||||
"Google Search",
|
||||
// What message will be sent when clicked/tapped
|
||||
InputMessageContent::Text(InputMessageContentText::new(format!(
|
||||
"https://www.google.com/search?q={}",
|
||||
query.update.query,
|
||||
))),
|
||||
);
|
||||
// While constructing them from the struct itself is possible, it is preferred to use
|
||||
// the builder pattern if you wish to add more information to your result.
|
||||
// Please refer to the documentation for more detailed information about each field.
|
||||
// https://docs.rs/teloxide/latest/teloxide/types/struct.InlineQueryResultArticle.html
|
||||
let ddg_search = InlineQueryResultArticle::new(
|
||||
"02".to_string(),
|
||||
"DuckDuckGo Search".to_string(),
|
||||
InputMessageContent::Text(InputMessageContentText::new(format!(
|
||||
"https://duckduckgo.com/?q={}",
|
||||
query.update.query.to_string()
|
||||
))),
|
||||
)
|
||||
.description("DuckDuckGo Search")
|
||||
.thumb_url("https://duckduckgo.com/assets/logo_header.v108.png")
|
||||
.url("https://duckduckgo.com/about"); // Note: This is the url that will open if they click the thumbnail
|
||||
|
||||
let results = vec![
|
||||
InlineQueryResult::Article(google_search),
|
||||
InlineQueryResult::Article(ddg_search),
|
||||
];
|
||||
|
||||
// Send it off! One thing to note -- the ID we use here must be of the query we're responding to.
|
||||
let response =
|
||||
query.requester.answer_inline_query(&query.update.id, results).send().await;
|
||||
if let Err(err) = response {
|
||||
log::error!("Error in handler: {:?}", err);
|
||||
}
|
||||
})
|
||||
})
|
||||
.dispatch()
|
||||
.await;
|
||||
}
|
|
@ -66,6 +66,8 @@ where
|
|||
.await?;
|
||||
|
||||
if let redis::Value::Bulk(values) = deleted_rows_count {
|
||||
// False positive
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let redis::Value::Int(deleted_rows_count) = values[0] {
|
||||
match deleted_rows_count {
|
||||
0 => return Err(RedisStorageError::DialogueNotFound),
|
||||
|
|
|
@ -311,6 +311,8 @@ where
|
|||
tokio::pin!(stream);
|
||||
|
||||
loop {
|
||||
// False positive
|
||||
#[allow(clippy::collapsible_match)]
|
||||
if let Ok(upd) = timeout(shutdown_check_timeout, stream.next()).await {
|
||||
match upd {
|
||||
None => break,
|
||||
|
|
Loading…
Reference in a new issue