From 433b84fcb76691da478a3ef6a41ac4f5ec3887a1 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 31 Dec 2020 19:46:55 +0100 Subject: [PATCH] Add users matching Signed-off-by: Knut Ahlers --- config.go | 8 ++++++++ wiki/Home.md | 3 +++ 2 files changed, 11 insertions(+) diff --git a/config.go b/config.go index 604a95c..5469517 100644 --- a/config.go +++ b/config.go @@ -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 { diff --git a/wiki/Home.md b/wiki/Home.md index 0a0d855..237a244 100644 --- a/wiki/Home.md +++ b/wiki/Home.md @@ -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'