mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-26 13:59:44 +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
|
return len(channel.members) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) GetUsers(replier Replier) {
|
func (channel *Channel) Names(client *Client) {
|
||||||
replier.Reply(NewNamesReply(channel))
|
client.Reply(NewNamesReply(channel))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) ClientIsOperator(client *Client) bool {
|
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.Reply(RplJoin(client, channel))
|
||||||
channel.GetTopic(client)
|
channel.GetTopic(client)
|
||||||
channel.GetUsers(client)
|
channel.Names(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) Part(client *Client, message string) {
|
func (channel *Channel) Part(client *Client, message string) {
|
||||||
|
@ -27,6 +27,7 @@ var (
|
|||||||
LIST: NewListCommand,
|
LIST: NewListCommand,
|
||||||
MODE: NewModeCommand,
|
MODE: NewModeCommand,
|
||||||
MOTD: NewMOTDCommand,
|
MOTD: NewMOTDCommand,
|
||||||
|
NAMES: NewNamesCommand,
|
||||||
NICK: NewNickCommand,
|
NICK: NewNickCommand,
|
||||||
NOTICE: NewNoticeCommand,
|
NOTICE: NewNoticeCommand,
|
||||||
OPER: NewOperCommand,
|
OPER: NewOperCommand,
|
||||||
@ -807,3 +808,20 @@ func NewListCommand(args []string) (editableCommand, error) {
|
|||||||
}
|
}
|
||||||
return cmd, nil
|
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"
|
LIST StringCode = "LIST"
|
||||||
MODE StringCode = "MODE"
|
MODE StringCode = "MODE"
|
||||||
MOTD StringCode = "MOTD"
|
MOTD StringCode = "MOTD"
|
||||||
|
NAMES StringCode = "NAMES"
|
||||||
NICK StringCode = "NICK"
|
NICK StringCode = "NICK"
|
||||||
NOTICE StringCode = "NOTICE"
|
NOTICE StringCode = "NOTICE"
|
||||||
OPER StringCode = "OPER"
|
OPER StringCode = "OPER"
|
||||||
|
@ -629,3 +629,22 @@ func (msg *ClientIdle) HandleServer(server *Server) {
|
|||||||
client := msg.Client()
|
client := msg.Client()
|
||||||
client.Reply(RplPing(server, 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