author | nemo |
Mon, 19 Aug 2019 11:41:59 -0400 | |
changeset 15347 | 0230c4766aa6 |
parent 14510 | ba29aa03db87 |
permissions | -rw-r--r-- |
14508
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
1 |
pub mod bad_words; |
14510 | 2 |
pub mod letter_repeat; |
14508
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
3 |
|
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
4 |
use unicode_skeleton::UnicodeSkeleton; |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
5 |
|
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
6 |
#[derive(PartialEq, Debug)] |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
7 |
enum Severity { |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
8 |
Pass, |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
9 |
Warn, |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
10 |
Silence, |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
11 |
Ban, |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
12 |
} |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
13 |
|
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
14 |
trait MessageChecker<T> { |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
15 |
fn check(&self, player_id: T, message: &str) -> Severity; |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
16 |
fn fix(&self, player_id: T, message: &str) -> Option<String> { |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
17 |
None |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
18 |
} |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
19 |
} |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
20 |
|
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
21 |
fn normalized_message(s: &str) -> String { |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
22 |
s.chars() |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
23 |
.flat_map(|c| c.to_lowercase()) |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
24 |
.skeleton_chars() |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
25 |
.collect::<String>() |
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
26 |
} |