Update to Tokio 1 and Serenity 0.10 (#9)

This commit is contained in:
Natsu Kagami 2021-01-15 18:50:33 +00:00 committed by GitHub
parent 40f6c6e553
commit 901d55814d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 238 additions and 281 deletions

414
Cargo.lock generated
View file

@ -16,15 +16,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
[[package]]
name = "ahash"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217"
dependencies = [
"const-random",
]
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.7.13" version = "0.7.13"
@ -53,9 +44,9 @@ dependencies = [
[[package]] [[package]]
name = "async-tungstenite" name = "async-tungstenite"
version = "0.9.3" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce503a5cb1e7450af7d211b86b84807791b251f335b2f43f1e26b85a416f315" checksum = "f7cc5408453d37e2b1c6f01d8078af1da58b6cfa6a80fa2ede3bd2b9a6ada9c4"
dependencies = [ dependencies = [
"futures-io", "futures-io",
"futures-util", "futures-util",
@ -75,7 +66,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi",
"libc", "libc",
"winapi 0.3.9", "winapi",
] ]
[[package]] [[package]]
@ -129,6 +120,12 @@ version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
[[package]]
name = "bytes"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.59" version = "1.0.59"
@ -141,6 +138,12 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.15" version = "0.4.15"
@ -155,48 +158,28 @@ dependencies = [
[[package]] [[package]]
name = "codeforces" name = "codeforces"
version = "0.2.1" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07443ebea310b4bbfd0c9ee79d25cf678fa1e7c82916bb32307af7a7ef1fe600" checksum = "7df54b4689d51d58162c8b76a642ba44d6128b68f29c3fbc23815e6ea4bfef15"
dependencies = [ dependencies = [
"futures-timer",
"futures-util", "futures-util",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"tokio",
] ]
[[package]] [[package]]
name = "command_attr" name = "command_attr"
version = "0.3.1" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dc8da29004a4dd9b89d21b2e17ccd372c1ff085bdab9e22b989096db1289d01" checksum = "ef54b146e4ff8a036b9d632fd48c183c9757992535e5f557275f4a01dfd9c7c7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn",
] ]
[[package]]
name = "const-random"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a"
dependencies = [
"const-random-macro",
"proc-macro-hack",
]
[[package]]
name = "const-random-macro"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a"
dependencies = [
"getrandom",
"proc-macro-hack",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.7.0" version = "0.7.0"
@ -225,17 +208,16 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
] ]
[[package]] [[package]]
name = "dashmap" name = "dashmap"
version = "3.11.10" version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f260e2fc850179ef410018660006951c1b55b79e8087e87111a2c388994b9b5" checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c"
dependencies = [ dependencies = [
"ahash", "cfg-if 1.0.0",
"cfg-if",
"num_cpus", "num_cpus",
] ]
@ -266,7 +248,7 @@ version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2" checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
] ]
[[package]] [[package]]
@ -288,7 +270,7 @@ version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"crc32fast", "crc32fast",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
@ -296,12 +278,14 @@ dependencies = [
[[package]] [[package]]
name = "flume" name = "flume"
version = "0.9.0" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f7d4f1d85cb8cafb73c01d872e0124a96e603f5b7633ce1eac70015f066e946" checksum = "0362ef9c4c1fa854ff95b4cb78045a86e810d804dc04937961988b45427104a9"
dependencies = [ dependencies = [
"futures", "futures-core",
"rand", "futures-sink",
"nanorand",
"pin-project 1.0.2",
"spinning_top", "spinning_top",
] ]
@ -327,21 +311,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]] [[package]]
name = "fuchsia-zircon" name = "form_urlencoded"
version = "0.3.3" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00"
dependencies = [ dependencies = [
"bitflags", "matches",
"fuchsia-zircon-sys", "percent-encoding",
] ]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.5" version = "0.3.5"
@ -405,12 +383,6 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "futures-timer"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
[[package]] [[package]]
name = "futures-util" name = "futures-util"
version = "0.3.5" version = "0.3.5"
@ -447,18 +419,31 @@ version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"wasi 0.9.0+wasi-snapshot-preview1", "wasi 0.9.0+wasi-snapshot-preview1",
] ]
[[package]] [[package]]
name = "h2" name = "getrandom"
version = "0.2.6" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6"
dependencies = [ dependencies = [
"bytes", "cfg-if 1.0.0",
"js-sys",
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
"wasm-bindgen",
]
[[package]]
name = "h2"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5"
dependencies = [
"bytes 1.0.1",
"fnv", "fnv",
"futures-core", "futures-core",
"futures-sink", "futures-sink",
@ -469,6 +454,7 @@ dependencies = [
"tokio", "tokio",
"tokio-util", "tokio-util",
"tracing", "tracing",
"tracing-futures",
] ]
[[package]] [[package]]
@ -492,18 +478,18 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9"
dependencies = [ dependencies = [
"bytes", "bytes 0.5.6",
"fnv", "fnv",
"itoa", "itoa",
] ]
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "0.3.1" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994"
dependencies = [ dependencies = [
"bytes", "bytes 1.0.1",
"http", "http",
] ]
@ -513,6 +499,12 @@ version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9"
[[package]]
name = "httpdate"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47"
[[package]] [[package]]
name = "humantime" name = "humantime"
version = "1.3.0" version = "1.3.0"
@ -524,11 +516,11 @@ dependencies = [
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.13.7" version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e68a8dd9716185d9e64ea473ea6ef63529252e3e27623295a0378a19665d5eb" checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe"
dependencies = [ dependencies = [
"bytes", "bytes 1.0.1",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
@ -536,10 +528,10 @@ dependencies = [
"http", "http",
"http-body", "http-body",
"httparse", "httparse",
"httpdate",
"itoa", "itoa",
"pin-project 0.4.23", "pin-project 1.0.2",
"socket2", "socket2",
"time",
"tokio", "tokio",
"tower-service", "tower-service",
"tracing", "tracing",
@ -548,11 +540,10 @@ dependencies = [
[[package]] [[package]]
name = "hyper-rustls" name = "hyper-rustls"
version = "0.21.0" version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37743cc83e8ee85eacfce90f2f4102030d9ff0a95244098d781e9bee4a90abb6" checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64"
dependencies = [ dependencies = [
"bytes",
"futures-util", "futures-util",
"hyper", "hyper",
"log", "log",
@ -564,15 +555,15 @@ dependencies = [
[[package]] [[package]]
name = "hyper-tls" name = "hyper-tls"
version = "0.4.3" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [ dependencies = [
"bytes", "bytes 1.0.1",
"hyper", "hyper",
"native-tls", "native-tls",
"tokio", "tokio",
"tokio-tls", "tokio-native-tls",
] ]
[[package]] [[package]]
@ -602,16 +593,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19a8a95243d5a0398cae618ec29477c6e3cb631152be5c19481f80bc71559754" checksum = "19a8a95243d5a0398cae618ec29477c6e3cb631152be5c19481f80bc71559754"
dependencies = [ dependencies = [
"bytes", "bytes 0.5.6",
]
[[package]]
name = "iovec"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
dependencies = [
"libc",
] ]
[[package]] [[package]]
@ -635,16 +617,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@ -678,7 +650,7 @@ version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
] ]
[[package]] [[package]]
@ -721,33 +693,34 @@ dependencies = [
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.6.22" version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7"
dependencies = [ dependencies = [
"cfg-if",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
"kernel32-sys",
"libc", "libc",
"log", "log",
"miow", "miow",
"net2", "ntapi",
"slab", "winapi",
"winapi 0.2.8",
] ]
[[package]] [[package]]
name = "miow" name = "miow"
version = "0.2.1" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897"
dependencies = [ dependencies = [
"kernel32-sys", "socket2",
"net2", "winapi",
"winapi 0.2.8", ]
"ws2_32-sys",
[[package]]
name = "nanorand"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac1378b66f7c93a1c0f8464a19bf47df8795083842e5090f4b7305973d5a22d0"
dependencies = [
"getrandom 0.2.1",
] ]
[[package]] [[package]]
@ -769,14 +742,12 @@ dependencies = [
] ]
[[package]] [[package]]
name = "net2" name = "ntapi"
version = "0.2.35" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [ dependencies = [
"cfg-if", "winapi",
"libc",
"winapi 0.3.9",
] ]
[[package]] [[package]]
@ -827,7 +798,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4" checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if 0.1.10",
"foreign-types", "foreign-types",
"lazy_static", "lazy_static",
"libc", "libc",
@ -912,9 +883,9 @@ dependencies = [
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.1.7" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
@ -976,7 +947,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [ dependencies = [
"getrandom", "getrandom 0.1.15",
"libc", "libc",
"rand_chacha", "rand_chacha",
"rand_core", "rand_core",
@ -999,7 +970,7 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [ dependencies = [
"getrandom", "getrandom 0.1.15",
] ]
[[package]] [[package]]
@ -1041,17 +1012,17 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [ dependencies = [
"winapi 0.3.9", "winapi",
] ]
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.10.8" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9eaa17ac5d7b838b7503d118fa16ad88f440498bf9ffe5424e621f93190d61e" checksum = "fd281b1030aa675fb90aa994d07187645bb3c8fc756ca766e7c3070b439de9de"
dependencies = [ dependencies = [
"base64 0.12.3", "base64 0.13.0",
"bytes", "bytes 1.0.1",
"encoding_rs", "encoding_rs",
"futures-core", "futures-core",
"futures-util", "futures-util",
@ -1074,13 +1045,13 @@ dependencies = [
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"tokio", "tokio",
"tokio-native-tls",
"tokio-rustls", "tokio-rustls",
"tokio-tls",
"url", "url",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
"webpki-roots 0.19.0", "webpki-roots 0.21.0",
"winreg", "winreg",
] ]
@ -1096,7 +1067,7 @@ dependencies = [
"spin", "spin",
"untrusted", "untrusted",
"web-sys", "web-sys",
"winapi 0.3.9", "winapi",
] ]
[[package]] [[package]]
@ -1113,11 +1084,11 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.18.1" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b"
dependencies = [ dependencies = [
"base64 0.12.3", "base64 0.13.0",
"log", "log",
"ring", "ring",
"sct", "sct",
@ -1137,7 +1108,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"winapi 0.3.9", "winapi",
] ]
[[package]] [[package]]
@ -1212,14 +1183,14 @@ dependencies = [
[[package]] [[package]]
name = "serde_urlencoded" name = "serde_urlencoded"
version = "0.6.1" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9"
dependencies = [ dependencies = [
"dtoa", "form_urlencoded",
"itoa", "itoa",
"ryu",
"serde", "serde",
"url",
] ]
[[package]] [[package]]
@ -1236,19 +1207,20 @@ dependencies = [
[[package]] [[package]]
name = "serenity" name = "serenity"
version = "0.9.1" version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fbd2938b8859261d418ba8325a795000e37e9cba1b19d4e978775c5e34dc997" checksum = "4dac8367ecfd3380c00dcedf5eb9a47888ae74ae391419b5b1f7735895ed8df4"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"async-tungstenite", "async-tungstenite",
"base64 0.13.0", "base64 0.13.0",
"bitflags", "bitflags",
"bytes", "bytes 1.0.1",
"chrono", "chrono",
"command_attr", "command_attr",
"flate2", "flate2",
"futures", "futures",
"percent-encoding",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
@ -1268,7 +1240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770" checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770"
dependencies = [ dependencies = [
"block-buffer", "block-buffer",
"cfg-if", "cfg-if 0.1.10",
"cpuid-bool", "cpuid-bool",
"digest", "digest",
"opaque-debug", "opaque-debug",
@ -1282,14 +1254,13 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.3.15" version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"redox_syscall", "winapi",
"winapi 0.3.9",
] ]
[[package]] [[package]]
@ -1330,12 +1301,12 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"rand", "rand",
"redox_syscall", "redox_syscall",
"remove_dir_all", "remove_dir_all",
"winapi 0.3.9", "winapi",
] ]
[[package]] [[package]]
@ -1384,7 +1355,7 @@ checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [ dependencies = [
"libc", "libc",
"wasi 0.10.0+wasi-snapshot-preview1", "wasi 0.10.0+wasi-snapshot-preview1",
"winapi 0.3.9", "winapi",
] ]
[[package]] [[package]]
@ -1395,27 +1366,25 @@ checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "0.2.22" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" checksum = "0ca04cec6ff2474c638057b65798f60ac183e5e79d3448bb7163d36a39cff6ec"
dependencies = [ dependencies = [
"bytes", "autocfg",
"fnv", "bytes 1.0.1",
"futures-core", "libc",
"iovec",
"lazy_static",
"memchr", "memchr",
"mio", "mio",
"num_cpus",
"pin-project-lite", "pin-project-lite",
"slab",
"tokio-macros", "tokio-macros",
] ]
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "0.2.5" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" checksum = "42517d2975ca3114b22a16192634e8241dc5cc1f130be194645970cc1c371494"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1423,39 +1392,50 @@ dependencies = [
] ]
[[package]] [[package]]
name = "tokio-rustls" name = "tokio-native-tls"
version = "0.14.1" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
dependencies = [
"futures-core",
"rustls",
"tokio",
"webpki",
]
[[package]]
name = "tokio-tls"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343"
dependencies = [ dependencies = [
"native-tls", "native-tls",
"tokio", "tokio",
] ]
[[package]] [[package]]
name = "tokio-util" name = "tokio-rustls"
version = "0.3.1" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
dependencies = [ dependencies = [
"bytes", "rustls",
"tokio",
"webpki",
]
[[package]]
name = "tokio-stream"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76066865172052eb8796c686f0b441a93df8b08d40a950b062ffb9a426f00edd"
dependencies = [
"futures-core",
"pin-project-lite",
"tokio",
]
[[package]]
name = "tokio-util"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ae4751faa60b9f96dd8344d74592e5a17c0c9a220413dbc6942d14139bbfcc"
dependencies = [
"bytes 1.0.1",
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"log", "log",
"pin-project-lite", "pin-project-lite",
"tokio", "tokio",
"tokio-stream",
] ]
[[package]] [[package]]
@ -1470,8 +1450,7 @@ version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c" checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"log",
"tracing-attributes", "tracing-attributes",
"tracing-core", "tracing-core",
] ]
@ -1520,7 +1499,7 @@ checksum = "f0308d80d86700c5878b9ef6321f020f29b1bb9d5ff3cab25e75e23f3a492a23"
dependencies = [ dependencies = [
"base64 0.12.3", "base64 0.12.3",
"byteorder", "byteorder",
"bytes", "bytes 0.5.6",
"http", "http",
"httparse", "httparse",
"input_buffer", "input_buffer",
@ -1584,10 +1563,11 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]] [[package]]
name = "url" name = "url"
version = "2.1.1" version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e"
dependencies = [ dependencies = [
"form_urlencoded",
"idna", "idna",
"matches", "matches",
"percent-encoding", "percent-encoding",
@ -1645,7 +1625,7 @@ version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"serde", "serde",
"serde_json", "serde_json",
"wasm-bindgen-macro", "wasm-bindgen-macro",
@ -1672,7 +1652,7 @@ version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@ -1727,15 +1707,6 @@ dependencies = [
"untrusted", "untrusted",
] ]
[[package]]
name = "webpki-roots"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8eff4b7516a57307f9349c64bf34caa34b940b66fed4b2fb3136cb7386e5739"
dependencies = [
"webpki",
]
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.20.0" version = "0.20.0"
@ -1746,10 +1717,13 @@ dependencies = [
] ]
[[package]] [[package]]
name = "winapi" name = "webpki-roots"
version = "0.2.8" version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" checksum = "82015b7e0b8bad8185994674a13a93306bea76cf5a16c5a181382fd3a5ec2376"
dependencies = [
"webpki",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
@ -1761,12 +1735,6 @@ dependencies = [
"winapi-x86_64-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu",
] ]
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
[[package]] [[package]]
name = "winapi-i686-pc-windows-gnu" name = "winapi-i686-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
@ -1779,7 +1747,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [ dependencies = [
"winapi 0.3.9", "winapi",
] ]
[[package]] [[package]]
@ -1794,17 +1762,7 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
dependencies = [ dependencies = [
"winapi 0.3.9", "winapi",
]
[[package]]
name = "ws2_32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
dependencies = [
"winapi 0.2.8",
"winapi-build",
] ]
[[package]] [[package]]

View file

@ -7,15 +7,15 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
tokio = { version = "0.2", features = ["time"] } tokio = { version = "1", features = ["time"] }
reqwest = "0.10.1" reqwest = "0.11"
serenity = "0.9" serenity = "0.10"
Inflector = "0.11" Inflector = "0.11"
codeforces = "0.2.1" codeforces = "0.3"
regex = "1" regex = "1"
lazy_static = "1" lazy_static = "1"
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
dashmap = "3.11.4" dashmap = "4"
youmubot-prelude = { path = "../youmubot-prelude" } youmubot-prelude = { path = "../youmubot-prelude" }
youmubot-db = { path = "../youmubot-db" } youmubot-db = { path = "../youmubot-db" }

View file

@ -96,11 +96,7 @@ async fn update_user(
e.content(format!("Rating change for {}!", user_id.mention())) e.content(format!("Rating change for {}!", user_id.mention()))
.embed(|c| { .embed(|c| {
crate::embed::rating_change_embed( crate::embed::rating_change_embed(
&rc, &rc, &info, &contest, user_id, c,
&info,
&contest,
&user_id.mention(),
c,
) )
}) })
}) })

View file

@ -2,6 +2,7 @@ use codeforces::{Contest, RatingChange, User};
use inflector::Inflector; use inflector::Inflector;
use serenity::{builder::CreateEmbed, utils::MessageBuilder}; use serenity::{builder::CreateEmbed, utils::MessageBuilder};
use std::borrow::Borrow; use std::borrow::Borrow;
use youmubot_prelude::*;
fn unwrap_or_ref<'a, T: ?Sized, B: Borrow<T>>(opt: &'a Option<B>, default: &'a T) -> &'a T { fn unwrap_or_ref<'a, T: ?Sized, B: Borrow<T>>(opt: &'a Option<B>, default: &'a T) -> &'a T {
opt.as_ref().map(|v| v.borrow()).unwrap_or(default) opt.as_ref().map(|v| v.borrow()).unwrap_or(default)
@ -59,14 +60,14 @@ pub fn rating_change_embed<'a>(
rating_change: &RatingChange, rating_change: &RatingChange,
user: &User, user: &User,
contest: &Contest, contest: &Contest,
tag: &str, user_id: serenity::model::id::UserId,
e: &'a mut CreateEmbed, e: &'a mut CreateEmbed,
) -> &'a mut CreateEmbed { ) -> &'a mut CreateEmbed {
let delta = (rating_change.new_rating as i64) - (rating_change.old_rating as i64); let delta = (rating_change.new_rating as i64) - (rating_change.old_rating as i64);
let color = if delta < 0 { 0xff0000 } else { 0x00ff00 }; let color = if delta < 0 { 0xff0000 } else { 0x00ff00 };
let message = if delta > 0 { let message = if delta > 0 {
MessageBuilder::new() MessageBuilder::new()
.push(tag) .push(user_id.mention())
.push(" competed in ") .push(" competed in ")
.push_bold_safe(&contest.name) .push_bold_safe(&contest.name)
.push(", gaining ") .push(", gaining ")
@ -77,7 +78,7 @@ pub fn rating_change_embed<'a>(
.build() .build()
} else { } else {
MessageBuilder::new() MessageBuilder::new()
.push(tag) .push(user_id.mention())
.push(" competed in ") .push(" competed in ")
.push_bold_safe(&contest.name) .push_bold_safe(&contest.name)
.push(", but lost ") .push(", but lost ")

View file

@ -33,8 +33,7 @@ pub use hook::InfoHook;
pub async fn setup(path: &std::path::Path, data: &mut TypeMap, announcers: &mut AnnouncerHandler) { pub async fn setup(path: &std::path::Path, data: &mut TypeMap, announcers: &mut AnnouncerHandler) {
CfSavedUsers::insert_into(data, path.join("cf_saved_users.yaml")) CfSavedUsers::insert_into(data, path.join("cf_saved_users.yaml"))
.expect("Must be able to set up DB"); .expect("Must be able to set up DB");
let http = data.get::<HTTPClient>().unwrap(); let client = Arc::new(codeforces::Client::new());
let client = Arc::new(codeforces::Client::new(http.clone()));
data.insert::<hook::ContestCache>(hook::ContestCache::new(client.clone()).await.unwrap()); data.insert::<hook::ContestCache>(hook::ContestCache::new(client.clone()).await.unwrap());
data.insert::<CFClient>(client); data.insert::<CFClient>(client);
announcers.add("codeforces", announcer::Announcer); announcers.add("codeforces", announcer::Announcer);

View file

@ -84,7 +84,7 @@ pub async fn watch_contest(
break; break;
} }
// Sleep for a minute // Sleep for a minute
tokio::time::delay_for(std::time::Duration::from_secs(60)).await; tokio::time::sleep(std::time::Duration::from_secs(60)).await;
} }
// Announce the final results // Announce the final results

View file

@ -7,13 +7,13 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
serenity = { version = "0.9", features = ["collector"] } serenity = { version = "0.10", features = ["collector"] }
rand = "0.7" rand = "0.7"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
chrono = "0.4" chrono = "0.4"
static_assertions = "1.1" static_assertions = "1.1"
futures-util = "0.3" futures-util = "0.3"
tokio = { version = "0.2", features = ["time"] } tokio = { version = "1", features = ["time"] }
youmubot-db = { path = "../youmubot-db" } youmubot-db = { path = "../youmubot-db" }
youmubot-prelude = { path = "../youmubot-prelude" } youmubot-prelude = { path = "../youmubot-prelude" }

View file

@ -53,7 +53,7 @@ async fn clean(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
}; };
msg.react(&ctx, '🌋').await?; msg.react(&ctx, '🌋').await?;
if let Channel::Guild(_) = &channel { if let Channel::Guild(_) = &channel {
tokio::time::delay_for(std::time::Duration::from_secs(2)).await; tokio::time::sleep(std::time::Duration::from_secs(2)).await;
msg.delete(&ctx).await.ok(); msg.delete(&ctx).await.ok();
} }

View file

@ -148,7 +148,7 @@ pub async fn watch_soft_bans(cache_http: Arc<CacheAndHttp>, data: AppData) {
} }
} }
// Sleep the thread for a minute // Sleep the thread for a minute
tokio::time::delay_for(std::time::Duration::from_secs(60)).await tokio::time::sleep(std::time::Duration::from_secs(60)).await
} }
} }

View file

@ -104,7 +104,7 @@ pub async fn choose(ctx: &Context, m: &Message, mut args: Args) -> CommandResult
.push_bold(format!("{}", users.len())) .push_bold(format!("{}", users.len()))
.push(" ") .push(" ")
.push( .push(
role.map(|r| r.mention() + "s") role.map(|r| format!("{}s", r.mention()))
.unwrap_or("potential prayers".to_owned()), .unwrap_or("potential prayers".to_owned()),
) )
.push(", ") .push(", ")

View file

@ -195,7 +195,7 @@ pub async fn vote(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
.push( .push(
votes votes
.into_iter() .into_iter()
.map(|v| v.mention()) .map(|v| v.mention().to_string())
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(", "), .join(", "),
); );

View file

@ -3,7 +3,7 @@ use serenity::framework::standard::CommandError as Error;
use serenity::{ use serenity::{
framework::standard::{ framework::standard::{
macros::{check, command}, macros::{check, command},
Args, CheckResult, CommandOptions, CommandResult, Reason, Args, CommandOptions, CommandResult, Reason,
}, },
model::channel::{Channel, Message}, model::channel::{Channel, Message},
}; };
@ -29,15 +29,20 @@ pub async fn image(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
#[check] #[check]
#[name = "nsfw"] #[name = "nsfw"]
async fn nsfw_check(ctx: &Context, msg: &Message, _: &mut Args, _: &CommandOptions) -> CheckResult { async fn nsfw_check(
ctx: &Context,
msg: &Message,
_: &mut Args,
_: &CommandOptions,
) -> Result<(), Reason> {
let channel = msg.channel_id.to_channel(&ctx).await.unwrap(); let channel = msg.channel_id.to_channel(&ctx).await.unwrap();
if !(match channel { if !(match channel {
Channel::Guild(guild_channel) => guild_channel.nsfw, Channel::Guild(guild_channel) => guild_channel.nsfw,
_ => true, _ => true,
}) { }) {
CheckResult::Failure(Reason::User("😣 YOU FREAKING PERVERT!!!".to_owned())) Err(Reason::User("😣 YOU FREAKING PERVERT!!!".to_owned()))
} else { } else {
CheckResult::Success Ok(())
} }
} }

View file

@ -7,7 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
serenity = "0.9" serenity = "0.10"
dotenv = "0.15" dotenv = "0.15"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
chrono = "0.4.9" chrono = "0.4.9"

View file

@ -7,15 +7,15 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
serenity = "0.9" serenity = "0.10"
chrono = "0.4.10" chrono = "0.4"
reqwest = "0.10.1" reqwest = "0.11"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
bitflags = "1" bitflags = "1"
lazy_static = "1" lazy_static = "1"
regex = "1" regex = "1"
oppai-rs = "0.2.0" oppai-rs = "0.2"
dashmap = "3.11.4" dashmap = "4"
youmubot-db = { path = "../youmubot-db" } youmubot-db = { path = "../youmubot-db" }
youmubot-prelude = { path = "../youmubot-prelude" } youmubot-prelude = { path = "../youmubot-prelude" }

View file

@ -10,14 +10,14 @@ edition = "2018"
anyhow = "1.0" anyhow = "1.0"
async-trait = "0.1" async-trait = "0.1"
futures-util = "0.3" futures-util = "0.3"
tokio = { version = "0.2", features = ["time"] } tokio = { version = "1", features = ["time"] }
youmubot-db = { path = "../youmubot-db" } youmubot-db = { path = "../youmubot-db" }
reqwest = "0.10" reqwest = "0.11"
chrono = "0.4" chrono = "0.4"
flume = "0.9" flume = "0.10"
dashmap = "3" dashmap = "4"
[dependencies.serenity] [dependencies.serenity]
version = "0.9" version = "0.10"
default-features = true default-features = true
features = ["collector"] features = ["collector"]

View file

@ -155,8 +155,7 @@ impl AnnouncerHandler {
self.data.write().await.insert::<Self>(keys.clone()); self.data.write().await.insert::<Self>(keys.clone());
loop { loop {
eprintln!("{}: announcer started scanning", chrono::Utc::now()); eprintln!("{}: announcer started scanning", chrono::Utc::now());
// let after_timer = after(cooldown); let after = tokio::time::sleep_until(tokio::time::Instant::now() + cooldown);
let after = tokio::time::delay_for(cooldown);
join_all(self.announcers.iter().map(|(key, announcer)| { join_all(self.announcers.iter().map(|(key, announcer)| {
eprintln!(" - scanning key `{}`", key); eprintln!(" - scanning key `{}`", key);
Self::announce(self.data.clone(), self.cache_http.clone(), *key, announcer).map( Self::announce(self.data.clone(), self.cache_http.clone(), *key, announcer).map(

View file

@ -60,7 +60,7 @@ impl<'a, T> Drop for RatelimitGuard<'a, T> {
let send = self.send.clone(); let send = self.send.clone();
let wait_time = self.wait_time.clone(); let wait_time = self.wait_time.clone();
tokio::spawn(async move { tokio::spawn(async move {
tokio::time::delay_for(wait_time).await; tokio::time::sleep(wait_time).await;
send.send_async(()).await.ok(); send.send_async(()).await.ok();
}); });
} }

View file

@ -12,8 +12,8 @@ osu = ["youmubot-osu"]
codeforces = ["youmubot-cf"] codeforces = ["youmubot-cf"]
[dependencies] [dependencies]
serenity = "0.9" serenity = "0.10"
tokio = "0.2" tokio = { version = "1", features = ["rt-multi-thread"] }
dotenv = "0.15" dotenv = "0.15"
env_logger = "0.7" env_logger = "0.7"
youmubot-db = { path = "../youmubot-db" } youmubot-db = { path = "../youmubot-db" }

View file

@ -6,7 +6,6 @@ use serenity::{
model::{ model::{
channel::{Channel, Message}, channel::{Channel, Message},
gateway, gateway,
id::{ChannelId, GuildId, UserId},
permissions::Permissions, permissions::Permissions,
}, },
}; };
@ -52,14 +51,14 @@ impl EventHandler for Handler {
} }
/// Returns whether the user has "MANAGE_MESSAGES" permission in the channel. /// Returns whether the user has "MANAGE_MESSAGES" permission in the channel.
async fn is_channel_mod(ctx: &Context, _: Option<GuildId>, ch: ChannelId, u: UserId) -> bool { async fn is_not_channel_mod(ctx: &Context, msg: &Message) -> bool {
match ch.to_channel(&ctx).await { match msg.channel_id.to_channel(&ctx).await {
Ok(Channel::Guild(gc)) => gc Ok(Channel::Guild(gc)) => gc
.permissions_for_user(&ctx, u) .permissions_for_user(&ctx, msg.author.id)
.await .await
.map(|perms| perms.contains(Permissions::MANAGE_MESSAGES)) .map(|perms| !perms.contains(Permissions::MANAGE_MESSAGES))
.unwrap_or(false), .unwrap_or(true),
_ => false, _ => true,
} }
} }
@ -167,7 +166,7 @@ async fn setup_framework(token: &str) -> StandardFramework {
.after(after_hook) .after(after_hook)
.on_dispatch_error(on_dispatch_error) .on_dispatch_error(on_dispatch_error)
.bucket("voting", |c| { .bucket("voting", |c| {
c.check(|ctx, g, ch, u| Box::pin(async move { !is_channel_mod(ctx, g, ch, u).await })) c.check(|ctx, msg| Box::pin(is_not_channel_mod(ctx, msg)))
.delay(120 /* 2 minutes */) .delay(120 /* 2 minutes */)
.time_span(120) .time_span(120)
.limit(1) .limit(1)
@ -176,7 +175,7 @@ async fn setup_framework(token: &str) -> StandardFramework {
.bucket("images", |c| c.time_span(60).limit(2)) .bucket("images", |c| c.time_span(60).limit(2))
.await .await
.bucket("community", |c| { .bucket("community", |c| {
c.check(|ctx, g, ch, u| Box::pin(async move { !is_channel_mod(ctx, g, ch, u).await })) c.check(|ctx, msg| Box::pin(is_not_channel_mod(ctx, msg)))
.delay(30) .delay(30)
.time_span(30) .time_span(30)
.limit(1) .limit(1)
@ -224,9 +223,9 @@ async fn on_dispatch_error(ctx: &Context, msg: &Message, error: DispatchError) {
msg.reply( msg.reply(
&ctx, &ctx,
&match error { &match error {
DispatchError::Ratelimited(seconds) => format!( DispatchError::Ratelimited(rl) => format!(
"⏳ You are being rate-limited! Try this again in **{}**.", "⏳ You are being rate-limited! Try this again in **{}**.",
youmubot_prelude::Duration(seconds), youmubot_prelude::Duration(rl.rate_limit),
), ),
DispatchError::NotEnoughArguments { min, given } => { DispatchError::NotEnoughArguments { min, given } => {
format!( format!(