mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
commit
79764cd549
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -970,26 +970,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