Fix some false positives in spelling correction

This commit is contained in:
kageru 2022-05-31 11:58:59 +02:00
parent 2ce2dee877
commit e0f85df40a
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -17,7 +17,7 @@ lazy_static! {
static ref SERVER_ID: GuildId = GuildId(std::env::args().nth(1).unwrap().parse().unwrap());
static ref MEME_CHANNEL: ChannelId =
ChannelId(std::env::args().nth(2).unwrap().parse().unwrap());
static ref RETARD_REGEX: Regex = Regex::new("([^j])a( |$)").unwrap();
static ref RETARD_REGEX: Regex = Regex::new("([^djDJh ])a( |$)").unwrap();
}
#[async_trait]
@ -44,9 +44,16 @@ async fn handle_message(ctx: Context, message: Message) -> Result<(), serenity::
.channel_id
.say(
&ctx,
RETARD_REGEX.replace_all(&message.content_safe(&ctx).await, |caps: &Captures| {
format!("{}**er**{}", &caps[1], &caps[2])
}),
RETARD_REGEX
.replace_all(&message.content_safe(&ctx).await, |caps: &Captures| {
format!("{}**er**{}", &caps[1], &caps[2])
})
// some common false positives
.replace("etw**er**", "etwa")
.replace("europ**er**", "europa")
.replace("amerik**er**", "amerika")
.replace("chin**er**", "china")
.replace("mang**er**", "manga"),
)
.await?;
}