Changeset 684 in code for trunk/irc.go


Ignore:
Timestamp:
Nov 15, 2021, 1:34:04 PM (4 years ago)
Author:
contact
Message:

Add support for MONITOR

Add support for MONITOR in single-upstream mode.

Each downstream has its own set of monitored targets. These sets
are merged together to compute the MONITOR commands to send to
upstream.

Each upstream has a set of monitored targets accepted by the server
alongside with their status (online/offline). This is used to
directly send replies to downstreams adding a target another
downstream has already added, and send MONITOR S[TATUS] replies.

Co-authored-by: delthas <delthas@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/irc.go

    r673 r684  
    409409}
    410410
     411func generateMonitor(subcmd string, targets []string) []*irc.Message {
     412        maxLength := maxMessageLength - len("MONITOR "+subcmd+" ")
     413
     414        var msgs []*irc.Message
     415        var buf []string
     416        n := 0
     417        for _, target := range targets {
     418                if n+len(target)+1 > maxLength {
     419                        msgs = append(msgs, &irc.Message{
     420                                Command: "MONITOR",
     421                                Params:  []string{subcmd, strings.Join(buf, ",")},
     422                        })
     423                        buf = buf[:0]
     424                        n = 0
     425                }
     426
     427                buf = append(buf, target)
     428                n += len(target) + 1
     429        }
     430
     431        if len(buf) > 0 {
     432                msgs = append(msgs, &irc.Message{
     433                        Command: "MONITOR",
     434                        Params:  []string{subcmd, strings.Join(buf, ",")},
     435                })
     436        }
     437
     438        return msgs
     439}
     440
    411441type joinSorter struct {
    412442        channels []string
     
    635665}
    636666
     667type monitorCasemapMap struct{ casemapMap }
     668
     669func (cm *monitorCasemapMap) Value(name string) (online bool) {
     670        entry, ok := cm.innerMap[cm.casemap(name)]
     671        if !ok {
     672                return false
     673        }
     674        return entry.value.(bool)
     675}
     676
    637677func isWordBoundary(r rune) bool {
    638678        switch r {
Note: See TracChangeset for help on using the changeset viewer.