Add hidden feature to not send messages when they're preceeded by an X

This commit is contained in:
2025-08-24 03:51:08 -03:00
parent bd09a55a74
commit 497d180669
4 changed files with 37 additions and 10 deletions
+22 -5
View File
@@ -160,8 +160,7 @@ impl OnMessageHandler<State, Extras> for CallMessageHandler {
return Ok(());
};
let user =
User::get_or_create_and_set_last_seen(event.author.clone(), &rt.state.db).await?;
let mut user = User::create_or_update(event.author.clone(), &rt.state.db).await?;
let user_incidents = UserIncident::get_for_user(event.author.id.get(), &rt.state.db)
.await?
@@ -173,6 +172,26 @@ impl OnMessageHandler<State, Extras> for CallMessageHandler {
return Ok(());
}
if event.content.to_ascii_lowercase().starts_with("x ") {
if !user.findings.contains("feature:hide-message") {
user.findings.insert("feature:hide-message".into());
user.insert(&rt.state.db).await?;
rt
.http
.create_message(
event.channel_id
)
.content(
"✨ You found a hidden feature! Messages starting with `x` followed by a space will not be sent to the other party (nor moderated, i.e. you won't get banned for what you say in them)."
)
.reply(event.id)
.await?;
}
return Ok(());
}
let Some(mut opposite_channel) = Channel::get_by_id(
call.other_party_channel_id(event.channel_id.get()),
&rt.state.db,
@@ -462,9 +481,7 @@ impl OnMessageEditHandler<State, Extras> for CallMessageEditHandler {
.reply(event.id)
.await?;
let user =
User::get_or_create_and_set_last_seen(event.author.clone(), &rt.state.db)
.await?;
let user = User::create_or_update(event.author.clone(), &rt.state.db).await?;
penalize_user(user, message, rules, &rt).await?;