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, ISON: NewIsOnCommand,
JOIN: NewJoinCommand, JOIN: NewJoinCommand,
KICK: NewKickCommand, KICK: NewKickCommand,
KILL: NewKillCommand,
LIST: NewListCommand, LIST: NewListCommand,
MODE: NewModeCommand, MODE: NewModeCommand,
MOTD: NewMOTDCommand, MOTD: NewMOTDCommand,
@ -946,3 +947,19 @@ func NewTimeCommand(args []string) (editableCommand, error) {
} }
return cmd, nil 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" ISON StringCode = "ISON"
JOIN StringCode = "JOIN" JOIN StringCode = "JOIN"
KICK StringCode = "KICK" KICK StringCode = "KICK"
KILL StringCode = "KILL"
LIST StringCode = "LIST" LIST StringCode = "LIST"
MODE StringCode = "MODE" MODE StringCode = "MODE"
MOTD StringCode = "MOTD" MOTD StringCode = "MOTD"

View File

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

View File

@ -793,9 +793,27 @@ func (msg *InviteCommand) HandleServer(server *Server) {
} }
func (msg *TimeCommand) HandleServer(server *Server) { func (msg *TimeCommand) HandleServer(server *Server) {
client := msg.Client()
if (msg.target != "") && (msg.target != server.name) { if (msg.target != "") && (msg.target != server.name) {
msg.Client().ErrNoSuchServer(msg.target) client.ErrNoSuchServer(msg.target)
return 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)
} }