Changeset 615 in code for trunk


Ignore:
Timestamp:
Oct 8, 2021, 8:52:03 AM (4 years ago)
Author:
contact
Message:

Add "server notice" command

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/soju.1.scd

    r612 r615  
    330330        Show some bouncer statistics. Only admins can query this information.
    331331
     332*server notice* <message>
     333        Broadcast a notice. All currently connected bouncer users will receive the
     334        message from the special _BouncerServ_ service. Only admins can broadcast a
     335        notice.
     336
    332337# AUTHORS
    333338
  • trunk/service.go

    r614 r615  
    295295                                        admin:  true,
    296296                                },
     297                                "notice": {
     298                                        desc:   "broadcast a notice to all connected bouncer users",
     299                                        handle: handleServiceServerNotice,
     300                                        admin:  true,
     301                                },
    297302                        },
    298303                        admin: true,
     
    979984        return nil
    980985}
     986
     987func handleServiceServerNotice(dc *downstreamConn, params []string) error {
     988        if len(params) != 1 {
     989                return fmt.Errorf("expected exactly one argument")
     990        }
     991        text := params[0]
     992
     993        dc.logger.Printf("broadcasting bouncer-wide NOTICE: %v", text)
     994
     995        broadcastMsg := &irc.Message{
     996                Prefix:  servicePrefix,
     997                Command: "NOTICE",
     998                Params:  []string{"$" + dc.srv.Hostname, text},
     999        }
     1000        dc.srv.forEachUser(func(u *user) {
     1001                u.events <- eventBroadcast{broadcastMsg}
     1002        })
     1003        return nil
     1004}
Note: See TracChangeset for help on using the changeset viewer.