Sanitize mentions on call
This commit is contained in:
Generated
+1
-1
@@ -1431,7 +1431,7 @@ checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
|
||||
|
||||
[[package]]
|
||||
name = "payphone"
|
||||
version = "4.0.5"
|
||||
version = "4.0.6"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "payphone"
|
||||
version = "4.0.5"
|
||||
version = "4.0.6"
|
||||
edition = "2024"
|
||||
default-run = "payphone"
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@ pub trait SanitizeDiscordMarkdown {
|
||||
/// Returns:
|
||||
/// [`String`] - The sanitized string.
|
||||
fn sanitize(&self, hard: bool) -> String;
|
||||
|
||||
/// Sanitizes mentions in a string.
|
||||
///
|
||||
/// Returns:
|
||||
/// [`String`] - The sanitized string.
|
||||
fn sanitize_mentions(&self) -> String;
|
||||
}
|
||||
|
||||
impl<T> SanitizeDiscordMarkdown for T
|
||||
@@ -40,7 +46,13 @@ where
|
||||
};
|
||||
|
||||
// Now block ping attempts — break mentions
|
||||
escaped
|
||||
escaped.sanitize_mentions()
|
||||
}
|
||||
|
||||
fn sanitize_mentions(&self) -> String {
|
||||
let input = self.to_string();
|
||||
|
||||
input
|
||||
.replace("@everyone", "@\u{200B}everyone")
|
||||
.replace("@here", "@\u{200B}here")
|
||||
.replace("<@", "<@\u{200B}") // user mentions
|
||||
|
||||
@@ -247,7 +247,7 @@ impl OnMessageHandler<State> for CallMessageHandler {
|
||||
.allowed_mentions(None)
|
||||
.username(&profile.name)
|
||||
.avatar_url(&profile.avatar_url)
|
||||
.content(&content)
|
||||
.content(&content.sanitize_mentions())
|
||||
.embeds(&embeds)
|
||||
.wait()
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user