From d549432b4227c3520fdf790d5df9b4a2e997523e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 28 Jan 2022 14:07:05 +0300 Subject: feat(clbot): Add list of strings that should never ping ... including marcus, which is the name of a person in the channel as well as the name of a machine of wpcarro's. Change-Id: I84bd83413175880663b3dafbdb760bbe9d23cef5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5086 Tested-by: BuildkiteCI Reviewed-by: sterni Autosubmit: tazjin --- fun/clbot/clbot.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fun/clbot/clbot.go b/fun/clbot/clbot.go index c259987a52..e5a5990ef2 100644 --- a/fun/clbot/clbot.go +++ b/fun/clbot/clbot.go @@ -40,6 +40,8 @@ var ( notifyRepo = flag.String("notify_repo", "depot", "Repo name to notify about") notifyBranches = stringSetFlag{} + + neverPing = flag.String("never_ping", "marcus", "Comma-separated terms that should never ping users") ) func init() { @@ -181,7 +183,13 @@ func noping(user string) string { // message. With this users will not be pinged for their own CLs, but // they will be notified if someone else writes a CL that includes // their username. +// +// Also applies noping to all instances of the words in `neverPing`. func nopingAll(username, message string) string { + for _, word := range strings.Split(*neverPing, ",") { + message = strings.ReplaceAll(message, word, noping(word)) + } + return strings.ReplaceAll(message, username, noping(username)) } -- cgit 1.4.1