Skip to content
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

Open
scottc943 opened this issue Jul 29, 2024 · 1 comment

Comments

@scottc943
Copy link

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.

@slingamn
Copy link
Member

Sorry to hear about the moderation issues. Personally, I've found that setting channels +R (only registered users can join) combined with liberal use of the +I list (exempting known-good unregistered users by nickmask) is effective against trolls. (Spamming new registrations is typically mitigated by the account registration throttle, but if it gets bad you can temporarily disable new registrations.)

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:

ergo/default.yaml

Lines 899 to 924 in 30f47a9

# fakelag: prevents clients from spamming commands too rapidly
fakelag:
# whether to enforce fakelag
enabled: true
# time unit for counting command rates
window: 1s
# clients can send this many commands without fakelag being imposed
burst-limit: 5
# once clients have exceeded their burst allowance, they can send only
# this many commands per `window`:
messages-per-window: 2
# client status resets to the default state if they go this long without
# sending any commands:
cooldown: 2s
# exempt a certain number of command invocations per session from fakelag;
# this is to speed up "resynchronization" of client state during reattach
command-budgets:
"CHATHISTORY": 16
"MARKREAD": 16
"MONITOR": 1
"WHO": 4

If you want to patch in a regex filter, I think this is the best place (compare the handling of modes.NoCTCP in this function):

ergo/irc/channel.go

Lines 1298 to 1317 in 30f47a9

func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mode, clientOnlyTags map[string]string, client *Client, message utils.SplitMessage, rb *ResponseBuffer) {
histType, err := msgCommandToHistType(command)
if err != nil {
return
}
if canSpeak, mode := channel.CanSpeak(client); !canSpeak {
if histType != history.Notice {
rb.Add(nil, client.server.name, ERR_CANNOTSENDTOCHAN, client.Nick(), channel.Name(), fmt.Sprintf(client.t("Cannot send to channel (+%s)"), mode))
}
return
}
isCTCP := message.IsRestrictedCTCPMessage()
if isCTCP && channel.flags.HasMode(modes.NoCTCP) {
if histType != history.Notice {
rb.Add(nil, client.server.name, ERR_CANNOTSENDTOCHAN, client.Nick(), channel.Name(), fmt.Sprintf(client.t("Cannot send to channel (+%s)"), "C"))
}
return
}

You can apply the regexes to message.Message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants