mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-13 07:29:30 +01:00
implement who reply like ngircd
This commit is contained in:
parent
b17e62d0b0
commit
bb64d38684
@ -19,6 +19,7 @@ type Client struct {
|
|||||||
ctime time.Time
|
ctime time.Time
|
||||||
flags map[UserMode]bool
|
flags map[UserMode]bool
|
||||||
friends map[*Client]uint
|
friends map[*Client]uint
|
||||||
|
hops uint
|
||||||
hostname string
|
hostname string
|
||||||
idleTimer *time.Timer
|
idleTimer *time.Timer
|
||||||
loginTimer *time.Timer
|
loginTimer *time.Timer
|
||||||
|
26
irc/reply.go
26
irc/reply.go
@ -341,14 +341,32 @@ func RplChannelModeIs(channel *Channel) Reply {
|
|||||||
|
|
||||||
// <channel> <user> <host> <server> <nick> ( "H" / "G" ) ["*"] [ ( "@" / "+" ) ]
|
// <channel> <user> <host> <server> <nick> ( "H" / "G" ) ["*"] [ ( "@" / "+" ) ]
|
||||||
// :<hopcount> <real name>
|
// :<hopcount> <real name>
|
||||||
func RplWhoReply(server *Server, channel *Channel, client *Client) Reply {
|
func RplWhoReply(channel *Channel, client *Client) Reply {
|
||||||
channelName := "*"
|
channelName := "*"
|
||||||
|
flags := ""
|
||||||
|
|
||||||
|
if client.flags[Away] {
|
||||||
|
flags = "G"
|
||||||
|
} else {
|
||||||
|
flags = "H"
|
||||||
|
}
|
||||||
|
if client.flags[Operator] {
|
||||||
|
flags += "*"
|
||||||
|
}
|
||||||
|
|
||||||
if channel != nil {
|
if channel != nil {
|
||||||
channelName = channel.name
|
channelName = channel.name
|
||||||
|
|
||||||
|
if channel.members[client][ChannelOperator] {
|
||||||
|
flags += "@"
|
||||||
|
} else if channel.members[client][Voice] {
|
||||||
|
flags += "+"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NewNumericReply(server, RPL_WHOREPLY, "%s %s %s %s %s H :0 %s",
|
return NewNumericReply(client.server, RPL_WHOREPLY,
|
||||||
channelName, client.username, client.hostname, server.name, client.Nick(),
|
"%s %s %s %s %s %s :%d %s",
|
||||||
client.realname)
|
channelName, client.username, client.hostname, client.server.name,
|
||||||
|
client.Nick(), flags, client.hops, client.realname)
|
||||||
}
|
}
|
||||||
|
|
||||||
// <name> :End of WHO list
|
// <name> :End of WHO list
|
||||||
|
@ -477,9 +477,11 @@ func (msg *ChannelModeCommand) HandleServer(server *Server) {
|
|||||||
channel.Mode(client, msg.changes)
|
channel.Mode(client, msg.changes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func whoChannel(client *Client, server *Server, channel *Channel) {
|
func whoChannel(client *Client, channel *Channel) {
|
||||||
for member := range channel.members {
|
for member := range channel.members {
|
||||||
client.Reply(RplWhoReply(server, channel, member))
|
if !client.flags[Invisible] {
|
||||||
|
client.Reply(RplWhoReply(channel, member))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,17 +492,17 @@ func (msg *WhoCommand) HandleServer(server *Server) {
|
|||||||
mask := string(msg.mask)
|
mask := string(msg.mask)
|
||||||
if mask == "" {
|
if mask == "" {
|
||||||
for _, channel := range server.channels {
|
for _, channel := range server.channels {
|
||||||
whoChannel(client, server, channel)
|
whoChannel(client, channel)
|
||||||
}
|
}
|
||||||
} else if IsChannel(mask) {
|
} else if IsChannel(mask) {
|
||||||
channel := server.channels[mask]
|
channel := server.channels[mask]
|
||||||
if channel != nil {
|
if channel != nil {
|
||||||
whoChannel(client, server, channel)
|
whoChannel(client, channel)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mclient := server.clients[mask]
|
mclient := server.clients[mask]
|
||||||
if mclient != nil {
|
if mclient != nil && !mclient.flags[Invisible] {
|
||||||
client.Reply(RplWhoReply(server, mclient.channels.First(), mclient))
|
client.Reply(RplWhoReply(nil, mclient))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user