removed different language logs & updated language key names
This commit is contained in:
+38
-60
@@ -1,62 +1,40 @@
|
|||||||
{
|
{
|
||||||
"8-ball_answer": "Q: {0}\nA: {1}",
|
"dc_msg_8-ball_answer": "## You shook a magic 8-ball\nQ: {0}\nA: {1}",
|
||||||
"add_to_data": "Added your server to my data! Thanks for letting me steal it! (/s)",
|
"dc_msg_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!",
|
"dc_msg_bound_channel": "Successfully bound channel ID `{0}` as the \"where all collected Reddit data gets dumped\" channel!",
|
||||||
"cfg_data_404": "cfg.json not found,",
|
"dc_msg_cmd_404": "No command \"{0}\" found!\nHint: Try `/help` without any arguments or `/help <category>`",
|
||||||
"cfg_data_wipe": "[WIPE] (cfg.json)",
|
"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.",
|
||||||
"cmd_404": "No command with the name \"{0}\" found!\nHint: Try `/help` without any arguments or `/help <category>`",
|
"dc_msg_dm_python_err_socket": "Unknown internal Python error occurred: Websocket response error",
|
||||||
"corrupted_data": "Oopsies `(。>\\\\<)`. It looks like my data i-is \\**sob*\\*... c-corrupted!",
|
"dc_msg_dm_python_err": "Unknown internal Python Error: {0}",
|
||||||
"couldnt_shorturl": "Couldn't convert to shortURL: Invalid URL",
|
"dc_msg_embed_default_embed_desc": "Default english embed description.",
|
||||||
"creating_data_file": "{0} creating new from preset...",
|
"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] }}`",
|
||||||
"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] }}`",
|
"dc_msg_embed_re_removed": "## Removed by `{0}`\n**Reason:** {1}\nURL: ||<{2}>||\n\nJSON: ||`{3}`||",
|
||||||
"data_post_removed_embed": "## Removed by `{0}`\n**Reason:** {1}\nURL: ||<{2}>||\n\nJSON: ||`{3}`||",
|
"dc_msg_err_trace": "Unknown error!\nError trace: {0}",
|
||||||
"data_save_complete": "Saving data... Done!\nShutting down...",
|
"dc_msg_failed_shorturl_conversion": "Couldn't convert to shortURL: Invalid Reddit URL format.",
|
||||||
"data_save_progress": "Saving data...",
|
"dc_msg_mandatory_response": "Mandatory response message, please ignore.",
|
||||||
"dc_404": "Your server is not in the data!\n Hint: Run the command `/add_server` inside of a Discord server.",
|
"dc_msg_owner_data_save_complete": "Saving data... Done!\nShutting down...",
|
||||||
"dc_bot_started": "Bot started as user \"{0}\" with id {1}",
|
"dc_msg_owner_data_save": "Saving data...",
|
||||||
"dc_bot_starting": "Starting bot...",
|
"dc_msg_owner_shutdown_failed_confirmation": "Failed to shut down: Invalid confirmation.",
|
||||||
"dc_data_404": "discord_data.json not found,",
|
"dc_msg_re_already_voted": "Couldn't cast a vote: You have already voted on this post!",
|
||||||
"dc_data_wipe": "[WIPE] (discord_data.json)",
|
"dc_msg_re_also_approved": "Also approved it!",
|
||||||
"default_embed_desc": "Default description",
|
"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\"",
|
||||||
"err_read_py_file": "Failed to read Python file!\nPath: {0}",
|
"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.",
|
||||||
"help_text_removed": "Help text not found. Someone deleted it. :(",
|
"dc_msg_re_permdeny_not_re_mod": "Permission denied: You are not a moderator of the subreddit(s) {0}",
|
||||||
"invalid_confirm_shutdown": "Failed to shut down: Invalid confirmation.",
|
"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.",
|
||||||
"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!",
|
"dc_msg_re_post_add_success": "Added post with URL \"<{0}>\"!",
|
||||||
"lang_data_404": "File for language \"{0}\" not found!",
|
"dc_msg_re_post_approve_success": "Successfully approved the post!",
|
||||||
"lang_load_success": "Successfully loaded the english language file!",
|
"dc_msg_re_post_disapprove_success": "Successfully disapproved the post!",
|
||||||
"mandatory_response": "Mandatory response message, please ignore.",
|
"dc_msg_re_post_remove_success": "Successfully removed post!",
|
||||||
"python_err": "Unknown internal Python Error: {0}",
|
"dc_msg_re_post_unremove_success": "Successfully un-removed post with URL \"<{0}>\"!",
|
||||||
"python_socket_binary_response": "[Binary] from Python: {0}",
|
"dc_msg_re_post_update_success": "Updated post with URL \"<{0}>\"!",
|
||||||
"python_socket_err": "Unknown internal Python error occurred: Websocket response error.",
|
"dc_msg_re_vote_err": "Failed to vote/un-vote: Unknown internal error.",
|
||||||
"python_socket_null": "Response from Python is None!",
|
"dc_msg_re_vote_mod_success": "Successfully voted (as moderator vote)!",
|
||||||
"python_socket_response": "Received from Python: [RESPONSE] {0}",
|
"dc_msg_re_vote_remove_havent": "Couldn't remove your vote: You haven't voted on this post yet!",
|
||||||
"python_socket_unknown_response": "Received from Python: [UNKNOWN / OTHER]",
|
"dc_msg_re_vote_remove_success": "Successfully removed vote!",
|
||||||
"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.",
|
"dc_msg_re_vote_success": "Successfully voted!",
|
||||||
"re_add_post_success": "Added post with URL \"<{0}>\"!",
|
"dc_msg_reload_cfg_python_fail": "Failed to reload configs: Failed-type response from Python.",
|
||||||
"re_already_voted": "Couldn't cast a vote: You have already voted on this post!",
|
"dc_msg_reload_cfg_success": "Successfully reloaded the configs!\nNew configs:\n```\n{0}\n```",
|
||||||
"re_also_approved": "Also approved it!",
|
"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).",
|
||||||
"re_approved_post_success": "Successfully approved the post!",
|
"dc_msg_shorturl": "ShortURL: <{0}>",
|
||||||
"re_data_404": "reddit_data.json not found,",
|
"log_lang_load_success": "Successfully loaded the english language file!"
|
||||||
"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..."
|
|
||||||
}
|
}
|
||||||
@@ -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..."
|
|
||||||
}
|
|
||||||
+18
-15
@@ -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::re_cmds::generic_fns::to_shorturl;
|
||||||
use crate::websocket::send_cmd_json;
|
use crate::websocket::send_cmd_json;
|
||||||
use crate::{data, lang, Context, Data, Error};
|
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::serenity_prelude::{OnlineStatus, Timestamp};
|
||||||
use poise::Command;
|
use poise::Command;
|
||||||
@@ -15,6 +15,9 @@ use serde_json::json;
|
|||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: separate to multiple files
|
||||||
|
|
||||||
|
|
||||||
#[derive(poise::ChoiceParameter, PartialEq)]
|
#[derive(poise::ChoiceParameter, PartialEq)]
|
||||||
enum HelpOptions {
|
enum HelpOptions {
|
||||||
Admin,
|
Admin,
|
||||||
@@ -63,19 +66,19 @@ pub async fn stop(
|
|||||||
|| confirmation.unwrap_or_default().to_lowercase() == "i want to stop the bot now";
|
|| confirmation.unwrap_or_default().to_lowercase() == "i want to stop the bot now";
|
||||||
|
|
||||||
if should_stop {
|
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_dc_data(ctx.data()).await;
|
||||||
data::write_re_data().await;
|
data::write_re_data().await;
|
||||||
send_cmd_json("stop_praw", None).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.serenity_context().set_presence(None, OnlineStatus::Invisible);
|
||||||
ctx.framework().shard_manager.shutdown_all().await;
|
ctx.framework().shard_manager.shutdown_all().await;
|
||||||
|
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
else {
|
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(());
|
return Ok(());
|
||||||
@@ -124,7 +127,7 @@ pub async fn embed(
|
|||||||
).await;
|
).await;
|
||||||
|
|
||||||
if !reply_unwrap {
|
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(());
|
return Ok(());
|
||||||
@@ -146,7 +149,7 @@ pub async fn send(
|
|||||||
) -> Result<(), Error>
|
) -> Result<(), Error>
|
||||||
{
|
{
|
||||||
send_msg(ctx, msg.replace("\\n", "\n"), false, false).await;
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +174,7 @@ pub async fn eight_ball(
|
|||||||
|
|
||||||
send_msg(
|
send_msg(
|
||||||
ctx,
|
ctx,
|
||||||
lang!("8-ball_answer", question, rand_item.unwrap()),
|
lang!("dc_msg_8-ball_answer", question, rand_item.unwrap()),
|
||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
).await;
|
).await;
|
||||||
@@ -194,10 +197,10 @@ pub async fn re_shorturl(
|
|||||||
let shorturl = to_shorturl(&url);
|
let shorturl = to_shorturl(&url);
|
||||||
|
|
||||||
if shorturl.is_ok() {
|
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 {
|
else {
|
||||||
send_msg(ctx, lang!("couldnt_shorturl"), true, true).await;
|
send_msg(ctx, lang!("dc_msg_failed_shorturl_conversion"), true, true).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -220,10 +223,10 @@ pub async fn add_server(
|
|||||||
let r = dc_add_server(ctx.data(), ctx.guild_id().unwrap().into()).await;
|
let r = dc_add_server(ctx.data(), ctx.guild_id().unwrap().into()).await;
|
||||||
|
|
||||||
if r.is_ok() {
|
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 {
|
else {
|
||||||
send_msg(ctx, lang!("corrupted_data"), true, true).await;
|
send_msg(ctx, lang!("dc_msg_corrupted_data"), true, true).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -250,14 +253,14 @@ pub async fn reload_cfg(
|
|||||||
if r.is_some() && r.unwrap()["value"].as_bool().unwrap() {
|
if r.is_some() && r.unwrap()["value"].as_bool().unwrap() {
|
||||||
send_msg(
|
send_msg(
|
||||||
ctx,
|
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,
|
||||||
true
|
true
|
||||||
).await;
|
).await;
|
||||||
return Ok(());
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +332,7 @@ async fn send_single_help(ctx: Context<'_>, mut cmd_name: String) {
|
|||||||
if cmd.is_none() {
|
if cmd.is_none() {
|
||||||
send_msg(
|
send_msg(
|
||||||
ctx,
|
ctx,
|
||||||
lang!("cmd_404", cmd_name),
|
lang!("dc_msg_cmd_404", cmd_name),
|
||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
).await;
|
).await;
|
||||||
@@ -355,7 +358,7 @@ async fn send_category_help(ctx: Context<'_>, category: HelpOptions) {
|
|||||||
|
|
||||||
async fn send_bk_week_help_re(ctx: Context<'_>) {
|
async fn send_bk_week_help_re(ctx: Context<'_>) {
|
||||||
let t: String = fs::read_to_string("./bk_week_help_re.md").await
|
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;
|
send_msg(ctx, t, true, true).await;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-11
@@ -4,7 +4,7 @@ use std::path::Path;
|
|||||||
use serde_json::{self, Value, json};
|
use serde_json::{self, Value, json};
|
||||||
use tokio::sync::Mutex;
|
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;
|
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) {
|
pub async fn read_dc_data(data: &Data, wipe: bool) {
|
||||||
if !Path::new(DATA_PATH_DC).exists() || wipe {
|
if !Path::new(DATA_PATH_DC).exists() || wipe {
|
||||||
rs_println!(
|
rs_println!(
|
||||||
"{}",
|
"{} creating new from preset...",
|
||||||
lang!("creating_data_file", if !wipe { lang!("dc_data_404") } else { lang!("dc_data_wipe") })
|
if !wipe { "discord_data.json not found," } else { "[WIPE] (discord_data.json)" }
|
||||||
);
|
);
|
||||||
generate_dc_data();
|
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) {
|
pub async fn read_re_data(data: &Data, wipe: bool) {
|
||||||
if !Path::new(DATA_PATH_RE).exists() || wipe {
|
if !Path::new(DATA_PATH_RE).exists() || wipe {
|
||||||
rs_println!(
|
rs_println!(
|
||||||
"{}",
|
"{} creating new from preset...",
|
||||||
lang!("creating_data_file", if !wipe { lang!("re_data_404") } else { lang!("re_data_wipe") })
|
if !wipe { "reddit_data.json not found," } else { "[WIPE] (reddit_data.json)" }
|
||||||
);
|
);
|
||||||
generate_re_data();
|
generate_re_data();
|
||||||
}
|
}
|
||||||
@@ -114,8 +114,8 @@ pub async fn write_re_data() {
|
|||||||
pub async fn read_cfg_data(data: &Data, wipe: bool) {
|
pub async fn read_cfg_data(data: &Data, wipe: bool) {
|
||||||
if !Path::new(DATA_PATH_CFG).exists() || wipe {
|
if !Path::new(DATA_PATH_CFG).exists() || wipe {
|
||||||
rs_println!(
|
rs_println!(
|
||||||
"{}",
|
"{} creating new from preset...",
|
||||||
lang!("creating_data_file", if !wipe { lang!("cfg_data_404") } else { lang!("cfg_data_wipe") })
|
if !wipe { "cfg.json not found," } else { "[WIPE] (cfg.json)" }
|
||||||
);
|
);
|
||||||
generate_cfg_data();
|
generate_cfg_data();
|
||||||
}
|
}
|
||||||
@@ -202,11 +202,10 @@ pub fn load_lang_data(lang: String) {
|
|||||||
let full_path = format!("{}{}.json", DATA_PATH_LANG, lang);
|
let full_path = format!("{}{}.json", DATA_PATH_LANG, lang);
|
||||||
|
|
||||||
if !Path::new(&full_path).exists() {
|
if !Path::new(&full_path).exists() {
|
||||||
rs_println!(
|
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!("creating_data_file", lang!("cfg_data_404", lang))
|
lang
|
||||||
);
|
);
|
||||||
generate_cfg_data();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let str_data = fs::read_to_string(full_path).unwrap();
|
let str_data = fs::read_to_string(full_path).unwrap();
|
||||||
|
|||||||
+4
-7
@@ -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};
|
use poise::serenity_prelude::{self as serenity, ActivityData};
|
||||||
|
|
||||||
@@ -14,12 +14,9 @@ pub fn event_handler<'a>(
|
|||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
if let serenity::FullEvent::Ready { data_about_bot } = event {
|
if let serenity::FullEvent::Ready { data_about_bot } = event {
|
||||||
rs_println!(
|
rs_println!(
|
||||||
"{}",
|
"Bot started as user \"{}\" with id {}",
|
||||||
lang!(
|
data_about_bot.user.name,
|
||||||
"dc_bot_started",
|
data_about_bot.user.id
|
||||||
data_about_bot.user.name.clone(),
|
|
||||||
data_about_bot.user.id
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let file_text = std::fs::read_to_string("./data/status.txt").unwrap();
|
let file_text = std::fs::read_to_string("./data/status.txt").unwrap();
|
||||||
|
|||||||
+2
-3
@@ -40,7 +40,6 @@ use websocket::send_cmd_json;
|
|||||||
|
|
||||||
use crate::schedule::Schedule;
|
use crate::schedule::Schedule;
|
||||||
|
|
||||||
// TODO: convert to lang!
|
|
||||||
|
|
||||||
#[derive(Parser, Serialize, Clone)]
|
#[derive(Parser, Serialize, Clone)]
|
||||||
struct Args {
|
struct Args {
|
||||||
@@ -92,7 +91,7 @@ async fn main() {
|
|||||||
|
|
||||||
rs_println!("Fetching language file...");
|
rs_println!("Fetching language file...");
|
||||||
data::load_lang_data(args.clone().lang);
|
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_env = std::env::var("ASSISTANT_OWNERS").unwrap_or("0".to_string());
|
||||||
let own_vec_str: Vec<String> = own_env.split(",").map(String::from).collect();
|
let own_vec_str: Vec<String> = own_env.split(",").map(String::from).collect();
|
||||||
@@ -156,7 +155,7 @@ async fn start(args: Args, owners: Vec<u64>) {
|
|||||||
let data = gen_data(args.clone(), owners).await;
|
let data = gen_data(args.clone(), owners).await;
|
||||||
let mut bot = gen_bot(data, args).await;
|
let mut bot = gen_bot(data, args).await;
|
||||||
|
|
||||||
rs_println!("{}", lang!("dc_bot_starting"));
|
rs_println!("Starting Discord bot...");
|
||||||
bot.start().await.unwrap();
|
bot.start().await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -29,7 +29,7 @@ pub struct EmbedOptions {
|
|||||||
impl Default for EmbedOptions {
|
impl Default for EmbedOptions {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
return EmbedOptions {
|
return EmbedOptions {
|
||||||
desc: lang!("default_embed_desc"),
|
desc: lang!("dc_msg_embed_default_embed_desc"),
|
||||||
title: None,
|
title: None,
|
||||||
col: None,
|
col: None,
|
||||||
url: None,
|
url: None,
|
||||||
@@ -45,7 +45,6 @@ impl Default for EmbedOptions {
|
|||||||
|
|
||||||
static DEFAULT_DC_COL: u32 = 5793266;
|
static DEFAULT_DC_COL: u32 = 5793266;
|
||||||
static REMOVED_DC_COL: u32 = 16716032;
|
static REMOVED_DC_COL: u32 = 16716032;
|
||||||
pub static MANDATORY_MSG: &str = "Mandatory response, please ignore.";
|
|
||||||
|
|
||||||
|
|
||||||
fn none_to_empty(string: Option<String>) -> String {
|
fn none_to_empty(string: Option<String>) -> 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 media_type = &post_data["post_data"]["media_type"];
|
||||||
|
|
||||||
let desc_str = lang!(
|
let desc_str = lang!(
|
||||||
"data_post_embed",
|
"dc_msg_embed_re_post",
|
||||||
post_data["post_data"]["upvotes"].as_i64().unwrap(),
|
post_data["post_data"]["upvotes"].as_i64().unwrap(),
|
||||||
post_data["votes"]["mod_voters"].as_array().unwrap().len(),
|
post_data["votes"]["mod_voters"].as_array().unwrap().len(),
|
||||||
if !media_type.is_null() { media_type.as_str().unwrap() } else { "None" },
|
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 {
|
return EmbedOptions {
|
||||||
title: Some("REMOVED!".to_string()),
|
title: Some("REMOVED!".to_string()),
|
||||||
desc: lang!(
|
desc: lang!(
|
||||||
"data_post_removed_embed",
|
"dc_msg_embed_re_removed",
|
||||||
post_data["removed_by"].as_str().unwrap(),
|
post_data["removed_by"].as_str().unwrap(),
|
||||||
if !post_data["remove_reason"].is_null() { post_data["remove_reason"].as_str().unwrap() }
|
if !post_data["remove_reason"].is_null() { post_data["remove_reason"].as_str().unwrap() }
|
||||||
else { "None" },
|
else { "None" },
|
||||||
|
|||||||
+3
-3
@@ -10,12 +10,12 @@ use pyo3::types::PyList;
|
|||||||
|
|
||||||
|
|
||||||
pub async fn start(args: Args) -> PyResult<()> {
|
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 args_str = serde_json::to_string(&args).expect("Error serializing args to JSON");
|
||||||
|
|
||||||
let slash = if cfg!(windows) { "\\" } else if cfg!(unix) { "/" } else { "" };
|
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);
|
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::<u64>().expect("Failed to parse ASSISTANT_OWNERS. Invalid syntax."))
|
.map(|s| s.parse::<u64>().expect("Failed to parse ASSISTANT_OWNERS. Invalid syntax."))
|
||||||
.collect();
|
.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);
|
errln!("pyO3: {:?}", from_python);
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
+5
-5
@@ -21,7 +21,7 @@ pub async fn cmd(
|
|||||||
) -> Result<(), Error>
|
) -> Result<(), Error>
|
||||||
{
|
{
|
||||||
if !is_bk_mod(ctx.data().bk_mods.clone(), ctx.author().id.get()) {
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,18 +49,18 @@ pub async fn cmd(
|
|||||||
|
|
||||||
if let Some(post) = bk_week.get(shorturl) {
|
if let Some(post) = bk_week.get(shorturl) {
|
||||||
if post.get("removed").is_some() {
|
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 {
|
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 {
|
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 {
|
if a {
|
||||||
send_msg(ctx, lang!("re_also_approved"), true, true).await;
|
send_msg(ctx, lang!("dc_msg_re_also_approved"), true, true).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ pub async fn cmd(
|
|||||||
let r = dc_bind_bk(ctx.data(), ctx.guild_id().unwrap().into(), c_id).await;
|
let r = dc_bind_bk(ctx.data(), ctx.guild_id().unwrap().into(), c_id).await;
|
||||||
|
|
||||||
if r.is_ok() {
|
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 {
|
else {
|
||||||
send_msg(ctx, lang!("dc_404"), false, false).await;
|
send_msg(ctx, lang!("dc_msg_server_data_404"), false, false).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub async fn cmd(
|
|||||||
) -> Result<(), Error>
|
) -> Result<(), Error>
|
||||||
{
|
{
|
||||||
if !is_bk_mod(ctx.data().bk_mods.clone(), ctx.author().id.get()) {
|
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(());
|
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();
|
let r = websocket::send_cmd_json("set_approve_post", Some(json!([approve, &url]))).await.unwrap();
|
||||||
if r.get("value").is_some() {
|
if r.get("value").is_some() {
|
||||||
if approve {
|
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 {
|
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 {
|
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 {
|
else {
|
||||||
send_msg(ctx, lang!("re_404"), false, false).await;
|
send_msg(ctx, lang!("dc_msg_re_post_404"), false, false).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -39,11 +39,11 @@ async fn get_post_from_data(ctx: Context<'_>, reddit_data: &Value, url: &str) ->
|
|||||||
return Ok(Some(post.clone()));
|
return Ok(Some(post.clone()));
|
||||||
}
|
}
|
||||||
else {
|
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 {
|
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)?);
|
rs_println!("{}", serde_json::to_string_pretty(reddit_data)?);
|
||||||
}
|
}
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ pub async fn cmd(
|
|||||||
) -> Result<(), Error>
|
) -> Result<(), Error>
|
||||||
{
|
{
|
||||||
if !is_bk_mod(ctx.data().bk_mods.clone(), ctx.author().id.get()) {
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,13 +27,13 @@ pub async fn cmd(
|
|||||||
if r["value"].as_bool().unwrap() {
|
if r["value"].as_bool().unwrap() {
|
||||||
send_msg(
|
send_msg(
|
||||||
ctx,
|
ctx,
|
||||||
lang!("re_remove_post_success"),
|
lang!("dc_msg_re_post_remove_success"),
|
||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
).await;
|
).await;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
send_msg(ctx, lang!("re_404"), false, false).await;
|
send_msg(ctx, lang!("dc_msg_re_post_404"), false, false).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ async fn update_progress(ctx: Context<'_>, p: ReplyHandle<'_>, t: String, added_
|
|||||||
|
|
||||||
async fn get_c_id(ctx: Context<'_>) -> Option<ChannelId> {
|
async fn get_c_id(ctx: Context<'_>) -> Option<ChannelId> {
|
||||||
if !data::dc_contains_server(ctx.data(), ctx.guild_id().unwrap().into()).await {
|
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;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -23,7 +23,7 @@ pub async fn cmd(
|
|||||||
let unw_vote = un_vote.unwrap_or(false);
|
let unw_vote = un_vote.unwrap_or(false);
|
||||||
|
|
||||||
if post_data.get(&url).is_none() {
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
if post_data[&url].get("removed").is_some() {
|
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 };
|
let voters = if is_mod { mod_voters } else { voters_dc };
|
||||||
|
|
||||||
if voters.contains(&json!(uid)) && !unw_vote {
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
else if !voters.contains(&json!(uid)) && unw_vote {
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,16 +51,16 @@ pub async fn cmd(
|
|||||||
let unw_r = r["value"].as_bool().unwrap();
|
let unw_r = r["value"].as_bool().unwrap();
|
||||||
|
|
||||||
if unw_r && !unw_vote && is_mod {
|
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 {
|
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 {
|
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 {
|
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(());
|
return Ok(());
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ pub async fn run_schedule<F: Fn() -> Pin<Box<dyn Future<Output = ()> + Send>>>(d
|
|||||||
pub async fn run_schedules(schedules: Vec<Schedule>) {
|
pub async fn run_schedules(schedules: Vec<Schedule>) {
|
||||||
let mut handles: Vec<JoinHandle<()>> = vec![];
|
let mut handles: Vec<JoinHandle<()>> = vec![];
|
||||||
|
|
||||||
rs_println!("{}", lang!("starting_schedules"));
|
rs_println!("Starting schedules...");
|
||||||
for (d, f) in schedules {
|
for (d, f) in schedules {
|
||||||
let handle = tokio::spawn(run_schedule(d, f));
|
let handle = tokio::spawn(run_schedule(d, f));
|
||||||
handles.push(handle);
|
handles.push(handle);
|
||||||
|
|||||||
+9
-9
@@ -66,11 +66,11 @@ pub async fn send_cmd_json(func_name: &str, func_args: Option<Value>) -> Option<
|
|||||||
|
|
||||||
let r = receive_response().await;
|
let r = receive_response().await;
|
||||||
if !["respond_mentions"].contains(&func_name) || <Args as clap::Parser>::parse().dev {
|
if !["respond_mentions"].contains(&func_name) || <Args as clap::Parser>::parse().dev {
|
||||||
rs_println!("{}", lang!("python_socket_response", format!("{:?}", r)));
|
rs_println!("Received from Python: [RESPONSE] {:?}", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.is_none() {
|
if r.is_none() {
|
||||||
rs_println!("{}", lang!("python_socket_null"));
|
rs_println!("[IMPORTANT] Response from Python is None!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@@ -99,10 +99,10 @@ async fn receive_response() -> Option<Value> {
|
|||||||
|
|
||||||
|
|
||||||
pub async fn start(args: Args, owners: Vec<u64>) {
|
pub async fn start(args: Args, owners: Vec<u64>) {
|
||||||
rs_println!("{}", lang!("starting_socket"));
|
rs_println!("Running local websocket...");
|
||||||
let ip = format!("127.0.0.1:{}", args.port);
|
let ip = format!("127.0.0.1:{}", args.port);
|
||||||
let listener = TcpListener::bind(&ip).await.unwrap();
|
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));
|
tokio::spawn(handle_connections(listener, args, owners));
|
||||||
}
|
}
|
||||||
@@ -129,18 +129,18 @@ async fn handle_connections(listener: TcpListener, args: Args, owners: Vec<u64>)
|
|||||||
async fn handle_message(msg: tungstenite::protocol::Message, args: Args, owners: Vec<u64>) {
|
async fn handle_message(msg: tungstenite::protocol::Message, args: Args, owners: Vec<u64>) {
|
||||||
match msg {
|
match msg {
|
||||||
tungstenite::Message::Text(text) => {
|
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:") {
|
if let Some(stripped) = text.strip_prefix("json:") {
|
||||||
let t_json: Value = serde_json::from_str(stripped).unwrap();
|
let t_json: Value = serde_json::from_str(stripped).unwrap();
|
||||||
if t_json.get("error").is_some() {
|
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 {
|
unsafe {
|
||||||
if !REPLY_HELLO {
|
if !REPLY_HELLO {
|
||||||
send_msg(&lang!("socket_rust_connection_test")).await;
|
send_msg("[Connection test] Hello from Rust!").await;
|
||||||
REPLY_HELLO = true;
|
REPLY_HELLO = true;
|
||||||
HAS_CONNECTED = true;
|
HAS_CONNECTED = true;
|
||||||
}
|
}
|
||||||
@@ -148,12 +148,12 @@ async fn handle_message(msg: tungstenite::protocol::Message, args: Args, owners:
|
|||||||
}
|
}
|
||||||
tungstenite::Message::Binary(bytes) => {
|
tungstenite::Message::Binary(bytes) => {
|
||||||
if args.dev && !args.noping {
|
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 {
|
if args.dev && !args.noping {
|
||||||
rs_println!("{}", lang!("python_socket_unknown_response"));
|
rs_println!("Received from Python: [UNKNOWN / OTHER]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user