Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions factorion-bot-discord/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "factorion-bot-discord"
version = "2.5.2"
version = "3.0.0"
edition = "2024"
description = "factorion-bot (for factorials and related) on Discord"
license = "MIT"
Expand All @@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math", "discord"]
categories = ["mathematics", "web-programming", "parser-implementations"]

[dependencies]
factorion-lib = { path = "../factorion-lib", version = "5.0.2", features = ["serde", "influxdb"] }
factorion-lib = { path = "../factorion-lib", version = "6.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"
Expand Down
8 changes: 4 additions & 4 deletions factorion-bot-discord/src/discord_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<'a> Handler<'a> {
let extract_end = SystemTime::now();

factorion_lib::influxdb::discord::log_time_consumed(
&self.influx_client,
self.influx_client,
extract_start,
extract_end,
"extract_factorials",
Expand All @@ -163,7 +163,7 @@ impl<'a> Handler<'a> {
let calc_end = SystemTime::now();

factorion_lib::influxdb::discord::log_time_consumed(
&self.influx_client,
self.influx_client,
calc_start,
calc_end,
"calculate_factorials",
Expand Down Expand Up @@ -208,7 +208,7 @@ impl<'a> Handler<'a> {

// Log the reply to InfluxDB
factorion_lib::influxdb::discord::log_message_reply(
&self.influx_client,
self.influx_client,
&msg.id.to_string(),
&msg.author.name,
&msg.channel_id.to_string(),
Expand All @@ -220,7 +220,7 @@ impl<'a> Handler<'a> {

let end = SystemTime::now();
factorion_lib::influxdb::discord::log_time_consumed(
&self.influx_client,
self.influx_client,
start,
end,
"process_message",
Expand Down
6 changes: 3 additions & 3 deletions factorion-bot-discord/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
std::fs::read_to_string(file.path()).unwrap().leak(),
)
.unwrap();
locale.set_bot_disclaimer("".into());
locale.bot_disclaimer = "".into();
(file.file_name().into_string().unwrap(), locale)
})
.collect::<Box<_>>()
Expand All @@ -106,7 +106,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
.unwrap_or_else(|_| {
factorion_lib::locale::get_all()
.map(|(k, mut v)| {
v.set_bot_disclaimer("".into());
v.bot_disclaimer = "".into();
(k.to_owned(), v)
})
.collect()
Expand All @@ -124,7 +124,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
info!("InfluxDB client configured. Metrics will be logged.");
}

discord_api::start_bot(token, consts, &*INFLUX_CLIENT).await?;
discord_api::start_bot(token, consts, &INFLUX_CLIENT).await?;

Ok(())
}
4 changes: 2 additions & 2 deletions factorion-bot-reddit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "factorion-bot-reddit"
version = "5.6.2"
version = "6.0.0"
edition = "2024"
description = "factorion-bot (for factorials and related) on Reddit"
license = "MIT"
Expand All @@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math"]
categories = ["mathematics", "web-programming", "parser-implementations"]

[dependencies]
factorion-lib = {path = "../factorion-lib", version = "5.0.2", features = ["serde", "influxdb"]}
factorion-lib = {path = "../factorion-lib", version = "6.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.140"
Expand Down
20 changes: 8 additions & 12 deletions factorion-bot-reddit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,13 @@ fn en_str() -> &'static str {
"en"
}

#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Default)]
enum SubredditMode {
All,
PostOnly,
#[default]
None,
}
impl Default for SubredditMode {
fn default() -> Self {
Self::None
}
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -135,7 +131,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
let dont_reply = dont_reply == "true";

let sub_entries = if let Ok(path) = std::env::var("SUBREDDITS_FILE") {
if let Ok(_) = std::env::var("SUBREDDITS") {
if std::env::var("SUBREDDITS").is_ok() {
panic!("SUBREDDITS and SUBREDDITS_FILE can not be set simultaneusly!")
}
let text = std::fs::read_to_string(path).unwrap();
Expand Down Expand Up @@ -277,7 +273,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
continue;
}
let Ok(mut dense_id) = u64::from_str_radix(&comment.meta.thread, 36) else {
if comment.meta.thread == "" {
if comment.meta.thread.is_empty() {
info!("Empty thread id on comment {}", comment.meta.id);
} else {
warn!("Failed to make id dense {}", comment.meta.thread);
Expand Down Expand Up @@ -421,10 +417,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
factorion_lib::influxdb::reddit::log_comment_reply(
influx_client,
&comment_id,
&comment_author,
&comment_subreddit,
&comment_locale,
comment_id,
comment_author,
comment_subreddit,
comment_locale,
)
.await?;
}
Expand Down
8 changes: 4 additions & 4 deletions factorion-bot-reddit/src/reddit_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl RedditClient {

reset_timer = Self::update_reset_timer(reset_timer, t);

if last_ids.mentions != ""
if !last_ids.mentions.is_empty()
&& a.len()
== *COMMENT_COUNT.get().expect("Comment count uninitialized") as usize
{
Expand Down Expand Up @@ -296,7 +296,7 @@ impl RedditClient {

reset_timer = Self::update_reset_timer(reset_timer, t);

if last_ids.comments != ""
if !last_ids.comments.is_empty()
&& a.len()
== *COMMENT_COUNT.get().expect("Comment count uninitialized") as usize
{
Expand Down Expand Up @@ -324,7 +324,7 @@ impl RedditClient {

reset_timer = Self::update_reset_timer(reset_timer, t);

if last_ids.posts != ""
if !last_ids.posts.is_empty()
&& posts.len()
== *COMMENT_COUNT.get().expect("Comment count uninitialized") as usize
{
Expand Down Expand Up @@ -859,7 +859,7 @@ impl RedditClient {
error!("Failed to construct comment {comment_id}!");
return None;
};
comment.meta.used_commands = !(comment.commands == pre_commands);
comment.meta.used_commands = (comment.commands != pre_commands);
if let Some((mention, commands, mention_author)) = mention_map.get(comment_id) {
comment.meta.id = mention.clone();
comment.commands = *commands;
Expand Down
2 changes: 1 addition & 1 deletion factorion-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "factorion-lib"
version = "5.0.2"
version = "6.0.0"
edition = "2024"
description = "A library used to create bots to recognize and calculate factorials and related concepts"
license = "MIT"
Expand Down
142 changes: 71 additions & 71 deletions factorion-lib/Locales.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,80 @@ Locales contain a few different kinds of settings:
- Toggles: on is true, off is false
- Map, a list of key value pairs for certain settings, used for overrides

## V1
## Example
```jsonc
// Version number
{ "V1":
{
// The little disclaimer at the end of a comment
"bot_disclaimer": "This action was performed by a bot | [Source code](http://f.r0.fyi)",
// The notes at the beginning of a comment
"notes": {
"tower": "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.",
"tower_mult": "Some of these are so large, that I can't even give the number of digits of them, so I have to make a power of ten tower.",
"digits": "That number is so large, that I can't even approximate it well, so I can only give you an approximation on the number of digits.",
"digits_mult": "Some of these are so large, that I can't even approximate them well, so I can only give you an approximation on the number of digits.",
"approx": "That is so large, that I can't calculate it, so I'll have to approximate.",
"approx_mult": "Some of those are so large, that I can't calculate them, so I'll have to approximate.",
"round": "I can't calculate such a large factorial of decimals. So I had to round at some point.",
"round_mult": "I can't calculate that large factorials of decimals. So I had to round at some point.",
"too_big": "If I post the whole number, the comment would get too long. So I had to turn it into scientific notation.",
"too_big_mult": "If I post the whole numbers, the comment would get too long. So I had to turn them into scientific notation.",
"remove": "If I posted all numbers, the comment would get too long. So I had to remove some of them.",
"tetration": "That is so large, I can't even fit it in a comment with a power of 10 tower, so I'll have to use tetration!",
"no_post": "Sorry, but the reply text for all those numbers would be _really_ long, so I'd rather not even try posting lmao",
// How to call out to a user (when mentioning them). "{mention}" is replaced by the user string formatted as a mention
"mention": "Hey {mention}!"
{
// The little disclaimer at the end of a comment
"bot_disclaimer": "This action was performed by a bot | [Source code](http://f.r0.fyi)",
// The notes at the beginning of a comment
"notes": {
"tower": "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.",
"tower_mult": "Some of these are so large, that I can't even give the number of digits of them, so I have to make a power of ten tower.",
"digits": "That number is so large, that I can't even approximate it well, so I can only give you an approximation on the number of digits.",
"digits_mult": "Some of these are so large, that I can't even approximate them well, so I can only give you an approximation on the number of digits.",
"approx": "That is so large, that I can't calculate it, so I'll have to approximate.",
"approx_mult": "Some of those are so large, that I can't calculate them, so I'll have to approximate.",
"round": "I can't calculate such a large factorial of decimals. So I had to round at some point.",
"round_mult": "I can't calculate that large factorials of decimals. So I had to round at some point.",
"too_big": "If I post the whole number, the comment would get too long. So I had to turn it into scientific notation.",
"too_big_mult": "If I post the whole numbers, the comment would get too long. So I had to turn them into scientific notation.",
"remove": "If I posted all numbers, the comment would get too long. So I had to remove some of them.",
"tetration": "That is so large, I can't even fit it in a comment with a power of 10 tower, so I'll have to use tetration!",
"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.",
// How to call out to a user (when mentioning them). "{mention}" is replaced by the user string formatted as a mention
"mention": "Hey {mention}!"
},
// Formatting calculations
"format": {
// Formatting numbers
"number_format": {
// The number decimal separator (also used when parsing). Must be a single character
"decimal": "."
},
// Formatting calculations
"format": {
// Formatting numbers
"number_format": {
// The number decimal separator (also used when parsing). Must be a single character
"decimal": "."
},
// Whether to capitalize the start of the calculation word (sub, uple, termial or factorial) (ASCII only)
"capitalize_calc": false,
"termial": "termial",
"factorial": "factorial",
// What to call tuples. "{factorial}" is replaced by termial or factorial
"uple": "uple-{factorial}",
// What to call a subfactorial. "{factorial}" is replaced by termial (not currently) or factorial
"sub": "sub{factorial}",
// How to call a negative calculation. "{factorial}" is replaced by sub, uple, termial or factorial
"negative": "negative {factorial}",
// Overrides for individual tuples. "{factorial}" is replaced by termial or factorial
"num_overrides": {
"2": "double-{factorial}",
"3": "triple-{factorial}"
},
// Turn off automatic tuple names (use overrides and numbers)
"force_num": false,
// How to write nested factorials. "{factorial}" is replaced by the outer calculation, "{next}" by the inner (both being negative, sub, uple, termial or factorial)
"nest": "{factorial} of {next}",
// How to write a calculation with an exact result. "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"exact": "{factorial} of {number} is {result}",
// How to write a calculation with a shortened result. "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"rough": "{factorial} of {number} is roughly {result}",
// How to write a calculation with an approximate result. "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"approx": "{factorial} of {number} is approximately {result}",
// How to write a calculation with a result given in approximate number of digits. "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"digits": "{factorial} of {number} has approximately {result} digits",
// How to write a calculation with a result given in a power-of-ten tower number of digits.
// "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"order": "{factorial} of {number} has on the order of {result} digits",
// How to write a calculation with a result given in tetration of ten number of digits, and no calculation steps.
// "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"all_that": "All that of {number} has on the order of {result} digits",
// How to write a shortened number. "{number}" is replaced by the input to the calculation
"rough_number": "roughly {number}"
}
// Whether to capitalize the start of the calculation word (sub, uple, termial or factorial) (ASCII only)
"capitalize_calc": false,
"termial": "termial",
"factorial": "factorial",
// What to call tuples. "{factorial}" is replaced by termial or factorial
"uple": "uple-{factorial}",
// What to call a subfactorial. "{factorial}" is replaced by termial (not currently) or factorial
"sub": "sub{factorial}",
// How to call a negative calculation. "{factorial}" is replaced by sub, uple, termial or factorial
"negative": "negative {factorial}",
// Overrides for individual tuples. "{factorial}" is replaced by termial or factorial
"num_overrides": {
"2": "double-{factorial}",
"3": "triple-{factorial}"
},
// Turn off automatic tuple names (use overrides and numbers)
"force_num": false,
// How to write nested factorials. "{factorial}" is replaced by the outer calculation, "{next}" by the inner (both being negative, sub, uple, termial or factorial)
"nest": "{factorial} of {next}",
// How to write a calculation with an exact result. "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"exact": "{factorial} of {number} is {result}",
// How to write a calculation with a shortened result. "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"rough": "{factorial} of {number} is roughly {result}",
// How to write a calculation with an approximate result. "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"approx": "{factorial} of {number} is approximately {result}",
// How to write a calculation with a result given in approximate number of digits. "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"digits": "{factorial} of {number} has approximately {result} digits",
// How to write a calculation with a result given in a power-of-ten tower number of digits.
// "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"order": "{factorial} of {number} has on the order of {result} digits",
// How to write a calculation with a result given in tetration of ten number of digits, and no calculation steps.
// "{factorial}" is replaced by nest, negative, sub, uple, termial or factorial,
// "{number}" by the input to the calculation or rough_number and "{result}" by the result
"all_that": "All that of {number} has on the order of {result} digits",
// How to write a shortened number. "{number}" is replaced by the input to the calculation
"rough_number": "roughly {number}"
}
}
```
Loading