Start working on mask command
This commit is contained in:
Generated
+1
-1
@@ -1437,7 +1437,7 @@ checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "payphone"
|
name = "payphone"
|
||||||
version = "4.2.12"
|
version = "4.2.15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "payphone"
|
name = "payphone"
|
||||||
version = "4.2.12"
|
version = "4.2.15"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
default-run = "payphone"
|
default-run = "payphone"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ALTER TABLE payphone.participants ADD is_masked BOOLEAN;
|
||||||
|
|
||||||
|
CREATE MATERIALIZED VIEW IF NOT EXISTS payphone.participants_by_user_id AS
|
||||||
|
SELECT user_id, call_id, channel_id FROM payphone.participants
|
||||||
|
WHERE user_id IS NOT NULL AND call_id IS NOT NULL AND channel_id IS NOT NULL
|
||||||
|
PRIMARY KEY (user_id, call_id);
|
||||||
@@ -7,7 +7,10 @@ use crate::{
|
|||||||
discord::sanitizing::SanitizeDiscordMarkdown,
|
discord::sanitizing::SanitizeDiscordMarkdown,
|
||||||
extras::Extras,
|
extras::Extras,
|
||||||
framework::commands::{
|
framework::commands::{
|
||||||
Command, CommandError, context::CommandContext, permissions::Permission,
|
Command, CommandError,
|
||||||
|
arguments::{Arg, ParseArguments},
|
||||||
|
context::CommandContext,
|
||||||
|
permissions::Permission,
|
||||||
},
|
},
|
||||||
groups::calls::{
|
groups::calls::{
|
||||||
get_display_profile,
|
get_display_profile,
|
||||||
@@ -224,10 +227,7 @@ impl Command<State, Extras> for SkipCommand {
|
|||||||
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(&format!(
|
.content(&format!("☎️ {}", get_string_call_answered(ctx.prefix)))
|
||||||
"☎️ {}",
|
|
||||||
get_string_call_hangup_other_party(ctx.prefix)
|
|
||||||
))
|
|
||||||
.await
|
.await
|
||||||
.bye();
|
.bye();
|
||||||
} else {
|
} else {
|
||||||
@@ -427,3 +427,88 @@ impl Command<State, Extras> for FriendRequestCommand {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct MaskCommand;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Command<State, Extras> for MaskCommand {
|
||||||
|
fn name(&self) -> &'static str {
|
||||||
|
"mask"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn aliases(&self) -> &'static [&'static str] {
|
||||||
|
&["m"]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn description(&self) -> &'static str {
|
||||||
|
"Masks your profile from the other party and updates your preferences for future calls."
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn execute(
|
||||||
|
&self,
|
||||||
|
mut ctx: CommandContext<'_, State, Extras>,
|
||||||
|
args: &str,
|
||||||
|
) -> Result<(), CommandError> {
|
||||||
|
let Arg(toggle) = match Arg::<Option<bool>>::parse(args, &ctx).await {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(_) => {
|
||||||
|
ctx
|
||||||
|
.send()
|
||||||
|
.content(
|
||||||
|
format!(
|
||||||
|
"❓ Are you sure that's correct? Use `{}mask on` and `{}mask off`, or just `{}mask` to toggle it.",
|
||||||
|
ctx.prefix, ctx.prefix, ctx.prefix
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(toggle) = toggle {
|
||||||
|
ctx.extras.user.is_masked = toggle;
|
||||||
|
} else {
|
||||||
|
ctx.extras.user.is_masked = !ctx.extras.user.is_masked;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.extras.user.insert(&ctx.rt.state.db).await?;
|
||||||
|
|
||||||
|
let Some(channel) =
|
||||||
|
Channel::get_by_id(ctx.event.channel_id.get(), &ctx.rt.state.db).await?
|
||||||
|
else {
|
||||||
|
ctx
|
||||||
|
.send()
|
||||||
|
.content(
|
||||||
|
format!(
|
||||||
|
"🎭 Your mask was set to `{}`. You can toggle your mask on or off using `{}mask on` and `{}mask off`.",
|
||||||
|
if ctx.extras.user.is_masked { "on" } else { "off" },
|
||||||
|
ctx.prefix,
|
||||||
|
ctx.prefix
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(call_id) = channel.call_id {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ctx
|
||||||
|
.send()
|
||||||
|
.content(
|
||||||
|
format!(
|
||||||
|
"🎭 Your mask was set to `{}`. You can toggle your mask on or off using `{}mask on` and `{}mask off`.",
|
||||||
|
if ctx.extras.user.is_masked { "on" } else { "off" },
|
||||||
|
ctx.prefix,
|
||||||
|
ctx.prefix
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user