Changeset 198 in code for trunk/upstream.go


Ignore:
Timestamp:
Apr 1, 2020, 10:16:32 AM (5 years ago)
Author:
contact
Message:

Auto away

Closes: https://todo.sr.ht/~emersion/soju/13

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r197 r198  
    5555        caps       map[string]string
    5656        batches    map[string]batch
     57        away       bool
    5758
    5859        tagsSupported   bool
     
    12701271        case "ACK":
    12711272                // Ignore
     1273        case irc.RPL_NOWAWAY, irc.RPL_UNAWAY:
     1274                // Ignore
    12721275        case irc.RPL_YOURHOST, irc.RPL_CREATED:
    12731276                // Ignore
     
    14841487        }
    14851488}
     1489
     1490func (uc *upstreamConn) updateAway() {
     1491        away := true
     1492        uc.forEachDownstream(func(*downstreamConn) {
     1493                away = false
     1494        })
     1495        if away == uc.away {
     1496                return
     1497        }
     1498        if away {
     1499                uc.SendMessage(&irc.Message{
     1500                        Command: "AWAY",
     1501                        Params:  []string{"Auto away"},
     1502                })
     1503        } else {
     1504                uc.SendMessage(&irc.Message{
     1505                        Command: "AWAY",
     1506                })
     1507        }
     1508        uc.away = away
     1509}
Note: See TracChangeset for help on using the changeset viewer.