Changeset 563 in code for trunk/downstream.go


Ignore:
Timestamp:
Jun 23, 2021, 5:23:09 PM (4 years ago)
Author:
contact
Message:

Allow admins to broadcast message to all bouncer users

Typically done via:

/notice $<bouncer> <message>

Or, for a connection not bound to a specific network:

/notice $* <message>

The message is broadcast as BouncerServ, because that's the only
user that can be trusted to belong to the bouncer by users. Any
other prefix would conflict with the upstream network.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r562 r563  
    19141914
    19151915                for _, name := range strings.Split(targetsStr, ",") {
     1916                        if name == "$"+dc.srv.Hostname || (name == "$*" && dc.network == nil) {
     1917                                // "$" means a server mask follows. If it's the bouncer's
     1918                                // hostname, broadcast the message to all bouncer users.
     1919                                if !dc.user.Admin {
     1920                                        return ircError{&irc.Message{
     1921                                                Prefix:  dc.srv.prefix(),
     1922                                                Command: irc.ERR_BADMASK,
     1923                                                Params:  []string{dc.nick, name, "Permission denied to broadcast message to all bouncer users"},
     1924                                        }}
     1925                                }
     1926
     1927                                dc.logger.Printf("broadcasting bouncer-wide %v: %v", msg.Command, text)
     1928
     1929                                broadcastTags := tags.Copy()
     1930                                broadcastTags["time"] = irc.TagValue(time.Now().UTC().Format(serverTimeLayout))
     1931                                broadcastMsg := &irc.Message{
     1932                                        Tags:    broadcastTags,
     1933                                        Prefix:  servicePrefix,
     1934                                        Command: msg.Command,
     1935                                        Params:  []string{name, text},
     1936                                }
     1937                                dc.srv.forEachUser(func(u *user) {
     1938                                        u.events <- eventBroadcast{broadcastMsg}
     1939                                })
     1940                                continue
     1941                        }
     1942
    19161943                        if dc.network == nil && casemapASCII(name) == dc.nickCM {
    19171944                                dc.SendMessage(msg)
Note: See TracChangeset for help on using the changeset viewer.