|
@@ -1887,6 +1887,15 @@ func messageHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
|
1887
|
1887
|
if i == maxTargets {
|
1888
|
1888
|
break
|
1889
|
1889
|
}
|
|
1890
|
+
|
|
1891
|
+ if strings.Contains(targetString, "/") {
|
|
1892
|
+ if histType == history.Privmsg {
|
|
1893
|
+ rb.Add(nil, server.name, ERR_NOSUCHNICK, client.Nick(), targetString, client.t("Relayed users cannot be sent private messages"))
|
|
1894
|
+ }
|
|
1895
|
+ // TAGMSG/NOTICEs are intentionally silently dropped
|
|
1896
|
+ continue
|
|
1897
|
+ }
|
|
1898
|
+
|
1890
|
1899
|
// each target gets distinct msgids
|
1891
|
1900
|
splitMsg := utils.MakeMessage(message)
|
1892
|
1901
|
dispatchMessageToTarget(client, clientOnlyTags, histType, msg.Command, targetString, splitMsg, rb)
|
|
@@ -2270,6 +2279,53 @@ func rehashHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
2270
|
2279
|
return false
|
2271
|
2280
|
}
|
2272
|
2281
|
|
|
2282
|
+// RELAYMSG <channel> <spoofed nick> :<message>
|
|
2283
|
+func relaymsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) (result bool) {
|
|
2284
|
+ channel := server.channels.Get(msg.Params[0])
|
|
2285
|
+ if channel == nil {
|
|
2286
|
+ rb.Add(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), utils.SafeErrorParam(msg.Params[0]), client.t("No such channel"))
|
|
2287
|
+ return false
|
|
2288
|
+ }
|
|
2289
|
+
|
|
2290
|
+ if !(channel.ClientIsAtLeast(client, modes.ChannelOperator) || client.HasRoleCapabs("relaymsg-anywhere")) {
|
|
2291
|
+ rb.Add(nil, server.name, "FAIL", "RELAYMSG", "NOT_PRIVED", client.t("Only channel operators or ircops with the 'relaymsg-anywhere' role can relay messages"))
|
|
2292
|
+ return false
|
|
2293
|
+ }
|
|
2294
|
+
|
|
2295
|
+ rawMessage := msg.Params[2]
|
|
2296
|
+ if strings.TrimSpace(rawMessage) == "" {
|
|
2297
|
+ rb.Add(nil, server.name, "FAIL", "RELAYMSG", "BLANK_MSG", client.t("The message must not be blank"))
|
|
2298
|
+ return false
|
|
2299
|
+ }
|
|
2300
|
+ message := utils.MakeMessage(rawMessage)
|
|
2301
|
+
|
|
2302
|
+ nick := msg.Params[1]
|
|
2303
|
+ _, err := CasefoldName(nick)
|
|
2304
|
+ if err != nil {
|
|
2305
|
+ rb.Add(nil, server.name, "FAIL", "RELAYMSG", "INVALID_NICK", client.t("Invalid nickname"))
|
|
2306
|
+ return false
|
|
2307
|
+ }
|
|
2308
|
+ if !strings.Contains(nick, "/") {
|
|
2309
|
+ rb.Add(nil, server.name, "FAIL", "RELAYMSG", "INVALID_NICK", fmt.Sprintf(client.t("Relayed nicknames MUST contain the relaymsg separator %s"), "/"))
|
|
2310
|
+ return false
|
|
2311
|
+ }
|
|
2312
|
+
|
|
2313
|
+ //TODO: add to history here??
|
|
2314
|
+
|
|
2315
|
+ // send msg
|
|
2316
|
+ for _, member := range channel.Members() {
|
|
2317
|
+ for _, session := range member.Sessions() {
|
|
2318
|
+ tagsToUse := make(map[string]string)
|
|
2319
|
+ if session.capabilities.Has(caps.Relaymsg) {
|
|
2320
|
+ tagsToUse["relaymsg"] = client.Nick()
|
|
2321
|
+ }
|
|
2322
|
+
|
|
2323
|
+ session.sendSplitMsgFromClientInternal(false, nick, "", tagsToUse, "PRIVMSG", channel.Name(), message)
|
|
2324
|
+ }
|
|
2325
|
+ }
|
|
2326
|
+ return false
|
|
2327
|
+}
|
|
2328
|
+
|
2273
|
2329
|
// RENAME <oldchan> <newchan> [<reason>]
|
2274
|
2330
|
func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) (result bool) {
|
2275
|
2331
|
result = false
|