Add strings to call commands

This commit is contained in:
2025-08-21 18:57:30 -03:00
parent cca77aa4a7
commit 2b1a738379
11 changed files with 208 additions and 25 deletions
Generated
+3 -2
View File
@@ -1458,6 +1458,7 @@ dependencies = [
"regex", "regex",
"scc", "scc",
"scylla", "scylla",
"serde_json",
"thiserror 2.0.12", "thiserror 2.0.12",
"time", "time",
"tokio", "tokio",
@@ -1943,9 +1944,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.142" version = "1.0.143"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
dependencies = [ dependencies = [
"itoa", "itoa",
"memchr", "memchr",
+1
View File
@@ -24,6 +24,7 @@ rand_chacha = { version = "0.9.0", features = ["os_rng"] }
regex = "1.11.1" regex = "1.11.1"
scc = "2.3.4" scc = "2.3.4"
scylla = { version = "1.3.1", features = ["time-03"] } scylla = { version = "1.3.1", features = ["time-03"] }
serde_json = "1.0.143"
thiserror = "2.0.12" thiserror = "2.0.12"
time = { version = "0.3.41", features = ["formatting", "local-offset", "macros"] } time = { version = "0.3.41", features = ["formatting", "local-offset", "macros"] }
tokio = { version = "1.47.1", features = ["macros", "rt-multi-thread"] } tokio = { version = "1.47.1", features = ["macros", "rt-multi-thread"] }
+51 -10
View File
@@ -8,7 +8,15 @@ use crate::{
framework::commands::{ framework::commands::{
Command, CommandError, context::CommandContext, permissions::Permission, Command, CommandError, context::CommandContext, permissions::Permission,
}, },
groups::calls::{get_display_profile, permissions::NotBannedPermission}, groups::calls::{
get_display_profile,
permissions::NotBannedPermission,
strings::{
get_string_call_answered, get_string_call_hangup_other_party,
get_string_call_hangup_this_party, get_string_call_no_answer,
get_string_call_searching, get_string_tips,
},
},
state::State, state::State,
utils::Bye, utils::Bye,
}; };
@@ -99,16 +107,28 @@ impl Command<State> for CallCommand {
.await; .await;
if let Some(call) = call { if let Some(call) = call {
ctx.send().content("☎️ Call connected. Say hi!").await.bye(); ctx.send()
.content(format!(
"**TIP:** {}\n☎️ {}\n☎️ {}",
get_string_tips(ctx.prefix),
get_string_call_searching(ctx.prefix),
get_string_call_answered(ctx.prefix)
))
.await
.bye();
ctx.rt ctx.rt
.http .http
.create_message(Id::new(call.other_party_channel_id(channel.id))) .create_message(Id::new(call.other_party_channel_id(channel.id)))
.content("☎️ Call connected. Say hi!") .content(&format!("☎️ {}", get_string_call_answered(ctx.prefix)))
.await .await
.bye(); .bye();
} else { } else {
ctx.send() ctx.send()
.content("☎️ Searching for a call...") .content(format!(
"**TIP:** {}\n☎️ {}",
get_string_tips(ctx.prefix),
get_string_call_searching(ctx.prefix)
))
.await .await
.map_err(|_| CommandError::MessageSendingFailed)?; .map_err(|_| CommandError::MessageSendingFailed)?;
} }
@@ -190,7 +210,10 @@ impl Command<State> for SkipCommand {
ctx.rt ctx.rt
.http .http
.create_message(Id::new(other_channel_id)) .create_message(Id::new(other_channel_id))
.content("☎️ The other party hung up the phone.") .content(&format!(
"☎️ {}",
get_string_call_hangup_other_party(ctx.prefix)
))
.await .await
.inspect_err(|e| { .inspect_err(|e| {
log::error!("Failed to send message to other party: {e:?}"); log::error!("Failed to send message to other party: {e:?}");
@@ -205,11 +228,20 @@ impl Command<State> for SkipCommand {
.map_err(|_| CommandError::DatabaseQueryFailed)?; .map_err(|_| CommandError::DatabaseQueryFailed)?;
if let Some(call) = call { if let Some(call) = call {
ctx.send().content("☎️ Call connected. Say hi!").await.bye(); ctx.send()
.content(format!(
"☎️ {}",
get_string_call_hangup_this_party(ctx.prefix)
))
.await
.bye();
ctx.rt ctx.rt
.http .http
.create_message(Id::new(call.other_party_channel_id(channel.id))) .create_message(Id::new(call.other_party_channel_id(channel.id)))
.content("☎️ Call connected. Say hi!") .content(&format!(
"☎️ {}",
get_string_call_hangup_other_party(ctx.prefix)
))
.await .await
.bye(); .bye();
} else { } else {
@@ -271,7 +303,7 @@ impl Command<State> for HangupCommand {
.map_err(|_| CommandError::DatabaseQueryFailed)?; .map_err(|_| CommandError::DatabaseQueryFailed)?;
ctx.send() ctx.send()
.content("☎️ The phone was hung up.") .content(format!("☎️ {}", get_string_call_no_answer(ctx.prefix)))
.await .await
.map_err(|_| CommandError::MessageSendingFailed)?; .map_err(|_| CommandError::MessageSendingFailed)?;
@@ -297,12 +329,21 @@ impl Command<State> for HangupCommand {
.inspect_err(|e| log::error!("Failed to hang up call: {e:?}")) .inspect_err(|e| log::error!("Failed to hang up call: {e:?}"))
.map_err(|_| CommandError::DatabaseQueryFailed)?; .map_err(|_| CommandError::DatabaseQueryFailed)?;
ctx.send().content("☎️ You hung up the phone.").await.bye(); ctx.send()
.content(format!(
"☎️ {}",
get_string_call_hangup_this_party(ctx.prefix)
))
.await
.bye();
ctx.rt ctx.rt
.http .http
.create_message(Id::new(call.other_party_channel_id(channel.id))) .create_message(Id::new(call.other_party_channel_id(channel.id)))
.content("☎️ The other party hung up the phone.") .content(&format!(
"☎️ {}",
get_string_call_hangup_other_party(ctx.prefix)
))
.await .await
.map_err(|_| CommandError::MessageSendingFailed)?; .map_err(|_| CommandError::MessageSendingFailed)?;
} else { } else {
@@ -7,4 +7,7 @@ fool
stfu stfu
syfm syfm
sybau sybau
gtfo gtfo
// Keys is only censored because there have been many genuine conversations about piano keys, keys,
// and other stuff.
keys
@@ -56,9 +56,6 @@ gang bang
squirt squirt
squirting squirting
squirts squirts
bitch
bih
bich
hoe hoe
// ho is in "explicit sexual language typos" because it's usually also a typo of "hi". it gets // ho is in "explicit sexual language typos" because it's usually also a typo of "hi". it gets
// censored instead of banned. // censored instead of banned.
+4 -1
View File
@@ -12,4 +12,7 @@ fuck u
shit shit
sht sht
ass ass
huz huz
bitch
bih
bich
@@ -5,7 +5,6 @@ hang urself
hang yourself hang yourself
gkys gkys
gokys gokys
keys
get raped get raped
rape you rape you
rape u rape u
+1
View File
@@ -11,6 +11,7 @@ pub(super) mod embeds;
pub mod events; pub mod events;
pub(super) mod moderation; pub(super) mod moderation;
pub(super) mod permissions; pub(super) mod permissions;
pub(super) mod strings;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct DisplayProfile { pub struct DisplayProfile {
+141
View File
@@ -0,0 +1,141 @@
use once_cell::sync::Lazy;
use rand::{SeedableRng, seq::IndexedRandom};
use rand_chacha::ChaCha20Rng;
static STRINGS_TIPS: Lazy<Vec<String>> = Lazy::new(|| {
let json = include_str!("strings/tips.json");
let strings: Vec<String> =
serde_json::from_str(json).expect("Failed to parse strings/tips.json strings");
assert_ne!(strings.len(), 0, "No strings found in strings/tips.json");
strings
});
pub fn get_string_tips(prefix: &str) -> String {
let mut rng = ChaCha20Rng::from_os_rng();
let message = STRINGS_TIPS
.choose(&mut rng)
.expect("Failed to choose a random string from tips");
message.replace("{prefix}", prefix)
}
static STRINGS_CALL_ANSWERED: Lazy<Vec<String>> = Lazy::new(|| {
let json = include_str!("strings/call-answered.json");
let strings: Vec<String> =
serde_json::from_str(json).expect("Failed to parse strings/call-answered.json strings");
assert_ne!(
strings.len(),
0,
"No strings found in strings/call-answered.json"
);
strings
});
pub fn get_string_call_answered(prefix: &str) -> String {
let mut rng = ChaCha20Rng::from_os_rng();
let message = STRINGS_CALL_ANSWERED
.choose(&mut rng)
.expect("Failed to choose a random string from call answered strings");
message.replace("{prefix}", prefix)
}
static STRINGS_CALL_SEARCHING: Lazy<Vec<String>> = Lazy::new(|| {
let json = include_str!("strings/call-searching.json");
let strings: Vec<String> =
serde_json::from_str(json).expect("Failed to parse strings/call-searching.json strings");
assert_ne!(
strings.len(),
0,
"No strings found in strings/call-searching.json"
);
strings
});
pub fn get_string_call_searching(prefix: &str) -> String {
let mut rng = ChaCha20Rng::from_os_rng();
let message = STRINGS_CALL_SEARCHING
.choose(&mut rng)
.expect("Failed to choose a random string from call starting strings");
message.replace("{prefix}", prefix)
}
static STRINGS_CALL_NO_ANSWER: Lazy<Vec<String>> = Lazy::new(|| {
let json = include_str!("strings/call-no-answer.json");
let strings: Vec<String> =
serde_json::from_str(json).expect("Failed to parse strings/call-no-answer.json strings");
assert_ne!(
strings.len(),
0,
"No strings found in strings/call-no-answer.json"
);
strings
});
pub fn get_string_call_no_answer(prefix: &str) -> String {
let mut rng = ChaCha20Rng::from_os_rng();
let message = STRINGS_CALL_NO_ANSWER
.choose(&mut rng)
.expect("Failed to choose a random string from call no answer strings");
message.replace("{prefix}", prefix)
}
static STRINGS_CALL_HANGUP_THIS_PARTY: Lazy<Vec<String>> = Lazy::new(|| {
let json = include_str!("strings/call-hangup-this-party.json");
let strings: Vec<String> = serde_json::from_str(json)
.expect("Failed to parse strings/call-hangup-this-party.json strings");
assert_ne!(
strings.len(),
0,
"No strings found in strings/call-hangup-this-party.json"
);
strings
});
pub fn get_string_call_hangup_this_party(prefix: &str) -> String {
let mut rng = ChaCha20Rng::from_os_rng();
let message = STRINGS_CALL_HANGUP_THIS_PARTY
.choose(&mut rng)
.expect("Failed to choose a random string from call hangup this party strings");
message.replace("{prefix}", prefix)
}
static STRINGS_CALL_HANGUP_OTHER_PARTY: Lazy<Vec<String>> = Lazy::new(|| {
let json = include_str!("strings/call-hangup-other-party.json");
let strings: Vec<String> = serde_json::from_str(json)
.expect("Failed to parse strings/call-hangup-other-party.json strings");
assert_ne!(
strings.len(),
0,
"No strings found in strings/call-hangup-other-party.json"
);
strings
});
pub fn get_string_call_hangup_other_party(prefix: &str) -> String {
let mut rng = ChaCha20Rng::from_os_rng();
let message = STRINGS_CALL_HANGUP_OTHER_PARTY
.choose(&mut rng)
.expect("Failed to choose a random string from call hangup other party strings");
message.replace("{prefix}", prefix)
}
+3 -7
View File
@@ -1,23 +1,19 @@
[ [
"You can report calls using `Apps > Report Message`.", "You can report messages using `Message > Apps > Report Message`.",
"Help us sharing Payphone to make it more active!", "Help us sharing Payphone to make it more active!",
"You can check your stats with `{prefix}me`.",
"Emojis will only show if they're from a server Payphone's in.", "Emojis will only show if they're from a server Payphone's in.",
"You cannot send links.", "You cannot send links.",
"[Vote for Payphone on top.gg](<https://top.gg/bot/1212940413795827763/vote>) to help us reach more users!", "[Vote for Payphone on top.gg](<https://top.gg/bot/1212940413795827763/vote>) to help us reach more users!",
"[Write a review](<https://top.gg/bot/1212940413795827763#reviews>) to tell everyone your opinion about Payphone!", "[Write a review](<https://top.gg/bot/1212940413795827763#reviews>) to tell everyone your opinion about Payphone!",
"Calls will be automatically hung up after 15 minutes if nobody talks.", "Calls will be automatically hung up after 15 minutes if nobody talks.",
"You can change Payphone's prefix with `{prefix}config prefix`.", "You can change Payphone's prefix with `{prefix}prefix`.",
"Do you have any suggestions? Use `{prefix}suggest`!",
"You can use `{prefix}skip` to directly search for a new call.", "You can use `{prefix}skip` to directly search for a new call.",
"The links from `{prefix}history` will take you to that call.",
"Want to stay hidden? Use `{prefix}mask on`!", "Want to stay hidden? Use `{prefix}mask on`!",
"Did you know you can check your mask with `{prefix}mask`?", "Did you know you can check your mask with `{prefix}mask`?",
"Do you like Payphone? Consider [making a donation](<https://ko-fi.com/payphonedev>) to help us grow Payphone (and keep it running)!", "Do you like Payphone? Consider [making a donation](<https://ko-fi.com/payphonedev>) to help us grow Payphone (and keep it running)!",
"Using `{prefix}friendreq` is the best way to ask the other party to add you.", "Using `{prefix}friendreq` is the best way to ask the other party to add you.",
"Enable and disable channels using `{prefix}config enable` and `{prefix}config disable`!",
"There's a secret easter egg command. Try to find it! (Hint: cat)", "There's a secret easter egg command. Try to find it! (Hint: cat)",
"Make sure to read Payphone's [Code of Conduct](<https://payphone.nyeki.dev/code-of-conduct>). Let's keep Payphone safe and fun for everyone!", "Make sure to read Payphone's [Code of Conduct](<https://payphone.nyeki.dev/code-of-conduct>). Let's keep Payphone safe and fun for everyone!",
"Did you join [Payphone's new official server](<https://discord.gg/9daSsrfTmE>) yet? We have a lot of fun stuff there!", "Did you join [Payphone's new official server](<https://discord.gg/9daSsrfTmE>) yet? We have a lot of fun stuff there!",
"How high are you on the leaderboard? Use `{prefix}me`, `{prefix}leaderboard`, and `{prefix}leaderboard servers` to check it out!" "How high are you on the leaderboard? Use `{prefix}leaderboard` to check it out!"
] ]