author | Wuzzy <Wuzzy2@mail.ru> |
Sun, 05 Jul 2020 01:58:48 +0200 | |
branch | ui-scaling |
changeset 15671 | f28ca5a87682 |
parent 14505 | ba29aa03db87 |
permissions | -rw-r--r-- |
14503
831ecafd74c6
Start chat_sanitizer package inspired by chat bot on pokerth server
unc0rr
parents:
diff
changeset
|
1 |
pub mod bad_words; |
14505 | 2 |
pub mod letter_repeat; |
14503
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 |
} |