3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00

support $$server and $#hostname global messages

This commit is contained in:
jesopo 2021-04-20 10:38:20 +00:00
parent 50d32924ef
commit 0a1537f928

View File

@ -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]