mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
names command
This commit is contained in:
parent
046723a709
commit
b17e62d0b0
@ -49,8 +49,8 @@ func (channel *Channel) IsEmpty() bool {
|
||||
return len(channel.members) == 0
|
||||
}
|
||||
|
||||
func (channel *Channel) GetUsers(replier Replier) {
|
||||
replier.Reply(NewNamesReply(channel))
|
||||
func (channel *Channel) Names(client *Client) {
|
||||
client.Reply(NewNamesReply(channel))
|
||||
}
|
||||
|
||||
func (channel *Channel) ClientIsOperator(client *Client) bool {
|
||||
@ -128,7 +128,7 @@ func (channel *Channel) Join(client *Client, key string) {
|
||||
|
||||
channel.Reply(RplJoin(client, channel))
|
||||
channel.GetTopic(client)
|
||||
channel.GetUsers(client)
|
||||
channel.Names(client)
|
||||
}
|
||||
|
||||
func (channel *Channel) Part(client *Client, message string) {
|
||||
|
@ -27,6 +27,7 @@ var (
|
||||
LIST: NewListCommand,
|
||||
MODE: NewModeCommand,
|
||||
MOTD: NewMOTDCommand,
|
||||
NAMES: NewNamesCommand,
|
||||
NICK: NewNickCommand,
|
||||
NOTICE: NewNoticeCommand,
|
||||
OPER: NewOperCommand,
|
||||
@ -807,3 +808,20 @@ func NewListCommand(args []string) (editableCommand, error) {
|
||||
}
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
type NamesCommand struct {
|
||||
BaseCommand
|
||||
channels []string
|
||||
target string
|
||||
}
|
||||
|
||||
func NewNamesCommand(args []string) (editableCommand, error) {
|
||||
cmd := &NamesCommand{}
|
||||
if len(args) > 0 {
|
||||
cmd.channels = strings.Split(args[0], ",")
|
||||
}
|
||||
if len(args) > 1 {
|
||||
cmd.target = args[1]
|
||||
}
|
||||
return cmd, nil
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ const (
|
||||
LIST StringCode = "LIST"
|
||||
MODE StringCode = "MODE"
|
||||
MOTD StringCode = "MOTD"
|
||||
NAMES StringCode = "NAMES"
|
||||
NICK StringCode = "NICK"
|
||||
NOTICE StringCode = "NOTICE"
|
||||
OPER StringCode = "OPER"
|
||||
|
@ -629,3 +629,22 @@ func (msg *ClientIdle) HandleServer(server *Server) {
|
||||
client := msg.Client()
|
||||
client.Reply(RplPing(server, client))
|
||||
}
|
||||
|
||||
func (msg *NamesCommand) HandleServer(server *Server) {
|
||||
client := msg.Client()
|
||||
if len(server.channels) == 0 {
|
||||
for _, channel := range server.channels {
|
||||
channel.Names(client)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
for _, chname := range msg.channels {
|
||||
channel := server.channels[chname]
|
||||
if channel == nil {
|
||||
client.Reply(ErrNoSuchChannel(server, chname))
|
||||
continue
|
||||
}
|
||||
channel.Names(client)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user