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 <sternenseemann@systemli.org>
Autosubmit: tazjin <tazjin@tvl.su>
This commit is contained in:
Vincent Ambo 2022-01-28 14:07:05 +03:00 committed by clbot
parent 6a897551cc
commit d549432b42

View file

@ -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))
}