Initialize Twilight project, set up basic framework, initialize DB module

This commit is contained in:
2025-08-07 04:32:34 -03:00
parent 00d61545eb
commit 24d2344f37
29 changed files with 4095 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
pub trait EscapeDiscordMarkdown {
fn escape(self) -> String;
}
impl<T> EscapeDiscordMarkdown for T
where
T: ToString,
{
fn escape(self) -> String {
let input = self.to_string();
let mut escaped = String::with_capacity(input.len());
for ch in input.chars() {
match ch {
'\\' | '*' | '_' | '~' | '`' | '>' | '|' | '[' | ']' | '(' | ')' | '#' | '+'
| '-' | '=' | '.' | '!' => {
escaped.push('\\');
escaped.push(ch);
}
_ => escaped.push(ch),
}
}
// Now block ping attempts — break mentions
escaped
.replace("@everyone", "@\u{200B}everyone")
.replace("@here", "@\u{200B}here")
.replace("<@", "<@\u{200B}") // user mentions
.replace("<@&", "<@&\u{200B}") // role mentions
.replace("<#", "<#\u{200B}") // channel mentions
}
}