3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 18:52:41 +01:00

kill command

This commit is contained in:
Jeremy Latt 2014-02-25 09:10:16 -08:00
parent 4d2d18caf1
commit 1fe73aaa9e
4 changed files with 43 additions and 2 deletions

View File

@ -33,6 +33,7 @@ var (
ISON: NewIsOnCommand,
JOIN: NewJoinCommand,
KICK: NewKickCommand,
KILL: NewKillCommand,
LIST: NewListCommand,
MODE: NewModeCommand,
MOTD: NewMOTDCommand,
@ -946,3 +947,19 @@ func NewTimeCommand(args []string) (editableCommand, error) {
}
return cmd, nil
}
type KillCommand struct {
BaseCommand
nickname string
comment string
}
func NewKillCommand(args []string) (editableCommand, error) {
if len(args) < 2 {
return nil, NotEnoughArgsError
}
return &KillCommand{
nickname: args[0],
comment: args[1],
}, nil
}

View File

@ -40,6 +40,7 @@ const (
ISON StringCode = "ISON"
JOIN StringCode = "JOIN"
KICK StringCode = "KICK"
KILL StringCode = "KILL"
LIST StringCode = "LIST"
MODE StringCode = "MODE"
MOTD StringCode = "MOTD"

View File

@ -137,6 +137,11 @@ func RplKick(channel *Channel, client *Client, target *Client, comment string) s
channel, target.Nick(), comment)
}
func RplKill(client *Client, target *Client, comment string) string {
return NewStringReply(client, KICK,
"%s :%s", target.Nick(), comment)
}
// numeric replies
func (target *Client) RplWelcome() {

View File

@ -793,9 +793,27 @@ func (msg *InviteCommand) HandleServer(server *Server) {
}
func (msg *TimeCommand) HandleServer(server *Server) {
client := msg.Client()
if (msg.target != "") && (msg.target != server.name) {
msg.Client().ErrNoSuchServer(msg.target)
client.ErrNoSuchServer(msg.target)
return
}
msg.Client().RplTime()
client.RplTime()
}
func (msg *KillCommand) HandleServer(server *Server) {
client := msg.Client()
if !client.flags[Operator] {
client.ErrNoPrivileges()
return
}
target := server.clients.Get(msg.nickname)
if target == nil {
client.ErrNoSuchNick(msg.nickname)
return
}
quitMsg := fmt.Sprintf("KILLed by %s: %s", client.Nick(), msg.comment)
target.Quit(quitMsg)
}