Add users matching

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-12-31 19:46:55 +01:00
parent 3a3959c79c
commit 433b84fcb7
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 11 additions and 0 deletions

View file

@ -37,6 +37,7 @@ type rule struct {
MatchChannels []string `yaml:"match_channels"`
MatchEvent *string `yaml:"match_event"`
MatchMessage *string `yaml:"match_message"`
MatchUsers []string `yaml:"match_users"`
DisableOnMatchMessages []string `yaml:"disable_on_match_messages"`
@ -83,6 +84,13 @@ func (r *rule) Matches(m *irc.Message, event *string) bool {
}
}
if len(r.MatchUsers) > 0 {
if !str.StringInSlice(strings.ToLower(m.User), r.MatchUsers) {
logger.Trace("Non-Match: Users")
return false
}
}
// Check Event match
if r.MatchEvent != nil {
if event == nil || *r.MatchEvent != *event {

View file

@ -47,6 +47,9 @@ rules: # See below for examples
# Require the chat message to be sent in this channel
match_channels: ['#mychannel']
# Require the chat message to be sent by one of these users
match_users: ['mychannel'] # List of users, all names MUST be all lower-case
# Execute actions when this event occurs
match_event: 'permit'