diff --git a/data/lang/en.json b/data/lang/en.json index fac98e4..c8e2c85 100644 --- a/data/lang/en.json +++ b/data/lang/en.json @@ -1,62 +1,40 @@ { - "8-ball_answer": "Q: {0}\nA: {1}", - "add_to_data": "Added your server to my data! Thanks for letting me steal it! (/s)", - "bound_dc_channel": "Successfully bound channel ID `{0}` as the bk_week channel!", - "cfg_data_404": "cfg.json not found,", - "cfg_data_wipe": "[WIPE] (cfg.json)", - "cmd_404": "No command with the name \"{0}\" found!\nHint: Try `/help` without any arguments or `/help `", - "corrupted_data": "Oopsies `(。>\\\\<)`. It looks like my data i-is \\**sob*\\*... c-corrupted!", - "couldnt_shorturl": "Couldn't convert to shortURL: Invalid URL", - "creating_data_file": "{0} creating new from preset...", - "data_post_embed": "Spoilers and vote length anonymizer for fair review!\n ## Post Data:\n **Post upvotes:** ||`{0:>6}`||\n **Moderator votes:** ||`{1:>6}`||\n **Media type:** `{2}`\n **URL:** ||<{3}>||\n\n ## Listing Data:\n **Added by:** `{{ human: {4}, bot: {5} }}`\n **Approved by:** `{{ human: {6}, bot: [not implemented] }}`", - "data_post_removed_embed": "## Removed by `{0}`\n**Reason:** {1}\nURL: ||<{2}>||\n\nJSON: ||`{3}`||", - "data_save_complete": "Saving data... Done!\nShutting down...", - "data_save_progress": "Saving data...", - "dc_404": "Your server is not in the data!\n Hint: Run the command `/add_server` inside of a Discord server.", - "dc_bot_started": "Bot started as user \"{0}\" with id {1}", - "dc_bot_starting": "Starting bot...", - "dc_data_404": "discord_data.json not found,", - "dc_data_wipe": "[WIPE] (discord_data.json)", - "default_embed_desc": "Default description", - "err_read_py_file": "Failed to read Python file!\nPath: {0}", - "help_text_removed": "Help text not found. Someone deleted it. :(", - "invalid_confirm_shutdown": "Failed to shut down: Invalid confirmation.", - "invalid_os": "Man what kinda OS do you have? Neither unix or windows, what the hell!? I can't process this anymore, you're too weird!", - "lang_data_404": "File for language \"{0}\" not found!", - "lang_load_success": "Successfully loaded the english language file!", - "mandatory_response": "Mandatory response message, please ignore.", - "python_err": "Unknown internal Python Error: {0}", - "python_socket_binary_response": "[Binary] from Python: {0}", - "python_socket_err": "Unknown internal Python error occurred: Websocket response error.", - "python_socket_null": "Response from Python is None!", - "python_socket_response": "Received from Python: [RESPONSE] {0}", - "python_socket_unknown_response": "Received from Python: [UNKNOWN / OTHER]", - "re_404": "Post URL \"<{0}>\" not found: Post doesn't exist in the data!\n Hint: Run the command `/re_addPost [URL]` in a Discord channel or `u/ByteDiceAssistant bk_week_add` in a Reddit post.", - "re_add_post_success": "Added post with URL \"<{0}>\"!", - "re_already_voted": "Couldn't cast a vote: You have already voted on this post!", - "re_also_approved": "Also approved it!", - "re_approved_post_success": "Successfully approved the post!", - "re_data_404": "reddit_data.json not found,", - "re_data_corrupted": "Post URL \"<{0}>\" not found: Post data is corrupted!\n Full details: Could not find key \"bk_weekly_art_posts\" in data file \"reddit_data.json\"", - "re_data_wipe": "[WIPE] (reddit_data.json)", - "re_disapproved_post_success": "Successfully disapproved the post!", - "re_err_trace": "Unknown error!\nError trace: {0}.", - "re_havent_voted_remove_vote": "Couldn't remove your vote: You haven't voted on this post yet!", - "re_permdeny_bk_mod": "Permission denied: You are not a moderator of {0}", - "re_remove_post_success": "Successfully removed post!", - "re_unremove_post_success": "Successfully un-removed post with URL \"<{0}>\"!", - "re_update_post_success": "Updated post with URL \"<{0}>\"!", - "re_vote_err": "Failed to vote/un-vote: Unknown internal error", - "re_vote_remove_success": "Successfully removed vote!", - "re_vote_success_mod": "Successfully voted (as moderator vote)!", - "re_vote_success": "Successfully voted!", - "reload_config_python_fail": "Failed to reload configs: Failed-type response from Python.", - "reload_config_success": "Successfully reloaded the configs!\nNew configs:\n```\n{0}\n```", - "shorturl": "ShortURL: <{0}>", - "socket_received_python": "Received from Python: {0}", - "socket_rust_connection_test": "[Connection test] Hello from Rust!", - "started_socket": "WebSocket server running on ws://{0}", - "starting_python_program": "Running Python program...", - "starting_schedules": "Starting schedules...", - "starting_socket": "Starting local websocket..." + "dc_msg_8-ball_answer": "## You shook a magic 8-ball\nQ: {0}\nA: {1}", + "dc_msg_add_to_data": "Added your server to my data! Thanks for letting me steal it! (/s)", + "dc_msg_bound_channel": "Successfully bound channel ID `{0}` as the \"where all collected Reddit data gets dumped\" channel!", + "dc_msg_cmd_404": "No command \"{0}\" found!\nHint: Try `/help` without any arguments or `/help `", + "dc_msg_corrupted_data": "Oopsies `(。>\\\\<)`. It looks like my data i-is \\**sob*\\*... c-corrupted!\n[From Byte Dice]: I have no idea what I was thinking while writing this at 2am. I'm not removing it.", + "dc_msg_dm_python_err_socket": "Unknown internal Python error occurred: Websocket response error", + "dc_msg_dm_python_err": "Unknown internal Python Error: {0}", + "dc_msg_embed_default_embed_desc": "Default english embed description.", + "dc_msg_embed_re_post": "Spoilers and vote length anonymizer for fair review!\n## Post Data:\n**Post upvotes:** ||`{0:>6}`||\n**Moderator votes:** ||`{1:>6}`||\n**Media type:** `{2}`\n**URL:** ||<{3}>||\n\n## Listing Data:\n**Added by:** `{{ human: {4}, bot: {5} }}`\n**Approved by:** `{{ human: {6}, bot: [not implemented] }}`", + "dc_msg_embed_re_removed": "## Removed by `{0}`\n**Reason:** {1}\nURL: ||<{2}>||\n\nJSON: ||`{3}`||", + "dc_msg_err_trace": "Unknown error!\nError trace: {0}", + "dc_msg_failed_shorturl_conversion": "Couldn't convert to shortURL: Invalid Reddit URL format.", + "dc_msg_mandatory_response": "Mandatory response message, please ignore.", + "dc_msg_owner_data_save_complete": "Saving data... Done!\nShutting down...", + "dc_msg_owner_data_save": "Saving data...", + "dc_msg_owner_shutdown_failed_confirmation": "Failed to shut down: Invalid confirmation.", + "dc_msg_re_already_voted": "Couldn't cast a vote: You have already voted on this post!", + "dc_msg_re_also_approved": "Also approved it!", + "dc_msg_re_data_corrupted": "Post URL \"<{0}>\" not found: Post data is corrupted!\n Full details: Could not find key \"bk_weekly_art_posts\" in data file \"reddit_data.json\"", + "dc_msg_re_help_removed": "Reddit help file not found, someone likely deleted it.\n Hint: You can find the official help text at https://github.com/ByteDice/ByteDiceAssistant in `bk_week_help_re.md`.\n**CAUTION:** The official help file may contain incorrect information if you're not using the official bot by Byte Dice.", + "dc_msg_re_permdeny_not_re_mod": "Permission denied: You are not a moderator of the subreddit(s) {0}", + "dc_msg_re_post_404": "Post URL \"<{0}>\" not found: Post doesn't exist in the data!\n Hint: Run the command `/re_addPost [URL]` in a Discord channel or `u/ByteDiceAssistant bk_week_add` in a Reddit post.", + "dc_msg_re_post_add_success": "Added post with URL \"<{0}>\"!", + "dc_msg_re_post_approve_success": "Successfully approved the post!", + "dc_msg_re_post_disapprove_success": "Successfully disapproved the post!", + "dc_msg_re_post_remove_success": "Successfully removed post!", + "dc_msg_re_post_unremove_success": "Successfully un-removed post with URL \"<{0}>\"!", + "dc_msg_re_post_update_success": "Updated post with URL \"<{0}>\"!", + "dc_msg_re_vote_err": "Failed to vote/un-vote: Unknown internal error.", + "dc_msg_re_vote_mod_success": "Successfully voted (as moderator vote)!", + "dc_msg_re_vote_remove_havent": "Couldn't remove your vote: You haven't voted on this post yet!", + "dc_msg_re_vote_remove_success": "Successfully removed vote!", + "dc_msg_re_vote_success": "Successfully voted!", + "dc_msg_reload_cfg_python_fail": "Failed to reload configs: Failed-type response from Python.", + "dc_msg_reload_cfg_success": "Successfully reloaded the configs!\nNew configs:\n```\n{0}\n```", + "dc_msg_server_data_404": "This server is not in the data!\n Hint: Run the command `/add_server` inside of a Discord server (requires administrator permission).", + "dc_msg_shorturl": "ShortURL: <{0}>", + "log_lang_load_success": "Successfully loaded the english language file!" } \ No newline at end of file diff --git a/data/lang/miserable.json b/data/lang/miserable.json deleted file mode 100644 index ac287f5..0000000 --- a/data/lang/miserable.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "8-ball_answer": "?: {0}\n!: {1}", - "add_to_data": "Something something selling data something.", - "bound_dc_channel": "Random numbers, go! `{0}`", - "cfg_data_404": "I'm not telling you the error but I think it's something about your pc having malware :) ", - "cfg_data_wipe": "[WIPE MY ASS] file.file_extention something.", - "cmd_404": "Great, you executed `{0}`!", - "corrupted_data": "p4Oad3!an5!#####", - "couldnt_shorturl": "ShortURL: https://ILoveBurritos.com/yourRedditURL.", - "creating_data_file": "{0} (not taking care of the malware).", - "data_post_embed": "## Figure it out:\n **Figure it out:** ||`{0:>6}`||\n **Figure it out:** ||`{1:>6}`||\n **Figure it out:** `{2}`\n **Figure it out:** ||<{3}>||\n\n ## Figure it out:\n **Figure it out:** `{{ human: {4}, bot: {5} }}`\n **Figure it out:** `{{ human: {6}, bot: [not implemented] }}`", - "data_post_removed_embed": "## Approved by `{0}`\n**Reason:** {1}\nURL: ||<{2}>||\n\nJSON: ||`{3}`||", - "data_save_complete": "Discarding data... Done!\nShutting down...", - "data_save_progress": "Discarding data...", - "dc_404": "Everything went well!", - "dc_bot_started": "Couldn't start bot \"{0}\" with id {1}: Someone else is currently running the same bot.", - "dc_bot_starting": "Starting bot...", - "dc_data_404": "I'm not telling you the error but I think it's something about your pc having malware :) ", - "dc_data_wipe": "[WIPE MY ASS] file.file_extention something", - "default_embed_desc": "The person who created this is stupid for not adding a description.", - "err_read_py_file": "Successfully read Python file: (Path) {0}", - "help_text_removed": "We hate providing help to you specifically!", - "invalid_confirm_shutdown": "Discarding data... Done!\nShutting down...", - "invalid_os": "Man what kinda OS do you have? Neither unix or windows, what the hell!? I can't process this anymore, you're too weird!", - "lang_data_404": "Successfully loaded language \"{0}\"!", - "lang_load_success": "Failed to load the english language file!", - "mandatory_response": "Annoying message you can't get rid of.", - "python_err": "Looking good! {0}\nIgnore what's above me.", - "python_socket_binary_response": "Corrupted data found: {0}", - "python_socket_err": "Websocket response test successfully completed!", - "python_socket_null": "Received from Python: [UNKNOWN / OTHER]", - "python_socket_response": "Received from alien contact: {0}", - "python_socket_unknown_response": "Lettuce", - "re_404": "\"<{0}>\" is a funny post URL, am I right?", - "re_add_post_success": "Removed post with URL \"<{0}>\"!", - "re_already_voted": "Successfully voted!", - "re_also_approved": "Nevermind, that post sucks.", - "re_approved_post_success": "Successfully added the post!", - "re_data_404": "I'm not telling you the error but I think it's something about your pc having malware :) ", - "re_data_corrupted": "\"<{0}>\" is a funny post URL, am I right?", - "re_data_wipe": "[WIPE MY ASS] file.file_extention something", - "re_disapproved_post_success": "Successfully removed the post!", - "re_err_trace": "I got this random file path thingy, here you go: {0}.", - "re_havent_voted_remove_vote": "Successfully voted!", - "re_permdeny_bk_mod": "Welcome to the {0} team!", - "re_remove_post_success": "Successfully", - "re_unremove_post_success": "Successfully removed post with URL \"<{0}>\"!", - "re_update_post_success": "\"<{0}>\"!", - "re_vote_err": "Successfully voted!", - "re_vote_remove_success": "Successfully voted!", - "re_vote_success_mod": "Successfully voted!", - "re_vote_success": "Successfully voted (as moderator vote)!", - "reload_config_python_fail": "Successfully reloaded the configs!", - "reload_config_success": "I didn't update them, but here you go anyways:\n```\n{0}\n```", - "shorturl": "Invalid shortURL, try again. Here's a random one though: <{0}>", - "socket_received_python": "Sent to Python: {0}", - "socket_rust_connection_test": "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", - "started_socket": "Your IPv4 address: {0}", - "starting_python_program": "Running Rust program...", - "starting_schedules": "Starting spyware...", - "starting_socket": "Starting global websocket..." -} \ No newline at end of file diff --git a/src/cmds.rs b/src/cmds.rs index 18c9b18..5fb9afb 100644 --- a/src/cmds.rs +++ b/src/cmds.rs @@ -6,7 +6,7 @@ use crate::data::{dc_add_server, get_mutex_data, read_cfg_data}; use crate::re_cmds::generic_fns::to_shorturl; use crate::websocket::send_cmd_json; use crate::{data, lang, Context, Data, Error}; -use crate::messages::{edit_reply, send_embed, send_msg, Author, EmbedOptions, MANDATORY_MSG}; +use crate::messages::{edit_reply, send_embed, send_msg, Author, EmbedOptions}; use poise::serenity_prelude::{OnlineStatus, Timestamp}; use poise::Command; @@ -15,6 +15,9 @@ use serde_json::json; use tokio::fs; +// TODO: separate to multiple files + + #[derive(poise::ChoiceParameter, PartialEq)] enum HelpOptions { Admin, @@ -63,19 +66,19 @@ pub async fn stop( || confirmation.unwrap_or_default().to_lowercase() == "i want to stop the bot now"; if should_stop { - let msg = send_msg(ctx, lang!("data_save_progress"), true, true).await.unwrap(); + let msg = send_msg(ctx, lang!("dc_msg_owner_data_save"), true, true).await.unwrap(); data::write_dc_data(ctx.data()).await; data::write_re_data().await; send_cmd_json("stop_praw", None).await; - edit_reply(ctx, msg, lang!("data_save_complete")).await; + edit_reply(ctx, msg, lang!("dc_msg_owner_data_save_complete")).await; ctx.serenity_context().set_presence(None, OnlineStatus::Invisible); ctx.framework().shard_manager.shutdown_all().await; process::exit(0); } else { - send_msg(ctx, lang!("invalid_confirm_shutdown"), true, true).await; + send_msg(ctx, lang!("dc_msg_owner_shutdown_failed_confirmation"), true, true).await; } return Ok(()); @@ -124,7 +127,7 @@ pub async fn embed( ).await; if !reply_unwrap { - send_msg(ctx, MANDATORY_MSG.to_string(), true, true).await; + send_msg(ctx, lang!("dc_msg_mandatory_response"), true, true).await; } return Ok(()); @@ -146,7 +149,7 @@ pub async fn send( ) -> Result<(), Error> { send_msg(ctx, msg.replace("\\n", "\n"), false, false).await; - send_msg(ctx, MANDATORY_MSG.to_string(), true, true).await; + send_msg(ctx, lang!("dc_msg_mandatory_response"), true, true).await; return Ok(()); } @@ -171,7 +174,7 @@ pub async fn eight_ball( send_msg( ctx, - lang!("8-ball_answer", question, rand_item.unwrap()), + lang!("dc_msg_8-ball_answer", question, rand_item.unwrap()), true, true ).await; @@ -194,10 +197,10 @@ pub async fn re_shorturl( let shorturl = to_shorturl(&url); if shorturl.is_ok() { - send_msg(ctx, lang!("shorturl", shorturl.unwrap()), true, true).await; + send_msg(ctx, lang!("dc_msg_shorturl", shorturl.unwrap()), true, true).await; } else { - send_msg(ctx, lang!("couldnt_shorturl"), true, true).await; + send_msg(ctx, lang!("dc_msg_failed_shorturl_conversion"), true, true).await; } return Ok(()); @@ -220,10 +223,10 @@ pub async fn add_server( let r = dc_add_server(ctx.data(), ctx.guild_id().unwrap().into()).await; if r.is_ok() { - send_msg(ctx, lang!("add_to_data"), true, true).await; + send_msg(ctx, lang!("dc_msg_added_to_data"), true, true).await; } else { - send_msg(ctx, lang!("corrupted_data"), true, true).await; + send_msg(ctx, lang!("dc_msg_corrupted_data"), true, true).await; } return Ok(()); @@ -250,14 +253,14 @@ pub async fn reload_cfg( if r.is_some() && r.unwrap()["value"].as_bool().unwrap() { send_msg( ctx, - lang!("reload_config_success", serde_json::to_string_pretty(&d).unwrap()), + lang!("dc_msg_reload_cfg_success", serde_json::to_string_pretty(&d).unwrap()), true, true ).await; return Ok(()); } - send_msg(ctx, lang!("reload_config_python_fail"), true, true).await; + send_msg(ctx, lang!("dc_msg_reload_cfg_python_fail"), true, true).await; return Ok(()); } @@ -329,7 +332,7 @@ async fn send_single_help(ctx: Context<'_>, mut cmd_name: String) { if cmd.is_none() { send_msg( ctx, - lang!("cmd_404", cmd_name), + lang!("dc_msg_cmd_404", cmd_name), true, true ).await; @@ -355,7 +358,7 @@ async fn send_category_help(ctx: Context<'_>, category: HelpOptions) { async fn send_bk_week_help_re(ctx: Context<'_>) { let t: String = fs::read_to_string("./bk_week_help_re.md").await - .unwrap_or(lang!("help_text_removed")); + .unwrap_or(lang!("dc_msg_re_help_removed")); send_msg(ctx, t, true, true).await; } diff --git a/src/data.rs b/src/data.rs index f3eca25..1f8a81a 100644 --- a/src/data.rs +++ b/src/data.rs @@ -4,7 +4,7 @@ use std::path::Path; use serde_json::{self, Value, json}; use tokio::sync::Mutex; -use crate::{lang, rs_println, Data, Error, BK_WEEK, LANG}; +use crate::{errln, rs_println, Data, Error, BK_WEEK, LANG}; use crate::websocket::send_cmd_json; @@ -20,8 +20,8 @@ static DATA_PATH_LANG: &str = "./data/lang/"; pub async fn read_dc_data(data: &Data, wipe: bool) { if !Path::new(DATA_PATH_DC).exists() || wipe { rs_println!( - "{}", - lang!("creating_data_file", if !wipe { lang!("dc_data_404") } else { lang!("dc_data_wipe") }) + "{} creating new from preset...", + if !wipe { "discord_data.json not found," } else { "[WIPE] (discord_data.json)" } ); generate_dc_data(); } @@ -71,8 +71,8 @@ pub async fn write_dc_data(data: &Data) { pub async fn read_re_data(data: &Data, wipe: bool) { if !Path::new(DATA_PATH_RE).exists() || wipe { rs_println!( - "{}", - lang!("creating_data_file", if !wipe { lang!("re_data_404") } else { lang!("re_data_wipe") }) + "{} creating new from preset...", + if !wipe { "reddit_data.json not found," } else { "[WIPE] (reddit_data.json)" } ); generate_re_data(); } @@ -114,8 +114,8 @@ pub async fn write_re_data() { pub async fn read_cfg_data(data: &Data, wipe: bool) { if !Path::new(DATA_PATH_CFG).exists() || wipe { rs_println!( - "{}", - lang!("creating_data_file", if !wipe { lang!("cfg_data_404") } else { lang!("cfg_data_wipe") }) + "{} creating new from preset...", + if !wipe { "cfg.json not found," } else { "[WIPE] (cfg.json)" } ); generate_cfg_data(); } @@ -202,11 +202,10 @@ pub fn load_lang_data(lang: String) { let full_path = format!("{}{}.json", DATA_PATH_LANG, lang); if !Path::new(&full_path).exists() { - rs_println!( - "{}", - lang!("creating_data_file", lang!("cfg_data_404", lang)) + errln!( + "File for language \"{0}\" ({0}.json) not found!\n Hint: You can download official language files at https://github.com/ByteDice/ByteDiceAssistant in the data/langs/... folder", + lang ); - generate_cfg_data(); } let str_data = fs::read_to_string(full_path).unwrap(); diff --git a/src/events.rs b/src/events.rs index 098d575..aa8f1d9 100644 --- a/src/events.rs +++ b/src/events.rs @@ -1,4 +1,4 @@ -use crate::{lang, rs_println, Data, Error}; +use crate::{rs_println, Data, Error}; use poise::serenity_prelude::{self as serenity, ActivityData}; @@ -14,12 +14,9 @@ pub fn event_handler<'a>( Box::pin(async move { if let serenity::FullEvent::Ready { data_about_bot } = event { rs_println!( - "{}", - lang!( - "dc_bot_started", - data_about_bot.user.name.clone(), - data_about_bot.user.id - ) + "Bot started as user \"{}\" with id {}", + data_about_bot.user.name, + data_about_bot.user.id ); let file_text = std::fs::read_to_string("./data/status.txt").unwrap(); diff --git a/src/main.rs b/src/main.rs index bf17a00..13a1315 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,6 @@ use websocket::send_cmd_json; use crate::schedule::Schedule; -// TODO: convert to lang! #[derive(Parser, Serialize, Clone)] struct Args { @@ -92,7 +91,7 @@ async fn main() { rs_println!("Fetching language file..."); data::load_lang_data(args.clone().lang); - rs_println!("{}", lang!("lang_load_success")); + rs_println!("[IMPORTANT] The below message is a test message, it should be written in the language you've selected\n{}", lang!("log_lang_load_success")); let own_env = std::env::var("ASSISTANT_OWNERS").unwrap_or("0".to_string()); let own_vec_str: Vec = own_env.split(",").map(String::from).collect(); @@ -156,7 +155,7 @@ async fn start(args: Args, owners: Vec) { let data = gen_data(args.clone(), owners).await; let mut bot = gen_bot(data, args).await; - rs_println!("{}", lang!("dc_bot_starting")); + rs_println!("Starting Discord bot..."); bot.start().await.unwrap(); } diff --git a/src/messages.rs b/src/messages.rs index 5b5ccc9..3c5191e 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -29,7 +29,7 @@ pub struct EmbedOptions { impl Default for EmbedOptions { fn default() -> Self { return EmbedOptions { - desc: lang!("default_embed_desc"), + desc: lang!("dc_msg_embed_default_embed_desc"), title: None, col: None, url: None, @@ -45,7 +45,6 @@ impl Default for EmbedOptions { static DEFAULT_DC_COL: u32 = 5793266; static REMOVED_DC_COL: u32 = 16716032; -pub static MANDATORY_MSG: &str = "Mandatory response, please ignore."; fn none_to_empty(string: Option) -> String { @@ -198,7 +197,7 @@ pub fn make_post_embed(post_data: &Value, url: &str, ephemeral: bool) -> EmbedOp let media_type = &post_data["post_data"]["media_type"]; let desc_str = lang!( - "data_post_embed", + "dc_msg_embed_re_post", post_data["post_data"]["upvotes"].as_i64().unwrap(), post_data["votes"]["mod_voters"].as_array().unwrap().len(), if !media_type.is_null() { media_type.as_str().unwrap() } else { "None" }, @@ -242,7 +241,7 @@ pub fn make_removed_embed(post_data: &Value, url: &str, ephemeral: bool) -> Embe return EmbedOptions { title: Some("REMOVED!".to_string()), desc: lang!( - "data_post_removed_embed", + "dc_msg_embed_re_removed", post_data["removed_by"].as_str().unwrap(), if !post_data["remove_reason"].is_null() { post_data["remove_reason"].as_str().unwrap() } else { "None" }, diff --git a/src/python.rs b/src/python.rs index d6146b2..fce7731 100644 --- a/src/python.rs +++ b/src/python.rs @@ -10,12 +10,12 @@ use pyo3::types::PyList; pub async fn start(args: Args) -> PyResult<()> { - rs_println!("{}", lang!("starting_python_program")); + rs_println!("Running Python program..."); let args_str = serde_json::to_string(&args).expect("Error serializing args to JSON"); let slash = if cfg!(windows) { "\\" } else if cfg!(unix) { "/" } else { "" }; - if slash.is_empty() { errln!("{}", lang!("invalid_os")); } + if slash.is_empty() { errln!("Man what kinda OS do you have? Neither unix or windows, what the hell!? I can't process this anymore, you're too weird!"); } let path = format!("{0}{1}src{1}python", env!("CARGO_MANIFEST_DIR"), slash); @@ -43,7 +43,7 @@ pub async fn start(args: Args) -> PyResult<()> { .map(|s| s.parse::().expect("Failed to parse ASSISTANT_OWNERS. Invalid syntax.")) .collect(); - send_dm(lang!("python_err", format!("{:?}", from_python)), args, own_vec_u64).await; + send_dm(lang!("dc_msg_dm_python_err", format!("{:?}", from_python)), args, own_vec_u64).await; errln!("pyO3: {:?}", from_python); } return Ok(()); diff --git a/src/re_cmds/add.rs b/src/re_cmds/add.rs index 689fad3..7e24838 100644 --- a/src/re_cmds/add.rs +++ b/src/re_cmds/add.rs @@ -21,7 +21,7 @@ pub async fn cmd( ) -> Result<(), Error> { if !is_bk_mod(ctx.data().bk_mods.clone(), ctx.author().id.get()) { - send_msg(ctx, lang!("re_permdeny_bk_mod"), false, false).await; + send_msg(ctx, lang!("dc_msg_re_permdeny_not_re_mod"), false, false).await; // TODO: add subreddit arg to lang return Ok(()); } @@ -49,18 +49,18 @@ pub async fn cmd( if let Some(post) = bk_week.get(shorturl) { if post.get("removed").is_some() { - send_msg(ctx, lang!("re_unremove_post_success", url), true, true).await; + send_msg(ctx, lang!("dc_msg_re_post_unremove_success", url), true, true).await; } else { - send_msg(ctx, lang!("re_update_post_success", url), true, true).await; + send_msg(ctx, lang!("dc_msg_re_post_update_success", url), true, true).await; } } else { - send_msg(ctx, lang!("re_add_post_success", &shorturl), true, true).await; + send_msg(ctx, lang!("dc_msg_re_post_add_success", &shorturl), true, true).await; } if a { - send_msg(ctx, lang!("re_also_approved"), true, true).await; + send_msg(ctx, lang!("dc_msg_re_also_approved"), true, true).await; } } diff --git a/src/re_cmds/admin_bind.rs b/src/re_cmds/admin_bind.rs index 9336004..675ea39 100644 --- a/src/re_cmds/admin_bind.rs +++ b/src/re_cmds/admin_bind.rs @@ -18,10 +18,10 @@ pub async fn cmd( let r = dc_bind_bk(ctx.data(), ctx.guild_id().unwrap().into(), c_id).await; if r.is_ok() { - send_msg(ctx, lang!("bound_dc_channel", c_id), true, true).await; + send_msg(ctx, lang!("dc_msg_bound_channel", c_id), true, true).await; } else { - send_msg(ctx, lang!("dc_404"), false, false).await; + send_msg(ctx, lang!("dc_msg_server_data_404"), false, false).await; } return Ok(()); diff --git a/src/re_cmds/approve.rs b/src/re_cmds/approve.rs index ed3eeaf..da3b8c2 100644 --- a/src/re_cmds/approve.rs +++ b/src/re_cmds/approve.rs @@ -19,7 +19,7 @@ pub async fn cmd( ) -> Result<(), Error> { if !is_bk_mod(ctx.data().bk_mods.clone(), ctx.author().id.get()) { - send_msg(ctx, lang!("re_permdeny_bk_mod"), false, false).await; + send_msg(ctx, lang!("dc_msg_re_permdeny_not_re_mod"), false, false).await; return Ok(()); } @@ -42,17 +42,17 @@ async fn approve_cmd(ctx: Context<'_>, url: &str, reddit_data: &Value, approve: let r = websocket::send_cmd_json("set_approve_post", Some(json!([approve, &url]))).await.unwrap(); if r.get("value").is_some() { if approve { - send_msg(ctx, lang!("re_approve_post_success"), true, true).await; + send_msg(ctx, lang!("dc_msg_re_post_approve_success"), true, true).await; } else { - send_msg(ctx, lang!("re_disapprove_post_success"), true, true).await; + send_msg(ctx, lang!("dc_msg_re_post_disapprove_success"), true, true).await; } } else { - send_msg(ctx, lang!("re_err_trace", "`re_cmds -> approve.rs -> cmd() -> unwrap websocket result error`"), true, true).await; + send_msg(ctx, lang!("dc_msg_err_trace", "`re_cmds -> approve.rs -> cmd() -> unwrap websocket result error`"), true, true).await; } } else { - send_msg(ctx, lang!("re_404"), false, false).await; + send_msg(ctx, lang!("dc_msg_re_post_404"), false, false).await; } } \ No newline at end of file diff --git a/src/re_cmds/get.rs b/src/re_cmds/get.rs index 54f34ce..7e99817 100644 --- a/src/re_cmds/get.rs +++ b/src/re_cmds/get.rs @@ -39,11 +39,11 @@ async fn get_post_from_data(ctx: Context<'_>, reddit_data: &Value, url: &str) -> return Ok(Some(post.clone())); } else { - send_msg(ctx, lang!("re_404", url), true, true).await; + send_msg(ctx, lang!("dc_msg_re_post_404", url), true, true).await; } } else { - send_msg(ctx, lang!("re_data_corrupted", url), true, true).await; + send_msg(ctx, lang!("dc_msg_re_data_corrupted", url), true, true).await; rs_println!("{}", serde_json::to_string_pretty(reddit_data)?); } return Ok(None); diff --git a/src/re_cmds/remove.rs b/src/re_cmds/remove.rs index f19dfb0..7a60046 100644 --- a/src/re_cmds/remove.rs +++ b/src/re_cmds/remove.rs @@ -17,7 +17,7 @@ pub async fn cmd( ) -> Result<(), Error> { if !is_bk_mod(ctx.data().bk_mods.clone(), ctx.author().id.get()) { - send_msg(ctx, lang!("re_permdeny_bk_mod"), false, false).await; + send_msg(ctx, lang!("dc_msg_re_permdeny_not_re_mod"), false, false).await; return Ok(()); } @@ -27,13 +27,13 @@ pub async fn cmd( if r["value"].as_bool().unwrap() { send_msg( ctx, - lang!("re_remove_post_success"), + lang!("dc_msg_re_post_remove_success"), true, true ).await; } else { - send_msg(ctx, lang!("re_404"), false, false).await; + send_msg(ctx, lang!("dc_msg_re_post_404"), false, false).await; } return Ok(()); diff --git a/src/re_cmds/update.rs b/src/re_cmds/update.rs index da8af2a..6197b6f 100644 --- a/src/re_cmds/update.rs +++ b/src/re_cmds/update.rs @@ -105,7 +105,7 @@ async fn update_progress(ctx: Context<'_>, p: ReplyHandle<'_>, t: String, added_ async fn get_c_id(ctx: Context<'_>) -> Option { if !data::dc_contains_server(ctx.data(), ctx.guild_id().unwrap().into()).await { - send_msg(ctx, lang!("dc_404"), false, false).await; + send_msg(ctx, lang!("dc_msg_server_data_404"), false, false).await; return None; } diff --git a/src/re_cmds/vote.rs b/src/re_cmds/vote.rs index b8e5413..6cb05ad 100644 --- a/src/re_cmds/vote.rs +++ b/src/re_cmds/vote.rs @@ -23,7 +23,7 @@ pub async fn cmd( let unw_vote = un_vote.unwrap_or(false); if post_data.get(&url).is_none() { - send_msg(ctx, lang!("re_404"), false, false).await; + send_msg(ctx, lang!("dc_msg_re_post_404"), false, false).await; return Ok(()); } if post_data[&url].get("removed").is_some() { @@ -39,11 +39,11 @@ pub async fn cmd( let voters = if is_mod { mod_voters } else { voters_dc }; if voters.contains(&json!(uid)) && !unw_vote { - send_msg(ctx, lang!("re_already_voted"), true, true).await; + send_msg(ctx, lang!("dc_msg_re_already_voted"), true, true).await; return Ok(()); } else if !voters.contains(&json!(uid)) && unw_vote { - send_msg(ctx, lang!("re_havent_voted_remove_vote"), true, true).await; + send_msg(ctx, lang!("dc_msg_re_vote_remove_havent"), true, true).await; return Ok(()); } @@ -51,16 +51,16 @@ pub async fn cmd( let unw_r = r["value"].as_bool().unwrap(); if unw_r && !unw_vote && is_mod { - send_msg(ctx, lang!("re_vote_success_mod"), true, true).await; + send_msg(ctx, lang!("dc_msg_re_vote_mod_success"), true, true).await; } else if unw_r && !unw_vote && !is_mod { - send_msg(ctx, lang!("re_vote_success"), true, true).await; + send_msg(ctx, lang!("dc_msg_re_vote_success"), true, true).await; } else if unw_r && unw_vote { - send_msg(ctx, lang!("re_vote_remove_success"), true, true).await; + send_msg(ctx, lang!("dc_msg_re_vote_remove_success"), true, true).await; } else { - send_msg(ctx, lang!("re_vote_err"), true, true).await; + send_msg(ctx, lang!("dc_msg_re_vote_err"), true, true).await; } return Ok(()); diff --git a/src/schedule.rs b/src/schedule.rs index 683fd7b..0ab5cbd 100644 --- a/src/schedule.rs +++ b/src/schedule.rs @@ -23,7 +23,7 @@ pub async fn run_schedule Pin + Send>>>(d pub async fn run_schedules(schedules: Vec) { let mut handles: Vec> = vec![]; - rs_println!("{}", lang!("starting_schedules")); + rs_println!("Starting schedules..."); for (d, f) in schedules { let handle = tokio::spawn(run_schedule(d, f)); handles.push(handle); diff --git a/src/websocket.rs b/src/websocket.rs index 9a03bcd..834acba 100644 --- a/src/websocket.rs +++ b/src/websocket.rs @@ -66,11 +66,11 @@ pub async fn send_cmd_json(func_name: &str, func_args: Option) -> Option< let r = receive_response().await; if !["respond_mentions"].contains(&func_name) || ::parse().dev { - rs_println!("{}", lang!("python_socket_response", format!("{:?}", r))); + rs_println!("Received from Python: [RESPONSE] {:?}", r); } if r.is_none() { - rs_println!("{}", lang!("python_socket_null")); + rs_println!("[IMPORTANT] Response from Python is None!"); } return r; @@ -99,10 +99,10 @@ async fn receive_response() -> Option { pub async fn start(args: Args, owners: Vec) { - rs_println!("{}", lang!("starting_socket")); + rs_println!("Running local websocket..."); let ip = format!("127.0.0.1:{}", args.port); let listener = TcpListener::bind(&ip).await.unwrap(); - rs_println!("{}", lang!("started_socket", ip)); + rs_println!("WebSocket server running on ws://{}", ip); tokio::spawn(handle_connections(listener, args, owners)); } @@ -129,18 +129,18 @@ async fn handle_connections(listener: TcpListener, args: Args, owners: Vec) async fn handle_message(msg: tungstenite::protocol::Message, args: Args, owners: Vec) { match msg { tungstenite::Message::Text(text) => { - rs_println!("{}", lang!("socket_received_python", text.clone())); + rs_println!("Received from Python: {}", text); if let Some(stripped) = text.strip_prefix("json:") { let t_json: Value = serde_json::from_str(stripped).unwrap(); if t_json.get("error").is_some() { - send_dm(lang!("python_socket_err"), args, owners).await; + send_dm(lang!("dc_msg_dm_python_err_socket"), args, owners).await; } } unsafe { if !REPLY_HELLO { - send_msg(&lang!("socket_rust_connection_test")).await; + send_msg("[Connection test] Hello from Rust!").await; REPLY_HELLO = true; HAS_CONNECTED = true; } @@ -148,12 +148,12 @@ async fn handle_message(msg: tungstenite::protocol::Message, args: Args, owners: } tungstenite::Message::Binary(bytes) => { if args.dev && !args.noping { - rs_println!("{}", lang!("python_socket_binary_response", format!("{:?}", bytes))); + rs_println!("[Binary] from Python: {:?}", bytes); } } _ => { if args.dev && !args.noping { - rs_println!("{}", lang!("python_socket_unknown_response")); + rs_println!("Received from Python: [UNKNOWN / OTHER]"); } } }