forked from External/ergo
nickname: Fix
This commit is contained in:
parent
9e7a590f23
commit
b8dc10f92d
4 changed files with 61 additions and 94 deletions
|
|
@ -10,6 +10,7 @@ import "github.com/DanielOaks/girc-go/ircmsg"
|
|||
// Command represents a command accepted from a client.
|
||||
type Command struct {
|
||||
handler func(server *Server, client *Client, msg ircmsg.IrcMessage) bool
|
||||
oper bool
|
||||
usablePreReg bool
|
||||
leaveClientActive bool // if true, leaves the client active time alone. reversed because we can't default a struct element to True
|
||||
leaveClientIdle bool
|
||||
|
|
@ -22,6 +23,10 @@ func (cmd *Command) Run(server *Server, client *Client, msg ircmsg.IrcMessage) b
|
|||
// command silently ignored
|
||||
return false
|
||||
}
|
||||
if (!cmd.oper) && (!client.flags[Operator]) {
|
||||
client.Send(nil, server.nameString, ERR_NOPRIVILEGES, client.nickString, "Permission Denied - You're not an IRC operator")
|
||||
return false
|
||||
}
|
||||
if len(msg.Params) < cmd.minParams {
|
||||
client.Send(nil, server.nameString, ERR_NEEDMOREPARAMS, client.nickString, msg.Command, "Not enough parameters")
|
||||
return false
|
||||
|
|
@ -76,6 +81,7 @@ var Commands = map[string]Command{
|
|||
"KILL": Command{
|
||||
handler: killHandler,
|
||||
minParams: 2,
|
||||
oper: true,
|
||||
},
|
||||
"LIST": Command{
|
||||
handler: listHandler,
|
||||
|
|
@ -103,10 +109,6 @@ var Commands = map[string]Command{
|
|||
handler: noticeHandler,
|
||||
minParams: 2,
|
||||
},
|
||||
"ONICK": Command{
|
||||
handler: onickHandler,
|
||||
minParams: 2,
|
||||
},
|
||||
"OPER": Command{
|
||||
handler: operHandler,
|
||||
minParams: 2,
|
||||
|
|
@ -141,6 +143,11 @@ var Commands = map[string]Command{
|
|||
usablePreReg: true,
|
||||
minParams: 5,
|
||||
},
|
||||
"SANICK": Command{
|
||||
handler: sanickHandler,
|
||||
minParams: 2,
|
||||
oper: true,
|
||||
},
|
||||
"QUIT": Command{
|
||||
handler: quitHandler,
|
||||
usablePreReg: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue