List task command + updated deps

This commit is contained in:
Joey Hines 2024-03-04 19:52:53 -07:00
parent c08ec0120d
commit 83efbb0d4f
Signed by: joeyahines
GPG Key ID: 995E531F7A569DDB
6 changed files with 255 additions and 95 deletions

293
Cargo.lock generated
View File

@ -27,17 +27,6 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "ahash"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd"
dependencies = [
"getrandom",
"once_cell",
"version_check",
]
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "1.1.2" version = "1.1.2"
@ -130,18 +119,19 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "axum" name = "axum"
version = "0.6.20" version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum-core", "axum-core",
"bitflags 1.3.2",
"bytes", "bytes",
"futures-util", "futures-util",
"http", "http 1.1.0",
"http-body", "http-body 1.0.0",
"hyper", "http-body-util",
"hyper 1.2.0",
"hyper-util",
"itoa", "itoa",
"matchit", "matchit",
"memchr", "memchr",
@ -158,23 +148,28 @@ dependencies = [
"tower", "tower",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
"tracing",
] ]
[[package]] [[package]]
name = "axum-core" name = "axum-core"
version = "0.3.4" version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
"futures-util", "futures-util",
"http", "http 1.1.0",
"http-body", "http-body 1.0.0",
"http-body-util",
"mime", "mime",
"pin-project-lite",
"rustversion", "rustversion",
"sync_wrapper",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
"tracing",
] ]
[[package]] [[package]]
@ -217,18 +212,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]] [[package]]
name = "bindgen" name = "base64"
version = "0.68.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 = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
[[package]]
name = "bindgen"
version = "0.69.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"cexpr", "cexpr",
"clang-sys", "clang-sys",
"itertools",
"lazy_static", "lazy_static",
"lazycell", "lazycell",
"log", "log",
"peeking_take_while",
"prettyplease", "prettyplease",
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -250,6 +251,9 @@ name = "bitflags"
version = "2.4.1" version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
@ -451,11 +455,12 @@ dependencies = [
[[package]] [[package]]
name = "config" name = "config"
version = "0.13.4" version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23738e11972c7643e4ec947840fc463b6a571afcd3e735bdfce7d03c7a784aca" checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"convert_case",
"json5", "json5",
"lazy_static", "lazy_static",
"nom", "nom",
@ -464,10 +469,39 @@ dependencies = [
"rust-ini", "rust-ini",
"serde", "serde",
"serde_json", "serde_json",
"toml 0.5.11", "toml",
"yaml-rust", "yaml-rust",
] ]
[[package]]
name = "const-random"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
dependencies = [
"const-random-macro",
]
[[package]]
name = "const-random-macro"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
dependencies = [
"getrandom",
"once_cell",
"tiny-keccak",
]
[[package]]
name = "convert_case"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
dependencies = [
"unicode-segmentation",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.4" version = "0.9.4"
@ -545,6 +579,12 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]] [[package]]
name = "crypto-common" name = "crypto-common"
version = "0.1.6" version = "0.1.6"
@ -640,9 +680,12 @@ dependencies = [
[[package]] [[package]]
name = "dlv-list" name = "dlv-list"
version = "0.3.0" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"
dependencies = [
"const-random",
]
[[package]] [[package]]
name = "either" name = "either"
@ -744,11 +787,11 @@ dependencies = [
[[package]] [[package]]
name = "fren" name = "fren"
version = "0.5.0" version = "0.6.0"
dependencies = [ dependencies = [
"axum", "axum",
"axum-macros", "axum-macros",
"base64 0.21.7", "base64 0.22.0",
"chrono", "chrono",
"chrono-tz", "chrono-tz",
"config", "config",
@ -768,7 +811,7 @@ dependencies = [
"structopt", "structopt",
"tera", "tera",
"tokio", "tokio",
"toml 0.8.8", "toml",
] ]
[[package]] [[package]]
@ -963,7 +1006,26 @@ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"futures-util", "futures-util",
"http", "http 0.2.11",
"indexmap",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "h2"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http 1.1.0",
"indexmap", "indexmap",
"slab", "slab",
"tokio", "tokio",
@ -973,12 +1035,9 @@ dependencies = [
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.12.3" version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
@ -1036,6 +1095,17 @@ dependencies = [
"itoa", "itoa",
] ]
[[package]]
name = "http"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "0.4.5" version = "0.4.5"
@ -1043,7 +1113,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
dependencies = [ dependencies = [
"bytes", "bytes",
"http", "http 0.2.11",
"pin-project-lite",
]
[[package]]
name = "http-body"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
dependencies = [
"bytes",
"http 1.1.0",
]
[[package]]
name = "http-body-util"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840"
dependencies = [
"bytes",
"futures-util",
"http 1.1.0",
"http-body 1.0.0",
"pin-project-lite", "pin-project-lite",
] ]
@ -1078,9 +1171,9 @@ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2", "h2 0.3.22",
"http", "http 0.2.11",
"http-body", "http-body 0.4.5",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
@ -1092,6 +1185,26 @@ dependencies = [
"want", "want",
] ]
[[package]]
name = "hyper"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"h2 0.4.2",
"http 1.1.0",
"http-body 1.0.0",
"httparse",
"httpdate",
"itoa",
"pin-project-lite",
"smallvec",
"tokio",
]
[[package]] [[package]]
name = "hyper-rustls" name = "hyper-rustls"
version = "0.24.2" version = "0.24.2"
@ -1099,8 +1212,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
dependencies = [ dependencies = [
"futures-util", "futures-util",
"http", "http 0.2.11",
"hyper", "hyper 0.14.27",
"rustls 0.21.9", "rustls 0.21.9",
"tokio", "tokio",
"tokio-rustls 0.24.1", "tokio-rustls 0.24.1",
@ -1113,12 +1226,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [ dependencies = [
"bytes", "bytes",
"hyper", "hyper 0.14.27",
"native-tls", "native-tls",
"tokio", "tokio",
"tokio-native-tls", "tokio-native-tls",
] ]
[[package]]
name = "hyper-util"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
dependencies = [
"bytes",
"futures-util",
"http 1.1.0",
"http-body 1.0.0",
"hyper 1.2.0",
"pin-project-lite",
"socket2 0.5.5",
"tokio",
]
[[package]] [[package]]
name = "iana-time-zone" name = "iana-time-zone"
version = "0.1.58" version = "0.1.58"
@ -1202,6 +1331,15 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
[[package]]
name = "itertools"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
dependencies = [
"either",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.9" version = "1.0.9"
@ -1343,9 +1481,9 @@ dependencies = [
[[package]] [[package]]
name = "magick_rust" name = "magick_rust"
version = "0.19.1" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c912b69250bcd5d024852a1a75c567d3b5d881871a55b741018741632a921bf8" checksum = "7bcea563f2aca74310eff7a545e1added08b1f4dce7679385034683fd482e9cc"
dependencies = [ dependencies = [
"bindgen", "bindgen",
"libc", "libc",
@ -1625,12 +1763,12 @@ dependencies = [
[[package]] [[package]]
name = "ordered-multimap" name = "ordered-multimap"
version = "0.4.3" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e"
dependencies = [ dependencies = [
"dlv-list", "dlv-list",
"hashbrown 0.12.3", "hashbrown 0.13.2",
] ]
[[package]] [[package]]
@ -1702,12 +1840,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 = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.3.1" version = "2.3.1"
@ -2072,10 +2204,10 @@ dependencies = [
"encoding_rs", "encoding_rs",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2", "h2 0.3.22",
"http", "http 0.2.11",
"http-body", "http-body 0.4.5",
"hyper", "hyper 0.14.27",
"hyper-rustls", "hyper-rustls",
"hyper-tls", "hyper-tls",
"ipnet", "ipnet",
@ -2148,13 +2280,14 @@ dependencies = [
[[package]] [[package]]
name = "ron" name = "ron"
version = "0.7.1" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.21.7",
"bitflags 1.3.2", "bitflags 2.4.1",
"serde", "serde",
"serde_derive",
] ]
[[package]] [[package]]
@ -2171,9 +2304,9 @@ dependencies = [
[[package]] [[package]]
name = "rust-ini" name = "rust-ini"
version = "0.18.0" 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 = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"ordered-multimap", "ordered-multimap",
@ -2647,9 +2780,9 @@ dependencies = [
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.11.2" version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
[[package]] [[package]]
name = "socket2" name = "socket2"
@ -2983,6 +3116,15 @@ dependencies = [
"time-core", "time-core",
] ]
[[package]]
name = "tiny-keccak"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
dependencies = [
"crunchy",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.6.0" version = "1.6.0"
@ -3103,15 +3245,6 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "toml"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.8.8" version = "0.8.8"
@ -3277,7 +3410,7 @@ dependencies = [
"base64 0.13.1", "base64 0.13.1",
"byteorder", "byteorder",
"bytes", "bytes",
"http", "http 0.2.11",
"httparse", "httparse",
"log", "log",
"rand", "rand",
@ -3298,7 +3431,7 @@ dependencies = [
"byteorder", "byteorder",
"bytes", "bytes",
"data-encoding", "data-encoding",
"http", "http 0.2.11",
"httparse", "httparse",
"log", "log",
"rand", "rand",

View File

@ -1,12 +1,12 @@
[package] [package]
name = "fren" name = "fren"
version = "0.5.1" version = "0.6.0"
edition = "2021" edition = "2021"
# 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]
config = "0.13.4" config = "0.14.0"
structopt = "0.3.26" structopt = "0.3.26"
reqwest = { version = "0.11.24", features = ["json"] } reqwest = { version = "0.11.24", features = ["json"] }
serde = "1.0.195" serde = "1.0.195"
@ -15,13 +15,13 @@ rand = "0.8.5"
tera = "1.19.1" tera = "1.19.1"
ndm = "0.9.10" ndm = "0.9.10"
regex = "1.10.2" regex = "1.10.2"
magick_rust = "0.19.1" magick_rust = "0.20.0"
songbird = "0.4.0" songbird = "0.4.0"
json = "0.12.4" json = "0.12.4"
axum = "0.6.3" axum = "0.7.4"
axum-macros = "0.4.1" axum-macros = "0.4.1"
sha3 = "0.10.8" sha3 = "0.10.8"
base64 = "0.21.7" base64 = "0.22.0"
j_db = { version = "0.1.0", registry = "jojo-dev" } j_db = { version = "0.1.0", registry = "jojo-dev" }
chrono = { version = "0.4.31", features = ["serde"] } chrono = { version = "0.4.31", features = ["serde"] }
chrono-tz = "0.8.5" chrono-tz = "0.8.5"

View File

@ -18,10 +18,8 @@ pub async fn web_server(ctx: Context) {
.with_state(ctx); .with_state(ctx);
println!("Serving bot api on: {}", addr); println!("Serving bot api on: {}", addr);
axum::Server::bind(&addr) let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
.serve(app.into_make_service()) axum::serve(listener, app).await.unwrap();
.await
.unwrap();
} }
#[derive(Deserialize)] #[derive(Deserialize)]

View File

@ -5,15 +5,18 @@ use crate::models::lil_fren::{
draw_dancing, draw_frankenstein, draw_gone, draw_magic, draw_mining, draw_resonance_cascade, draw_dancing, draw_frankenstein, draw_gone, draw_magic, draw_mining, draw_resonance_cascade,
draw_sick, draw_sleep, draw_standing, draw_tax_fraud, AliveState, LilFren, draw_sick, draw_sleep, draw_standing, draw_tax_fraud, AliveState, LilFren,
}; };
use crate::models::task::Task;
use crate::user::User; use crate::user::User;
use crate::{command, group, GlobalData}; use crate::{command, group, GlobalData};
use json::JsonValue; use json::JsonValue;
use serenity::all::{CreateAttachment, CreateMessage}; use serenity::all::{CreateAttachment, CreateMessage, FormattedTimestamp, FormattedTimestampStyle};
use serenity::client::Context; use serenity::client::Context;
use serenity::framework::standard::{Args, CommandResult}; use serenity::framework::standard::{Args, CommandResult};
use serenity::model::channel::Message; use serenity::model::channel::Message;
use serenity::model::misc::EmojiIdentifier; use serenity::model::misc::EmojiIdentifier;
use serenity::model::prelude::UserId; use serenity::model::prelude::UserId;
use serenity::model::Timestamp;
use serenity::utils::MessageBuilder;
use std::borrow::Cow; use std::borrow::Cow;
#[group] #[group]
@ -24,7 +27,8 @@ use std::borrow::Cow;
add_key, add_key,
debug_buddy, debug_buddy,
draw_buddy_states, draw_buddy_states,
op_give op_give,
list_tasks
)] )]
pub struct ADMIN; pub struct ADMIN;
@ -240,3 +244,28 @@ async fn op_give(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
Ok(()) Ok(())
} }
#[command]
#[description("List scheduled tasks")]
async fn list_tasks(ctx: &Context, msg: &Message) -> CommandResult {
let data = ctx.data.read().await;
let global_data = data.get::<GlobalData>().unwrap();
let tasks: Vec<Task> = global_data.db.filter(|_, _task: &Task| true)?.collect();
let mut resp = MessageBuilder::new();
for task in &tasks {
let timestamp = Timestamp::from(task.time);
let time_tag =
FormattedTimestamp::new(timestamp, Some(FormattedTimestampStyle::ShortDateTime));
resp.push_line(format!(
"* **Task**: {:?} **Next Execution**: {}",
task.task_type, time_tag
));
}
msg.reply(&ctx.http, resp.build()).await?;
Ok(())
}

View File

@ -42,7 +42,7 @@ pub async fn create_motivation_image(motivation: Motivation) -> Result<Vec<u8>,
&border_wand, &border_wand,
border, border,
border, border,
magick_rust::bindings::CompositeOperator_OverCompositeOp, magick_rust::bindings::CompositeOperator_OverCompositeOp.into(),
)?; )?;
border_wand.set_color("black")?; border_wand.set_color("black")?;
@ -52,7 +52,7 @@ pub async fn create_motivation_image(motivation: Motivation) -> Result<Vec<u8>,
&border_wand, &border_wand,
border, border,
border, border,
magick_rust::bindings::CompositeOperator_OverCompositeOp, magick_rust::bindings::CompositeOperator_OverCompositeOp.into(),
)?; )?;
let text_pos_x = wand.get_image_width() as f64 / 2.0; let text_pos_x = wand.get_image_width() as f64 / 2.0;

View File

@ -30,8 +30,8 @@ impl TaskType {
#[derive(Debug, Deserialize, Serialize, Clone)] #[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Task { pub struct Task {
id: Option<u64>, id: Option<u64>,
task_type: TaskType, pub task_type: TaskType,
time: chrono::DateTime<Utc>, pub time: chrono::DateTime<Utc>,
} }
impl JdbModel for Task { impl JdbModel for Task {