增加了发布通道

This commit is contained in:
sansen
2026-07-23 19:37:20 +08:00
parent e3d03d74ea
commit e8a45032f8
35 changed files with 1489 additions and 413 deletions
@@ -61,7 +61,10 @@ func (c *Client) handleClientEnterView(cmd *commands.Command) {
c.mu.Lock()
c.clients[clid] = info
unescapedNick := commands.Unescape(nick)
if isAutoNicknameMatch(c.nickname, unescapedNick) {
// Only allow clid override from nickname match if we haven't received initserver yet.
// After initserver, the clid is authoritative and should not be overwritten by
// stale same-UID sessions that happen to have matching nicknames.
if c.clid == 0 && isAutoNicknameMatch(c.nickname, unescapedNick) {
c.clid = clid
c.handler.SetClientID(clid)
}
@@ -80,11 +83,16 @@ func (c *Client) handleClientLeftView(cmd *commands.Command) {
if clid != 0 {
c.mu.Lock()
isSelf := (clid == c.clid)
uid := ""
if info, ok := c.clients[clid]; ok {
uid = info.UID
}
delete(c.clients, clid)
c.mu.Unlock()
evt := ClientLeftViewEvent{
ID: clid,
UID: uid,
ReasonID: reasonID,
ReasonMsg: reasonMsg,
}
@@ -34,6 +34,7 @@ type ClientLeftViewEvent struct {
ReasonMsg string
ReasonID int
ID uint16
UID string
TargetID uint16
}