update dependencies
This commit is contained in:
parent
b07cad742a
commit
be0f70ff32
File diff suppressed because it is too large
Load Diff
|
@ -5,8 +5,7 @@ authors = ["kageru <kageru@encode.moe>"]
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
serenity = { version = "0.10", default_features = false, features = ["client", "rustls_backend", "model", "builder", "gateway", "utils", "cache"] }
|
||||
lazy_static = "1.4.0"
|
||||
fancy-regex = "0.10"
|
||||
async-trait = "0.1.53"
|
||||
tokio = { version = "1.18.2", features = ["rt-multi-thread"] }
|
||||
serenity = { version = "0.11", default_features = false, features = ["client", "rustls_backend", "model", "builder", "gateway", "utils", "cache"] }
|
||||
lazy_static = "1"
|
||||
async-trait = "0.1"
|
||||
tokio = { version = "1", features = ["rt-multi-thread"] }
|
||||
|
|
59
src/main.rs
59
src/main.rs
|
@ -1,6 +1,4 @@
|
|||
#![feature(option_result_contains)]
|
||||
use async_trait::async_trait;
|
||||
use fancy_regex::Regex;
|
||||
use lazy_static::lazy_static;
|
||||
use serenity::{
|
||||
model::{
|
||||
|
@ -18,8 +16,6 @@ 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| d|op|in|us|ng|si|tw|dd|nd| n))a( |$)").unwrap();
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
@ -31,36 +27,15 @@ impl EventHandler for Handler {
|
|||
}
|
||||
}
|
||||
|
||||
fn fix_spelling(msg: &str) -> String {
|
||||
RETARD_REGEX.replace_all(&msg, "**er** ").trim().to_owned()
|
||||
}
|
||||
|
||||
async fn handle_message(ctx: Context, message: Message) -> Result<(), serenity::Error> {
|
||||
if message.guild_id != Some(*SERVER_ID) {
|
||||
return Ok(());
|
||||
}
|
||||
/*
|
||||
// That other idiot who ends words with “a” instead of “er”
|
||||
if message.author.id == 261246789942902794
|
||||
&& RETARD_REGEX.is_match(&message.content).contains(&true)
|
||||
&& !message.content.starts_with("a ")
|
||||
&& !message.content.starts_with("ja ")
|
||||
&& !message.content.starts_with("da ")
|
||||
&& !message.content.starts_with("na ")
|
||||
{
|
||||
message.delete(&ctx).await?;
|
||||
let fixed = fix_spelling(&message.content);
|
||||
message
|
||||
.channel_id
|
||||
.say(&ctx, &format!("{}: {}", message.author.mention(), fixed))
|
||||
.await?;
|
||||
}
|
||||
*/
|
||||
if message.channel_id == *MEME_CHANNEL && is_meme(&message) {
|
||||
react(&ctx, &message, 748564944449962017, "based").await?;
|
||||
react(&ctx, &message, 748564944819060856, "cringe").await?;
|
||||
};
|
||||
let content = message.content_safe(&ctx).await.to_lowercase();
|
||||
let content = message.content_safe(&ctx).to_lowercase();
|
||||
if content.contains("everyone") && content.contains("nitro") && content.contains("http") {
|
||||
println!(
|
||||
"Deleting probable spam from user {}: “{}”",
|
||||
|
@ -96,30 +71,12 @@ fn is_meme(msg: &Message) -> bool {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let mut client =
|
||||
Client::builder(std::env::var("DISCORD_TOKEN").expect("no token in environment"))
|
||||
.event_handler(Handler)
|
||||
.await
|
||||
.expect("Could not create client");
|
||||
let mut client = Client::builder(
|
||||
std::env::var("DISCORD_TOKEN").expect("no token in environment"),
|
||||
GatewayIntents::default(),
|
||||
)
|
||||
.event_handler(Handler)
|
||||
.await
|
||||
.expect("Could not create client");
|
||||
client.start().await.expect("could not start");
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn fix_spelling_test() {
|
||||
let msg = "aba ihr meint es ja bessa zu wissen ohne euch damit auseinanda gesetzt zu haben oda zu wollen";
|
||||
let expected = "ab**er** ihr meint es ja bess**er** zu wissen ohne euch damit auseinand**er** gesetzt zu haben od**er** zu wollen";
|
||||
assert_eq!(fix_spelling(msg), expected);
|
||||
let msg = "your a bad person";
|
||||
assert_eq!(fix_spelling(msg), msg);
|
||||
let msg = "china usa europa da ja manga asia etwa unsa";
|
||||
let expected = "china usa europa da ja manga asia etwa uns**er**";
|
||||
assert_eq!(fix_spelling(msg), expected);
|
||||
let msg = "guta tip";
|
||||
let expected = "gut**er** tip";
|
||||
assert_eq!(fix_spelling(msg), expected);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user