From c8fce6c51c963eaeb120d4c97e35f6c192bcd485 Mon Sep 17 00:00:00 2001 From: Aras14HD Date: Mon, 22 Jun 2026 13:15:04 +0200 Subject: [PATCH 1/4] deprecate "nested" for "no_multi" add nested_used status and locale --- factorion-lib/src/comment.rs | 40 +++++++++++++++++++++++++++++- factorion-lib/src/locale.rs | 5 ++++ factorion-lib/tests/integration.rs | 4 +-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/factorion-lib/src/comment.rs b/factorion-lib/src/comment.rs index 7ccacf4..96d8a12 100644 --- a/factorion-lib/src/comment.rs +++ b/factorion-lib/src/comment.rs @@ -83,6 +83,7 @@ pub struct Status { pub reply_would_be_too_long: bool, pub factorials_found: bool, pub limit_hit: bool, + pub nested_used: bool, } impl_all_bitwise!(Status { @@ -93,6 +94,7 @@ impl_all_bitwise!(Status { reply_would_be_too_long, factorials_found, limit_hit, + nested_used, }); #[allow(dead_code)] impl Status { @@ -104,6 +106,7 @@ impl Status { reply_would_be_too_long: false, factorials_found: false, limit_hit: false, + nested_used: false, }; pub const ALREADY_REPLIED_OR_REJECTED: Self = Self { already_replied_or_rejected: true, @@ -133,6 +136,10 @@ impl Status { limit_hit: true, ..Self::NONE }; + pub const NESTED_USED: Self = Self { + nested_used: true, + ..Self::NONE + }; } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Default, PartialOrd, Ord)] @@ -217,7 +224,10 @@ impl Commands { steps: Self::contains_command_format(text, "steps") || Self::contains_command_format(text, "all"), nested: Self::contains_command_format(text, "nest") - || Self::contains_command_format(text, "nested"), + || Self::contains_command_format(text, "nested") + || Self::contains_command_format(text, "no multi") + || Self::contains_command_format(text, "no\\_multi") + || Self::contains_command_format(text, "no_multi"), termial: Self::contains_command_format(text, "termial") || Self::contains_command_format(text, "triangle"), no_note: Self::contains_command_format(text, "no note") @@ -299,6 +309,13 @@ impl CommentConstructed { (Commands::from_comment_text(comment_text) | pre_commands) & command_overrides; let mut status: Status = Default::default(); + if Commands::contains_command_format(comment_text, "nest") + || Commands::contains_command_format(comment_text, "nested") + || Commands::contains_command_format(comment_text, "no_nest") + || Commands::contains_command_format(comment_text, "no\\_nest") + { + status.nested_used = true; + } let text = if Self::might_have_factorial(comment_text) { comment_text.to_owned() @@ -695,6 +712,14 @@ impl CommentCalculated { too_big_number: &Integer, ) -> bool { let multiple = self.calculation_list.len() > 1; + if self.status.nested_used { + let _ = note.write_str(locale.notes.nested_used + .as_ref() + .map(AsRef::as_ref) + .unwrap_or("The command \"nested\" is now \"no_multi\", which is way more clear in what it means. I'll ignore it at some point in the future.") + ); + let _ = note.write_str("\n\n"); + } if !self.commands.no_note { if self.status.limit_hit { let _ = note.write_str( @@ -933,4 +958,17 @@ mod tests { "I can only write out numbers in english, so I will do that.\n\nFakultät von one ist one \n\n\n*^(Dieser Kommentar wurde automatisch geschrieben | [Quelltext](http://f.r0.fyi))*" ); } + + #[test] + fn test_nested_used_note() { + let consts = Consts::default(); + let comment = Comment::new("n!!!!! !nested", (), Commands::NONE, MAX_LENGTH, "en") + .extract(&consts) + .calc(&consts); + let reply = comment.get_reply(&consts); + assert_eq!( + reply, + "The command \"nested\" is now \"no_multi\", which is way more clear in what it means. I'll ignore it at some point in the future.\n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" + ); + } } diff --git a/factorion-lib/src/locale.rs b/factorion-lib/src/locale.rs index 082edbf..22fb60b 100644 --- a/factorion-lib/src/locale.rs +++ b/factorion-lib/src/locale.rs @@ -48,6 +48,7 @@ pub fn get_all() -> impl Iterator)> { #[derive(Debug, Clone)] #[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))] +#[non_exhaustive] pub struct Locale<'a> { pub bot_disclaimer: Cow<'a, str>, pub notes: Notes<'a>, @@ -55,6 +56,7 @@ pub struct Locale<'a> { } #[derive(Debug, Clone)] #[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))] +#[non_exhaustive] pub struct Notes<'a> { pub tower: Cow<'a, str>, pub tower_mult: Cow<'a, str>, @@ -72,10 +74,12 @@ pub struct Notes<'a> { pub mention: Cow<'a, str>, pub limit_hit: Option>, pub write_out_unsupported: Option>, + pub nested_used: Option>, } #[derive(Debug, Clone)] #[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))] +#[non_exhaustive] pub struct Format<'a> { pub capitalize_calc: bool, pub termial: Cow<'a, str>, @@ -98,6 +102,7 @@ pub struct Format<'a> { #[derive(Debug, Clone)] #[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))] +#[non_exhaustive] pub struct NumFormat { pub decimal: char, } diff --git a/factorion-lib/tests/integration.rs b/factorion-lib/tests/integration.rs index 334c608..3391039 100644 --- a/factorion-lib/tests/integration.rs +++ b/factorion-lib/tests/integration.rs @@ -673,7 +673,7 @@ full_reply_tests!( "Termial of 2 is 3 \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*", ), test_command_nest: ( - "9!!!!?? !nest", + "9!!!!?? !no_multi", Commands::TERMIAL, "en", "That is so large, that I can't even give the number of digits of it, so I have to make a power of ten tower.\n\nTermial of termial of factorial of factorial of factorial of factorial of 9 has on the order of 10^(2.993960567614282167996111938338 × 10^1859939) digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*", @@ -685,7 +685,7 @@ full_reply_tests!( "Factorial of 10939742352358 is approximately 4.451909479489793754826968519779 × 10^137892308399887 \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*", ), test_command_no_note_tet: ( - "\\[no_note\\] 9!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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!!no_multi ", Commands::NONE, "en", "All that of 9 has on the order of ^(628)10 digits \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*", From eb49d6090c0c9915a0697ca9fdaaa27dff5439fa Mon Sep 17 00:00:00 2001 From: Aras14HD Date: Mon, 22 Jun 2026 13:21:40 +0200 Subject: [PATCH 2/4] add nested_used to more locales (en, en_fuck, de) --- factorion-lib/src/comment.rs | 4 ++-- factorion-lib/src/de.json | 3 ++- factorion-lib/src/en.json | 1 + factorion-lib/src/en_fuck.json | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/factorion-lib/src/comment.rs b/factorion-lib/src/comment.rs index 96d8a12..ef84ec9 100644 --- a/factorion-lib/src/comment.rs +++ b/factorion-lib/src/comment.rs @@ -716,7 +716,7 @@ impl CommentCalculated { let _ = note.write_str(locale.notes.nested_used .as_ref() .map(AsRef::as_ref) - .unwrap_or("The command \"nested\" is now \"no_multi\", which is way more clear in what it means. I'll ignore it at some point in the future.") + .unwrap_or("The command \"nested\" is now \"no_multi\", which is way more clear in what it means. I'll ignore the former at some point in the future.") ); let _ = note.write_str("\n\n"); } @@ -968,7 +968,7 @@ mod tests { let reply = comment.get_reply(&consts); assert_eq!( reply, - "The command \"nested\" is now \"no_multi\", which is way more clear in what it means. I'll ignore it at some point in the future.\n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" + "The command \"nested\" is now \"no_multi\", which is way more clear in what it means. I'll ignore the former at some point in the future.\n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*" ); } } diff --git a/factorion-lib/src/de.json b/factorion-lib/src/de.json index 4ce9330..66fc8c5 100644 --- a/factorion-lib/src/de.json +++ b/factorion-lib/src/de.json @@ -13,9 +13,10 @@ "too_big_mult": "Wenn ich die Zahlen ausschreiben würde, wäre der Kommentar zu lang. Also muss ich die wissenschaftliche Schreibweise nutzen.", "remove": "Wenn ich alle Zahlen angeben würde, wäre der Kommentar zu lang. Also muss ich welche rausnehmen.", "tetration": "Das ist so groß, dass selbst der Zehn-hoch-Turm nicht mehr in den Kommentar passt. Also muss ich tetrieren.", - "no_post": "Sorry, die Antwort für all das wäre einfach _zu_ lang. Ich probier lieber nicht das zu schicken lmao", + "no_post": "Sorry, die Antwort für all das wäre einfach _zu_ lang. Ich probier lieber nicht das zu schicken lmao.", "limit_hit": "I habe mich genug wiederholt, das werde ich nicht nochmal berechnen.", "write_out_unsupported": "Ich kann nur in Englisch Zahlen ausschreiben, also werde ich das tun.", + "nested_used": "Der Command \"nested\" ist jetzt \"no_multi\", was um einiges verständlicher ist. Ich werde ersteres irgendwann ignorieren.", "mention": "Hey {mention}!" }, "format": { diff --git a/factorion-lib/src/en.json b/factorion-lib/src/en.json index 5381548..dcfb3d4 100644 --- a/factorion-lib/src/en.json +++ b/factorion-lib/src/en.json @@ -16,6 +16,7 @@ "no_post": "Sorry, but the reply text for all those numbers would be _really_ long, so I'd rather not even try posting lmao", "limit_hit": "I have repeated myself enough, I won't do that calculation again.", "write_out_unsupported": "I can only write out numbers in english, so I will do that.", + "nested_used": "The command \"nested\" is now \"no_multi\", which is way more clear in what it means. I'll ignore the former at some point in the future.", "mention": "Hey {mention}!" }, "format": { diff --git a/factorion-lib/src/en_fuck.json b/factorion-lib/src/en_fuck.json index a8f08b3..3e9d83c 100644 --- a/factorion-lib/src/en_fuck.json +++ b/factorion-lib/src/en_fuck.json @@ -16,6 +16,7 @@ "no_post": "Sorry, but the reply text for all those numbers would be _really_ fucking long, so I'd rather not even try posting lmao", "limit_hit": "I have repeated myself enough, I won't do that fucking calculation again.", "write_out_unsupported": "I can only write out numbers in english, so I will do that.", + "nested_used": "The command \"nested\" is now \"no_multi\", which is way more fucking clear in what it means. I won't give a fuck about the former at some point in the future.", "mention": "Hey {mention}!" }, "format": { From 5b4a98b1217c7ce460bc0cadafba308a28b3ab17 Mon Sep 17 00:00:00 2001 From: Aras14HD Date: Wed, 24 Jun 2026 14:50:32 +0200 Subject: [PATCH 3/4] add Default for Locale (plus docs) --- factorion-lib/src/locale.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/factorion-lib/src/locale.rs b/factorion-lib/src/locale.rs index 22fb60b..4e46d2c 100644 --- a/factorion-lib/src/locale.rs +++ b/factorion-lib/src/locale.rs @@ -46,7 +46,16 @@ pub fn get_all() -> impl Iterator)> { .into_iter() } -#[derive(Debug, Clone)] +/// Represents the whole locale. +/// Create by deserializing or intializing as a Struct, sperading with default. +/// +/// Note regarding non_exhaustive: Additions will always be Option and will so default to None, causing a sensible fallback. +/// (also not break serialization format in many cases like json) +/// +/// Note on Default: It is derived, so any strings will be empty and booleans will be false. So all non-option fields should be overridden/supplied. +/// +/// For further information about the fields (as json serialization), read [../Locales.md] +#[derive(Debug, Clone, Default)] #[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))] #[non_exhaustive] pub struct Locale<'a> { @@ -54,7 +63,8 @@ pub struct Locale<'a> { pub notes: Notes<'a>, pub format: Format<'a>, } -#[derive(Debug, Clone)] + +#[derive(Debug, Clone, Default)] #[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))] #[non_exhaustive] pub struct Notes<'a> { @@ -77,7 +87,7 @@ pub struct Notes<'a> { pub nested_used: Option>, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] #[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))] #[non_exhaustive] pub struct Format<'a> { @@ -106,3 +116,9 @@ pub struct Format<'a> { pub struct NumFormat { pub decimal: char, } + +impl Default for NumFormat { + fn default() -> Self { + NumFormat { decimal: '.' } + } +} From 6c6f150d9966b4fcd3daf98c5446c6ae88d77717 Mon Sep 17 00:00:00 2001 From: Aras14HD Date: Wed, 24 Jun 2026 14:54:24 +0200 Subject: [PATCH 4/4] bump versions (major lib, clients minor) --- Cargo.lock | 6 +++--- factorion-bot-discord/Cargo.toml | 4 ++-- factorion-bot-reddit/Cargo.toml | 4 ++-- factorion-lib/Cargo.toml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92ccefc..a2e923a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -399,7 +399,7 @@ dependencies = [ [[package]] name = "factorion-bot-discord" -version = "3.0.6" +version = "3.1.0" dependencies = [ "anyhow", "dotenvy", @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "factorion-bot-reddit" -version = "6.0.7" +version = "6.1.0" dependencies = [ "anyhow", "base64 0.22.1", @@ -434,7 +434,7 @@ dependencies = [ [[package]] name = "factorion-lib" -version = "6.0.6" +version = "7.0.0" dependencies = [ "arbtest", "chrono", diff --git a/factorion-bot-discord/Cargo.toml b/factorion-bot-discord/Cargo.toml index 72a9b56..19b6e3d 100644 --- a/factorion-bot-discord/Cargo.toml +++ b/factorion-bot-discord/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "factorion-bot-discord" -version = "3.0.6" +version = "3.1.0" edition = "2024" description = "factorion-bot (for factorials and related) on Discord" license = "MIT" @@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math", "discord"] categories = ["mathematics", "web-programming", "parser-implementations"] [dependencies] -factorion-lib = { path = "../factorion-lib", version = "6.0.6", features = ["serde", "influxdb"] } +factorion-lib = { path = "../factorion-lib", version = "7.0.0", features = ["serde", "influxdb"] } serenity = { version = "0.12", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "cache"] } tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread", "time"] } dotenvy = "^0.15.7" diff --git a/factorion-bot-reddit/Cargo.toml b/factorion-bot-reddit/Cargo.toml index d573f3f..f27d5b4 100644 --- a/factorion-bot-reddit/Cargo.toml +++ b/factorion-bot-reddit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "factorion-bot-reddit" -version = "6.0.7" +version = "6.1.0" edition = "2024" description = "factorion-bot (for factorials and related) on Reddit" license = "MIT" @@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math"] categories = ["mathematics", "web-programming", "parser-implementations"] [dependencies] -factorion-lib = {path = "../factorion-lib", version = "6.0.6", features = ["serde", "influxdb"]} +factorion-lib = {path = "../factorion-lib", version = "7.0.0", features = ["serde", "influxdb"]} reqwest = { version = "0.12.28", features = ["json", "native-tls"], default-features = false } serde = { version = "1.0.219", default-features = false, features = ["derive"] } serde_json = "1.0.145" diff --git a/factorion-lib/Cargo.toml b/factorion-lib/Cargo.toml index 0bce288..c7b539a 100644 --- a/factorion-lib/Cargo.toml +++ b/factorion-lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "factorion-lib" -version = "6.0.6" +version = "7.0.0" edition = "2024" description = "A library used to create bots to recognize and calculate factorials and related concepts" license = "MIT"