From 0a1537f928f739706261840847b29b70718e019b Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 20 Apr 2021 10:38:20 +0000 Subject: [PATCH 1/5] support $$server and $#hostname global messages --- irc/handlers.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/irc/handlers.go b/irc/handlers.go index c8d6a311..330f7e19 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2157,6 +2157,27 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi return } channel.SendSplitMessage(command, lowestPrefix, tags, client, message, rb) + } else if target[0] == '$' && len(target) > 2 && client.Oper().HasRoleCapab("massmessage") { + details := client.Details() + matcher, err := utils.CompileGlob(target[1:], false) + if err != nil { + rb.Add(nil, server.name, ERR_UNKNOWNERROR, details.nick, command, client.t("Erroneous target")) + return + } + + nickMaskString := details.nickMask + accountName := details.accountName + isBot := client.HasMode(modes.Bot) + for _, tClient := range server.clients.AllClients() { + if matcher.MatchString(fmt.Sprintf("$%s", tClient.server.name)) || // $$servername + matcher.MatchString(fmt.Sprintf("#%s", tClient.Hostname())) { // $#hostname + + tnick := tClient.Details().nick + for _, session := range tClient.Sessions() { + session.sendSplitMsgFromClientInternal(false, nickMaskString, accountName, isBot, nil, command, tnick, message) + } + } + } } else { lowercaseTarget := strings.ToLower(target) service, isService := OragonoServices[lowercaseTarget] From c74a64b88850fc22585c81686ad338b0bcce6846 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 20 Apr 2021 10:50:52 +0000 Subject: [PATCH 2/5] add massmessage oper capab to default.yaml --- default.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/default.yaml b/default.yaml index c97a2b84..4b6fb9c0 100644 --- a/default.yaml +++ b/default.yaml @@ -622,6 +622,7 @@ oper-classes: - "chanreg" - "history" - "defcon" + - "massmessage" # ircd operators opers: From 76697dff0f8e47510909d25eec212035001f858e Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 20 Apr 2021 11:00:09 +0000 Subject: [PATCH 3/5] "massmessage" oper capab in traditional.yaml too --- traditional.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/traditional.yaml b/traditional.yaml index 92d95728..8776dff6 100644 --- a/traditional.yaml +++ b/traditional.yaml @@ -594,6 +594,7 @@ oper-classes: - "chanreg" - "history" - "defcon" + - "massmessage" # ircd operators opers: From 7345ecba482c1778b04bb31e7fe8d01647189664 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 20 Apr 2021 11:04:24 +0000 Subject: [PATCH 4/5] don't Sprintf for each match, Details().nick -> .Nick() --- irc/handlers.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index 330f7e19..5ffb0ee8 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2159,7 +2159,7 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi channel.SendSplitMessage(command, lowestPrefix, tags, client, message, rb) } else if target[0] == '$' && len(target) > 2 && client.Oper().HasRoleCapab("massmessage") { details := client.Details() - matcher, err := utils.CompileGlob(target[1:], false) + matcher, err := utils.CompileGlob(target[2:], false) if err != nil { rb.Add(nil, server.name, ERR_UNKNOWNERROR, details.nick, command, client.t("Erroneous target")) return @@ -2169,10 +2169,10 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi accountName := details.accountName isBot := client.HasMode(modes.Bot) for _, tClient := range server.clients.AllClients() { - if matcher.MatchString(fmt.Sprintf("$%s", tClient.server.name)) || // $$servername - matcher.MatchString(fmt.Sprintf("#%s", tClient.Hostname())) { // $#hostname + if (target[1] == '$' && matcher.MatchString(tClient.server.name)) || // $$servername + (target[1] == '#' && matcher.MatchString(tClient.Hostname())) { // $#hostname - tnick := tClient.Details().nick + tnick := tClient.Nick() for _, session := range tClient.Sessions() { session.sendSplitMsgFromClientInternal(false, nickMaskString, accountName, isBot, nil, command, tnick, message) } From 4700d4c048b7047902c813c81c5256fb5149c11f Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 20 Apr 2021 11:05:05 +0000 Subject: [PATCH 5/5] make gofmt happey :)) --- irc/handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irc/handlers.go b/irc/handlers.go index 5ffb0ee8..c6e36c3b 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2169,7 +2169,7 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi accountName := details.accountName isBot := client.HasMode(modes.Bot) for _, tClient := range server.clients.AllClients() { - if (target[1] == '$' && matcher.MatchString(tClient.server.name)) || // $$servername + if (target[1] == '$' && matcher.MatchString(tClient.server.name)) || // $$servername (target[1] == '#' && matcher.MatchString(tClient.Hostname())) { // $#hostname tnick := tClient.Nick()