Created
March 10, 2020 10:49
-
-
Save optozorax/51f0b26a607721884f22abde37831d76 to your computer and use it in GitHub Desktop.
Inline sticker telegram bot teloxide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "fyass" | |
version = "0.1.0" | |
authors = ["optozorax <[email protected]>"] | |
edition = "2018" | |
[dependencies] | |
teloxide = { git = "https://github.com/teloxide/teloxide", branch = "dev" } | |
log = "0.4.8" | |
tokio = "0.2.11" | |
pretty_env_logger = "0.4.0" | |
reqwest = { verion = "*", default-features = false, features = ["socks"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use teloxide::types::*; | |
use teloxide::prelude::*; | |
#[tokio::main] | |
async fn main() { | |
teloxide::enable_logging!(); | |
log::info!("Starting ping_pong_bot!"); | |
let proxy = reqwest::Proxy::all("socks5://proxy:[email protected]:443").expect("Creating proxy"); | |
let client = reqwest::Client::builder() | |
.proxy(proxy) | |
.build() | |
.expect("creating reqwest::Client"); | |
let bot = Bot::from_env_with_client(client); | |
Dispatcher::new(bot) | |
.inline_queries_handler(|rx: DispatcherHandlerRx<InlineQuery>| { | |
rx.for_each(|message| async move { | |
let stickers = [ | |
"CAACAgIAAxkBAAMxXmdY_Ssn6E61-907MMNfVZIFd5oAAiMAA3lx3hbatLjZRpEzkRgE", | |
"CAACAgIAAxkBAAM1XmdaZcMlEDa-75LVKWwEEVeDLRkAAqAAA6tXxAtpwuGr-UylexgE", | |
"CAACAgIAAxkBAAM3Xmda0Kc4utK7UbfabZy0kVFC1pQAAvUAA3tOKhBCNQABQEpab2YYBA", | |
]; | |
message.bot.answer_inline_query(message.update.id.clone(), | |
stickers.iter().enumerate().map(|(i, x)| InlineQueryResult::CachedSticker(InlineQueryResultCachedSticker { | |
id: format!("5364356453645365345633456346543{}", i), | |
sticker_file_id: (*x).to_string(), | |
reply_markup: None, | |
input_message_content: None, | |
})).collect::<Vec<InlineQueryResult>>() | |
).send().await.log_on_error().await; | |
log::info!("inline: {:?}", message.update); | |
}) | |
}) | |
.messages_handler(|rx: DispatcherHandlerRx<Message>| { | |
rx.for_each(|message| async move { | |
log::info!("message: {:#?}", message); | |
message.answer("ну здарова").send().await.log_on_error().await; | |
}) | |
}) | |
.dispatch() | |
.await; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment