upgrade teloxide

This commit is contained in:
ihciah 2022-06-18 21:13:45 +08:00
parent cb574b9f76
commit e7a5ad13af
No known key found for this signature in database
GPG Key ID: 97CE6E121061F3BA
5 changed files with 46 additions and 171 deletions

185
Cargo.lock generated
View File

@ -12,12 +12,6 @@ dependencies = [
"wasm-timer",
]
[[package]]
name = "ahash"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217"
[[package]]
name = "ahash"
version = "0.7.6"
@ -66,17 +60,6 @@ dependencies = [
"syn",
]
[[package]]
name = "async-trait"
version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "atty"
version = "0.2.14"
@ -108,7 +91,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bot"
version = "0.1.3"
version = "0.1.4"
dependencies = [
"anyhow",
"clap",
@ -145,12 +128,6 @@ version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -206,15 +183,6 @@ dependencies = [
"os_str_bytes",
]
[[package]]
name = "cloudabi"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
dependencies = [
"bitflags",
]
[[package]]
name = "cloudflare-kv-proxy"
version = "0.1.3"
@ -265,32 +233,6 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "crossbeam-epoch"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
dependencies = [
"autocfg",
"cfg-if 0.1.10",
"crossbeam-utils",
"lazy_static",
"maybe-uninit",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg",
"cfg-if 0.1.10",
"lazy_static",
]
[[package]]
name = "darling"
version = "0.13.4"
@ -341,9 +283,9 @@ dependencies = [
[[package]]
name = "dptree"
version = "0.1.2"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7fcc437df15b844a38de424170425a6e8b52c79e22364fec6133bcdf18c0abd"
checksum = "90018d2d80bd5c16aaa022271b2747ea8d461a21934c79404c26f568b60cca3d"
dependencies = [
"futures",
]
@ -390,7 +332,7 @@ version = "0.8.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
]
[[package]]
@ -432,18 +374,6 @@ dependencies = [
"instant",
]
[[package]]
name = "flurry"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c0a35f7b50e99185a2825541946252f669f3c3ca77801357cd682a1b356bb3e"
dependencies = [
"ahash 0.3.8",
"crossbeam-epoch",
"num_cpus",
"parking_lot 0.10.2",
]
[[package]]
name = "fnv"
version = "1.0.7"
@ -570,7 +500,7 @@ version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
@ -581,7 +511,7 @@ version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
]
@ -623,7 +553,7 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash 0.7.6",
"ahash",
]
[[package]]
@ -632,7 +562,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
dependencies = [
"ahash 0.7.6",
"ahash",
]
[[package]]
@ -785,7 +715,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
]
[[package]]
@ -836,15 +766,6 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
name = "lock_api"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75"
dependencies = [
"scopeguard",
]
[[package]]
name = "lock_api"
version = "0.4.7"
@ -861,7 +782,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
]
[[package]]
@ -870,27 +791,12 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memoffset"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa"
dependencies = [
"autocfg",
]
[[package]]
name = "mime"
version = "0.3.16"
@ -994,7 +900,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
@ -1038,16 +944,6 @@ version = "6.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
[[package]]
name = "parking_lot"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
dependencies = [
"lock_api 0.3.4",
"parking_lot_core 0.7.2",
]
[[package]]
name = "parking_lot"
version = "0.11.2"
@ -1055,7 +951,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
dependencies = [
"instant",
"lock_api 0.4.7",
"lock_api",
"parking_lot_core 0.8.5",
]
@ -1065,34 +961,20 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"lock_api 0.4.7",
"lock_api",
"parking_lot_core 0.9.3",
]
[[package]]
name = "parking_lot_core"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
dependencies = [
"cfg-if 0.1.10",
"cloudabi",
"libc",
"redox_syscall 0.1.57",
"smallvec",
"winapi",
]
[[package]]
name = "parking_lot_core"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"instant",
"libc",
"redox_syscall 0.2.13",
"redox_syscall",
"smallvec",
"winapi",
]
@ -1103,9 +985,9 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"libc",
"redox_syscall 0.2.13",
"redox_syscall",
"smallvec",
"windows-sys",
]
@ -1282,12 +1164,6 @@ dependencies = [
"erasable",
]
[[package]]
name = "redox_syscall"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]]
name = "redox_syscall"
version = "0.2.13"
@ -1644,16 +1520,14 @@ checksum = "20f34339676cdcab560c9a82300c4c2581f68b9369aedf0fae86f2ff9565ff3e"
[[package]]
name = "teloxide"
version = "0.7.3"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e0471ee22325fa9d4d0574afb21104c28466dbd02495dbd5fef2d431c58c7a5"
checksum = "b30e69ea9f7aa110a028bdaa9965fac98270aadce592aa854822a4f04d3b197e"
dependencies = [
"aquamarine",
"async-trait",
"bytes",
"derive_more",
"dptree",
"flurry",
"futures",
"log",
"mime",
@ -1667,13 +1541,14 @@ dependencies = [
"tokio",
"tokio-stream",
"tokio-util 0.6.10",
"url",
]
[[package]]
name = "teloxide-core"
version = "0.4.5"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc4d7ef8a6e39097e49a2481169fa9fc0ff627d8321a7ab52cf6d5ac47850fff"
checksum = "08f534b85075f00cae7857f99e78146464b88b04c05aae30a6deb75fec49b9d9"
dependencies = [
"bitflags",
"bytes",
@ -1702,9 +1577,9 @@ dependencies = [
[[package]]
name = "teloxide-macros"
version = "0.5.1"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d08322f107110dc4aadf5683bf19df9340eebc567529def2d17c830de198a58"
checksum = "d01426e8e52631fc7c766f03896c04f89264048981d106aafd20479d8b99e103"
dependencies = [
"heck",
"proc-macro2",
@ -1718,10 +1593,10 @@ version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"fastrand",
"libc",
"redox_syscall 0.2.13",
"redox_syscall",
"remove_dir_all",
"winapi",
]
@ -1906,7 +1781,7 @@ version = "0.1.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
@ -2043,7 +1918,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f44ef1afcf5979e34748c12595f9589f3dc4e34abf156fb6d95f9b835568dc"
dependencies = [
"anyhow",
"cfg-if 1.0.0",
"cfg-if",
"enum-iterator",
"getset",
"rustc_version",
@ -2086,7 +1961,7 @@ version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"wasm-bindgen-macro",
]
@ -2111,7 +1986,7 @@ version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",

View File

@ -1,20 +1,20 @@
[package]
edition = "2021"
name = "bot"
version = "0.1.3"
version = "0.1.4"
[dependencies]
eh2telegraph = {path = "../eh2telegraph"}
anyhow = "1"
clap = {version = "3", features = ["derive"]}
dptree = "0.1"
dptree = "0.2"
once_cell = "1"
regex = "1"
reqwest = {version = "0.11", default-features = false, features = ["json", "multipart", "rustls-tls"]}
serde = {version = "1", features = ["derive"]}
singleflight-async = {version = "0.1", features = ["hardware-lock-elision"]}
teloxide = {version = "0.7", features = ["macros", "ctrlc_handler", "dispatching2", "auto-send"]}
teloxide = {version = "0.9", features = ["macros", "ctrlc_handler", "auto-send"]}
time = {version = "0.3", features = ["local-offset", "std", "macros"]}
tokio = {version = "1", default-features = false, features = ["rt-multi-thread", "macros", "net", "sync", "time", "parking_lot"]}
tracing = "0.1"

View File

@ -14,9 +14,9 @@ use eh2telegraph::{
use reqwest::Url;
use teloxide::{
adaptors::DefaultParseMode,
prelude2::*,
prelude::*,
utils::{
command::BotCommand,
command::BotCommands,
markdown::{code_inline, escape, link},
},
};
@ -27,7 +27,7 @@ use crate::{ok_or_break, util::PrettyChat};
const MIN_SIMILARITY: u8 = 70;
const MIN_SIMILARITY_PRIVATE: u8 = 50;
#[derive(BotCommand, Clone)]
#[derive(BotCommands, Clone)]
#[command(
rename = "lowercase",
description = "\
@ -55,7 +55,7 @@ pub enum Command {
Sync(String),
}
#[derive(BotCommand, Clone)]
#[derive(BotCommands, Clone)]
#[command(rename = "lowercase", description = "Command for admins")]
pub enum AdminCommand {
#[command(description = "Delete cache with given key.")]
@ -96,7 +96,7 @@ where
match command {
Command::Help => {
let _ = bot
.send_message(msg.chat.id, escape(&Command::descriptions()))
.send_message(msg.chat.id, escape(&Command::descriptions().to_string()))
.reply_to_message_id(msg.id)
.await;
}

View File

@ -15,7 +15,7 @@ use teloxide::{
adaptors::DefaultParseMode,
dispatching::update_listeners,
error_handlers::IgnoringErrorHandler,
prelude2::*,
prelude::*,
types::{AllowedUpdate, ChatPermissions, ParseMode, UpdateKind},
};
@ -143,7 +143,7 @@ async fn main() {
.branch(
dptree::entry()
.chain(dptree::filter(move |message: Message| {
handler.admins.contains(&message.chat.id)
handler.admins.contains(&message.chat.id.0)
}))
.filter_command::<AdminCommand>()
.branch(wrap_endpoint(admin_command_handler)),

View File

@ -1,6 +1,6 @@
use std::{convert::Infallible, ops::ControlFlow, sync::Arc};
use dptree::{di::Injectable, from_fn, Handler};
use dptree::{di::Injectable, from_fn_with_description, Handler, HandlerDescription};
pub struct PrettyChat<'a>(pub &'a teloxide::types::Chat);
@ -30,19 +30,19 @@ impl<'a> std::fmt::Debug for PrettyChat<'a> {
}
}
pub fn wrap_endpoint<'a, F, Input, Output, FnArgs>(
pub fn wrap_endpoint<'a, F, Input, Output, FnArgs, Descr>(
f: F,
) -> Handler<'a, Input, Result<Output, Infallible>, Infallible>
) -> Handler<'a, Input, Result<Output, Infallible>, Descr>
where
F: Injectable<Input, ControlFlow<Output>, FnArgs> + Send + Sync + 'a,
Input: Send + Sync + 'a,
Output: Send + Sync + 'a,
Descr: HandlerDescription,
F: Injectable<Input, ControlFlow<Output>, FnArgs> + Send + Sync + 'a,
{
let f = Arc::new(f);
from_fn(move |event, _cont| {
from_fn_with_description(Descr::endpoint(), move |event, _cont| {
let f = Arc::clone(&f);
async move {
let f = f.inject(&event);
let cf = f().await;