-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for some kind of slow mode + regex filter to allow certain words to be banned? #2179
Comments
Sorry to hear about the moderation issues. Personally, I've found that setting channels A robust "slowmode" equivalent is a good idea; we don't have one now but I opened #2180 to investigate it. In the meantime you can try setting more aggressive fakelag settings, although these will penalize all traffic on the server, not just channel messages: Lines 899 to 924 in 30f47a9
If you want to patch in a regex filter, I think this is the best place (compare the handling of Lines 1298 to 1317 in 30f47a9
You can apply the regexes to |
For anyone that wants to implement this in the future, I have created a simple automod system with configurable automod rules. Add this to the // Check if automod is enabled
if channel.server.Config().Automod.Enabled {
// Check message against automod rules
for _, rule := range channel.server.Config().Automod.Rules {
if rule.RegexString != "" {
re := regexp.MustCompile(rule.RegexString)
if re.MatchString(message.Message) {
rb.Add(nil, client.server.name, ERR_CANNOTSENDTOCHAN, client.Nick(), channel.Name(), fmt.Sprintf(client.t("Message blocked by rule: %s"), rule.Name))
return
}
}
for _, word := range rule.BlockedWords {
if strings.Contains(message.Message, word) {
rb.Add(nil, client.server.name, ERR_CANNOTSENDTOCHAN, client.Nick(), channel.Name(), fmt.Sprintf(client.t("Message blocked by rule: %s"), rule.Name))
return
}
}
}
} Update type AutomodRule struct {
Name string `yaml:"name"`
RegexString string `yaml:"regex_string"`
BlockedWords []string `yaml:"blocked_words"`
}
type AutomodConfig struct {
Enabled bool `yaml:"enabled"`
Rules []AutomodRule `yaml:"rules"`
}
type Config struct {
...
Automod AutomodConfig `yaml:"automod"`
} Finally, you can configure your config file ( automod:
enabled: true
rules:
- name: "Don't talk about food."
regex_string: "\bham\b"
blocked_words: ["pizza", "cheese"]
- name: "Don't say this."
blocked_words: ["milk"]
- name: "This content is definitely forbidden."
regex_string: "(?i)\\b(almonds|beans)\\b" If an automod rule is triggered, the user will see which rule was broken.
|
@wlinator I'm not sure if you were the person who asked in #ergo about this, but if you want to exempt users with an operator capability from this check, operator capabilities are just freeform strings written in the config and tested in the code. See Lines 687 to 690 in 1bdc45e
Line 595 in 1bdc45e
|
Is there a way to do this? I don't mind to patch it in myself if needed, but I'm trying to find the main function that handles channel messages (I believe in handlers.go or services.go there's a privmsg function that only handles DMs iirc). I don't have the code pulled up where I can see it right now.
Basically I'm hosting an irc server with ergo that is getting hit with trolls and I'm wanting to lock it down and ban some very offensive words. If I could force a "slow mode" similar to discords slow mode that would be ideal as well.
The text was updated successfully, but these errors were encountered: