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"
diff --git a/factorion-lib/src/comment.rs b/factorion-lib/src/comment.rs
index 7ccacf4..ef84ec9 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 the former 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 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": {
diff --git a/factorion-lib/src/locale.rs b/factorion-lib/src/locale.rs
index 082edbf..4e46d2c 100644
--- a/factorion-lib/src/locale.rs
+++ b/factorion-lib/src/locale.rs
@@ -46,15 +46,27 @@ 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> {
pub bot_disclaimer: Cow<'a, str>,
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> {
pub tower: Cow<'a, str>,
pub tower_mult: Cow<'a, str>,
@@ -72,10 +84,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)]
+#[derive(Debug, Clone, Default)]
#[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 +112,13 @@ pub struct Format<'a> {
#[derive(Debug, Clone)]
#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
+#[non_exhaustive]
pub struct NumFormat {
pub decimal: char,
}
+
+impl Default for NumFormat {
+ fn default() -> Self {
+ NumFormat { decimal: '.' }
+ }
+}
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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