mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 11:59:40 +01:00
fix #1161
This commit is contained in:
parent
1aad7bed51
commit
696980367d
@ -1460,3 +1460,10 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client, rb *ResponseBuf
|
||||
rb.Add(nil, inviter.server.name, RPL_AWAY, cnick, tnick, invitee.AwayMessage())
|
||||
}
|
||||
}
|
||||
|
||||
// data for RPL_LIST
|
||||
func (channel *Channel) listData() (memberCount int, name, topic string) {
|
||||
channel.stateMutex.RLock()
|
||||
defer channel.stateMutex.RUnlock()
|
||||
return len(channel.members), channel.name, channel.topic
|
||||
}
|
||||
|
@ -1530,6 +1530,13 @@ func listHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
||||
}
|
||||
}
|
||||
|
||||
nick := client.Nick()
|
||||
rplList := func(channel *Channel) {
|
||||
if members, name, topic := channel.listData(); members != 0 {
|
||||
rb.Add(nil, client.server.name, RPL_LIST, nick, name, strconv.Itoa(members), topic)
|
||||
}
|
||||
}
|
||||
|
||||
clientIsOp := client.HasMode(modes.Operator)
|
||||
if len(channels) == 0 {
|
||||
for _, channel := range server.channels.Channels() {
|
||||
@ -1537,7 +1544,7 @@ func listHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
||||
continue
|
||||
}
|
||||
if matcher.Matches(channel) {
|
||||
client.RplList(channel, rb)
|
||||
rplList(channel)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1555,7 +1562,7 @@ func listHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
||||
continue
|
||||
}
|
||||
if matcher.Matches(channel) {
|
||||
client.RplList(channel, rb)
|
||||
rplList(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -967,26 +967,6 @@ func (matcher *elistMatcher) Matches(channel *Channel) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// RplList returns the RPL_LIST numeric for the given channel.
|
||||
func (target *Client) RplList(channel *Channel, rb *ResponseBuffer) {
|
||||
// get the correct number of channel members
|
||||
var memberCount int
|
||||
if target.HasMode(modes.Operator) || channel.hasClient(target) {
|
||||
memberCount = len(channel.Members())
|
||||
} else {
|
||||
for _, member := range channel.Members() {
|
||||
if !member.HasMode(modes.Invisible) {
|
||||
memberCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #704: some channels are kept around even with no members
|
||||
if memberCount != 0 {
|
||||
rb.Add(nil, target.server.name, RPL_LIST, target.nick, channel.name, strconv.Itoa(memberCount), channel.topic)
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
infoString1 = strings.Split(` ▄▄▄ ▄▄▄· ▄▄ • ▐ ▄
|
||||
▪ ▀▄ █·▐█ ▀█ ▐█ ▀ ▪▪ •█▌▐█▪
|
||||
|
Loading…
Reference in New Issue
Block a user