From 63c1a8a62c4805aff8cb41cbbcfe94fa5e0a7bbf Mon Sep 17 00:00:00 2001 From: Florian Schmidt Date: Fri, 8 Nov 2024 15:36:30 +0100 Subject: [PATCH] allow toggling between diff update and full updates; bump deps --- Cargo.lock | 453 +++++++++++++++++++++++++++------- Cargo.toml | 4 +- src/bin/mensi-telegram-bin.rs | 5 +- src/bin/stuwe-telegram-bin.rs | 5 +- src/bot_command_handlers.rs | 30 +++ src/data_types/mod.rs | 3 + src/db_operations.rs | 27 +- src/shared_main.rs | 5 +- src/task_scheduler_funcs.rs | 17 +- 9 files changed, 444 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80abf80..4fa69d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,9 +56,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -71,9 +71,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" @@ -105,9 +105,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "aquamarine" @@ -120,7 +120,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -216,9 +216,9 @@ checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cc" -version = "1.1.31" +version = "1.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" dependencies = [ "shlex", ] @@ -281,7 +281,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -376,14 +376,14 @@ dependencies = [ [[package]] name = "cssparser" -version = "0.31.2" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b3df4f93e5fbbe73ec01ec8d3f68bba73107993a5b1e7519273c32db9b0d5be" +checksum = "b7c66d1cd8ed61bf80b38432613a7a2f09401ab8d0501110655f8b341484a3e3" dependencies = [ "cssparser-macros", "dtoa-short", "itoa", - "phf 0.11.2", + "phf", "smallvec", ] @@ -394,7 +394,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -457,7 +457,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -470,6 +470,17 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "dptree" version = "0.3.0" @@ -496,9 +507,9 @@ dependencies = [ [[package]] name = "ego-tree" -version = "0.6.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12a0bb14ac04a9fcf170d0bbbef949b44cc492f4452bd20c095636956f653642" +checksum = "7c6ba7d4eec39eaa9ab24d44a0e73a7949a1095a8b3f3abb11eddf27dbb56a53" [[package]] name = "either" @@ -568,9 +579,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "fnv" @@ -668,7 +679,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -795,9 +806,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "hashlink" @@ -834,16 +845,16 @@ checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "html5ever" -version = "0.27.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c13771afe0e6e846f1e67d038d4cb29998a6779f93c809212e4e9c32efd244d4" +checksum = "2e15626aaf9c351bc696217cbe29cb9b5e86c43f8a46b5e2f5c6c5cf7cb904ce" dependencies = [ "log", "mac", "markup5ever", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1052,6 +1063,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1078,6 +1207,27 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "include_dir" version = "0.7.4" @@ -1104,7 +1254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", ] [[package]] @@ -1165,9 +1315,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libsqlite3-sys" @@ -1185,6 +1335,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.4.12" @@ -1209,13 +1365,13 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "markup5ever" -version = "0.12.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16ce3abbeba692c8b8441d036ef91aea6df8da2c6b6e21c7e14d3c18e526be45" +checksum = "82c88c6129bd24319e62a0359cb6b958fa7e8be6e19bb1663bc396b90883aca5" dependencies = [ "log", - "phf 0.11.2", - "phf_codegen 0.11.2", + "phf", + "phf_codegen", "string_cache", "string_cache_codegen", "tendril", @@ -1301,7 +1457,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1351,7 +1507,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1426,15 +1582,6 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" -[[package]] -name = "phf" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" -dependencies = [ - "phf_shared 0.10.0", -] - [[package]] name = "phf" version = "0.11.2" @@ -1445,16 +1592,6 @@ dependencies = [ "phf_shared 0.11.2", ] -[[package]] -name = "phf_codegen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", -] - [[package]] name = "phf_codegen" version = "0.11.2" @@ -1495,7 +1632,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1533,7 +1670,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1832,7 +1969,7 @@ dependencies = [ "async-tungstenite", "futures-util", "reqwest 0.12.9", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-util", "tracing", @@ -1886,9 +2023,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" dependencies = [ "bitflags 2.6.0", "errno", @@ -1968,16 +2105,16 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scraper" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b90460b31bfe1fc07be8262e42c665ad97118d4585869de9345a84d501a9eaf0" +checksum = "b0e749d29b2064585327af5038a5a8eb73aeebad4a3472e83531a436563f7208" dependencies = [ "ahash", "cssparser", "ego-tree", "getopts", "html5ever", - "once_cell", + "precomputed-hash", "selectors", "tendril", ] @@ -2007,9 +2144,9 @@ dependencies = [ [[package]] name = "selectors" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb30575f3638fc8f6815f448d50cb1a2e255b0897985c8c59f4d37b72a07b06" +checksum = "fd568a4c9bb598e291a08244a5c1f5a8a6650bee243b5b0f8dbb3d9cc1d87fe8" dependencies = [ "bitflags 2.6.0", "cssparser", @@ -2017,8 +2154,8 @@ dependencies = [ "fxhash", "log", "new_debug_unreachable", - "phf 0.10.1", - "phf_codegen 0.10.0", + "phf", + "phf_codegen", "precomputed-hash", "servo_arc", "smallvec", @@ -2047,7 +2184,7 @@ checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -2098,9 +2235,9 @@ dependencies = [ [[package]] name = "servo_arc" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d036d71a959e00c77a63538b90a6c2390969f9772b096ea837205c6bd0491a44" +checksum = "ae65c4249478a2647db249fb43e23cec56a2c8974a427e7bd8cb5a1d0964921a" dependencies = [ "stable_deref_trait", ] @@ -2261,7 +2398,7 @@ dependencies = [ "static_init", "teloxide", "teloxide-core", - "thiserror", + "thiserror 2.0.0", "tokio", "tokio-cron-scheduler", "uuid", @@ -2286,9 +2423,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -2310,6 +2447,17 @@ dependencies = [ "futures-core", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -2383,7 +2531,7 @@ dependencies = [ "serde_json", "teloxide-core", "teloxide-macros", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", "tokio-util", @@ -2413,7 +2561,7 @@ dependencies = [ "serde_with", "take_mut", "takecell", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-util", "url", @@ -2434,9 +2582,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", @@ -2477,22 +2625,42 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +dependencies = [ + "thiserror-impl 1.0.68", +] + +[[package]] +name = "thiserror" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15291287e9bff1bc6f9ff3409ed9af665bec7a5fc8ac079ea96be07bca0e2668" +dependencies = [ + "thiserror-impl 2.0.0", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ - "thiserror-impl", + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "22efd00f33f93fa62848a7cab956c3d38c8d43095efda1decfc2b3a5dc0b8972" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -2526,6 +2694,16 @@ dependencies = [ "time-core", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -2543,9 +2721,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -2581,7 +2759,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -2655,7 +2833,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -2687,7 +2865,7 @@ dependencies = [ "log", "rand", "sha1", - "thiserror", + "thiserror 1.0.68", "utf-8", ] @@ -2738,12 +2916,12 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", - "idna 0.5.0", + "idna 1.0.3", "percent-encoding", "serde", ] @@ -2754,6 +2932,18 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -2818,7 +3008,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", "wasm-bindgen-shared", ] @@ -2852,7 +3042,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3114,6 +3304,42 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -3132,7 +3358,28 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", ] [[package]] @@ -3140,3 +3387,25 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] diff --git a/Cargo.toml b/Cargo.toml index d79beef..fa543a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,13 +24,13 @@ regex-lite = "0.1.5" reqwest = { version = "0.12.2", features = ["cookies", "json"] } reqwest-websocket = "0.4.2" rusqlite = { version = "0.32.1" } -scraper = "0.20.0" +scraper = "0.21.0" serde = { version = "1.0.196", features = ["derive"] } serde_json = "1.0.113" static_init = "1.0.3" teloxide = { version = "0.13.0", features = ["macros"] } teloxide-core = "0.10.1" -thiserror = "1.0.56" +thiserror = "2.0.0" tokio = { version = "1.35.1", features = ["rt-multi-thread", "macros"] } tokio-cron-scheduler = "0.13.0" uuid = "1.7.0" diff --git a/src/bin/mensi-telegram-bin.rs b/src/bin/mensi-telegram-bin.rs index 6ae630b..caa3fb5 100644 --- a/src/bin/mensi-telegram-bin.rs +++ b/src/bin/mensi-telegram-bin.rs @@ -4,8 +4,8 @@ use stuwe_telegram_rs::data_backend::mm_parser::get_mensen; use stuwe_telegram_rs::data_types::CampusDualData; use stuwe_telegram_rs::bot_command_handlers::{ - allergene, change_mensa, day_cmd, invalid_cmd, reply_time_dialogue, show_different_mensa, - start, start_time_dialogue, subscribe, unsubscribe, + allergene, change_mensa, day_cmd, invalid_cmd, reply_time_dialogue, senddiff, + show_different_mensa, start, start_time_dialogue, subscribe, unsubscribe, }; use stuwe_telegram_rs::constants::{ BACKEND, CD_DATA, DB_FILENAME, MENSI_DB, OLLAMA_HOST, OLLAMA_MODEL, USER_REGISTRATIONS, @@ -138,6 +138,7 @@ fn schema() -> UpdateHandler> .branch(dptree::case![Command::Unsubscribe].endpoint(unsubscribe)) .branch(dptree::case![Command::Mensa].endpoint(change_mensa)) .branch(dptree::case![Command::Allergene].endpoint(allergene)) + .branch(dptree::case![Command::Diff].endpoint(senddiff)) .branch(dptree::case![Command::Uhrzeit].endpoint(start_time_dialogue)); let message_handler = Update::filter_message() diff --git a/src/bin/stuwe-telegram-bin.rs b/src/bin/stuwe-telegram-bin.rs index 1b88c10..d5c0bf9 100644 --- a/src/bin/stuwe-telegram-bin.rs +++ b/src/bin/stuwe-telegram-bin.rs @@ -3,8 +3,8 @@ use stuwe_telegram_rs::data_types::CampusDualData; use stuwe_telegram_rs::bot_command_handlers::{ - allergene, change_mensa, day_cmd, invalid_cmd, reply_time_dialogue, show_different_mensa, - start, start_time_dialogue, subscribe, unsubscribe, + allergene, change_mensa, day_cmd, invalid_cmd, reply_time_dialogue, senddiff, + show_different_mensa, start, start_time_dialogue, subscribe, unsubscribe, }; use stuwe_telegram_rs::constants::{ API_URL, BACKEND, CD_DATA, DB_FILENAME, OLLAMA_HOST, OLLAMA_MODEL, STUWE_DB, USER_REGISTRATIONS, @@ -146,6 +146,7 @@ fn schema() -> UpdateHandler> .branch(dptree::case![Command::Unsubscribe].endpoint(unsubscribe)) .branch(dptree::case![Command::Mensa].endpoint(change_mensa)) .branch(dptree::case![Command::Allergene].endpoint(allergene)) + .branch(dptree::case![Command::Diff].endpoint(senddiff)) .branch(dptree::case![Command::Uhrzeit].endpoint(start_time_dialogue)); let message_handler = Update::filter_message() diff --git a/src/bot_command_handlers.rs b/src/bot_command_handlers.rs index 571e386..b6c4d3a 100644 --- a/src/bot_command_handlers.rs +++ b/src/bot_command_handlers.rs @@ -168,6 +168,36 @@ pub async fn allergene(bot: Bot, msg: Message) -> HandlerResult { Ok(()) } +pub async fn senddiff(bot: Bot, msg: Message) -> HandlerResult { + if let Some(mut registration) = get_user_registration(msg.chat.id.0) { + registration.senddiff = !registration.senddiff; + + set_user_allergen_state(msg.chat.id.0, registration.senddiff)?; + insert_user_registration(msg.chat.id.0, registration); + + match registration.senddiff { + true => { + bot.send_message( + msg.chat.id, + "✅ Nur Änderungen werden bei Planänderung gesendet.", + ) + .await?; + } + false => { + bot.send_message( + msg.chat.id, + "❌ Gesamter Plan wird bei Änderungen gesendet.", + ) + .await?; + } + } + } else { + bot.send_message(msg.chat.id, NO_DB_MSG).await?; + } + + Ok(()) +} + pub async fn start_time_dialogue( bot: Bot, msg: Message, diff --git a/src/data_types/mod.rs b/src/data_types/mod.rs index b6b4f1d..27a4e54 100644 --- a/src/data_types/mod.rs +++ b/src/data_types/mod.rs @@ -38,6 +38,8 @@ pub enum Command { Uhrzeit, #[command(hide)] Allergene, + #[command(description = "Bei Planänderungen nur Unterschied schicken")] + Diff, #[command(hide)] Start, } @@ -160,6 +162,7 @@ pub struct RegistrationEntry { pub hour: Option, pub minute: Option, pub allergens: bool, + pub senddiff: bool, } #[derive(Error, Debug, Clone)] diff --git a/src/db_operations.rs b/src/db_operations.rs index e941a97..1eca296 100644 --- a/src/db_operations.rs +++ b/src/db_operations.rs @@ -70,7 +70,8 @@ pub fn check_or_create_db_tables() -> rusqlite::Result<()> { mensa_id integer not null, hour integer, minute integer, - allergens BOOLEAN + allergens BOOLEAN DEFAULT 1, + senddiff BOOLEAN DEFAULT 1 )", )? .execute([])?; @@ -142,3 +143,27 @@ pub fn set_user_allergen_state(chat_id: i64, state: bool) -> rusqlite::Result<() Ok(()) } + +pub fn get_user_senddiff_state(chat_id: i64) -> rusqlite::Result { + let conn = Connection::open(DB_FILENAME.get().unwrap()).unwrap(); + + let mut stmt = conn.prepare_cached( + "select senddiff from registrations + where chat_id = ?1", + )?; + + let diff: bool = stmt.query_row(params![chat_id], |row| row.get(0))?; + + Ok(diff) +} + +pub fn set_user_senddiff_state(chat_id: i64, state: bool) -> rusqlite::Result<()> { + let conn = Connection::open(DB_FILENAME.get().unwrap()).unwrap(); + + let mut stmt = + conn.prepare_cached("update registrations set senddiff = ?2 where chat_id = ?1")?; + + stmt.execute(params![chat_id, state])?; + + Ok(()) +} diff --git a/src/shared_main.rs b/src/shared_main.rs index 237e756..ee700a0 100644 --- a/src/shared_main.rs +++ b/src/shared_main.rs @@ -68,12 +68,13 @@ pub fn make_commands_keyrow() -> KeyboardMarkup { vec![ KeyboardButton::new("/heute"), KeyboardButton::new("/morgen"), - KeyboardButton::new("/übermorgen"), + KeyboardButton::new("/andere"), + // KeyboardButton::new("/übermorgen"), ], vec![ - KeyboardButton::new("/andere"), KeyboardButton::new("/mensa"), KeyboardButton::new("/allergene"), + KeyboardButton::new("/diff"), ], ]; KeyboardMarkup::new(keyboard).resize_keyboard() diff --git a/src/task_scheduler_funcs.rs b/src/task_scheduler_funcs.rs index 12d7f9f..f549918 100644 --- a/src/task_scheduler_funcs.rs +++ b/src/task_scheduler_funcs.rs @@ -19,13 +19,13 @@ use crate::{ save_campusdual_grades, save_campusdual_signup_options, }, constants::{API_URL, BACKEND, CD_DATA, NO_DB_MSG, USER_REGISTRATIONS}, - data_backend::stuwe_parser::stuwe_build_diff_msg, + data_backend::stuwe_parser::{stuwe_build_diff_msg, stuwe_build_meal_msg}, data_types::{ Backend, BroadcastUpdateTask, JobHandlerTask, RegistrationEntry, UpdateRegistrationTask, }, db_operations::{ - get_all_user_registrations_db, get_user_allergen_state, init_db_record, task_db_kill_auto, - update_db_row, + get_all_user_registrations_db, get_user_allergen_state, get_user_senddiff_state, + init_db_record, task_db_kill_auto, update_db_row, }, shared_main::{get_user_registration, insert_user_registration, load_job}, }; @@ -59,6 +59,7 @@ pub async fn handle_add_registration_task( hour: job_handler_task.hour, minute: job_handler_task.minute, allergens: registration.map(|reg| reg.allergens).unwrap_or(true), + senddiff: registration.map(|reg| reg.senddiff).unwrap_or(true), }, ); } @@ -119,6 +120,7 @@ pub async fn handle_update_registration_task( hour, minute, allergens: registration.allergens, + senddiff: registration.senddiff, }, ); @@ -157,6 +159,7 @@ pub async fn handle_delete_registration_task( hour: None, minute: None, allergens: registration.allergens, + senddiff: registration.senddiff, }, ); @@ -213,7 +216,12 @@ pub async fn handle_broadcast_update_task(bot: &Bot, job_handler_task: JobHandle log::info!("Sent update to {}", chat_id); - let text = stuwe_build_diff_msg(&diff, registration_data.allergens).await; + let text = match registration_data.senddiff { + true => stuwe_build_diff_msg(&diff, registration_data.allergens).await, + false => { + stuwe_build_meal_msg(0, diff.canteen_id, registration_data.allergens).await + } + }; bot.send_message(ChatId(chat_id), text) .parse_mode(ParseMode::MarkdownV2) @@ -345,6 +353,7 @@ pub async fn load_jobs_from_db( minute: task.minute, // hack job allergens: get_user_allergen_state(task.chat_id.unwrap()).unwrap(), + senddiff: get_user_senddiff_state(task.chat_id.unwrap()).unwrap(), }, ); }