mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
kill command
This commit is contained in:
parent
4d2d18caf1
commit
1fe73aaa9e
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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() {
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user