Add Handler support for OPER command

This commit is contained in:
justin 2015-08-28 16:19:03 -04:00
parent 1b12cbfb34
commit 08973839bc
2 changed files with 27 additions and 0 deletions

View File

@ -309,3 +309,18 @@ func (c *Client) Who() {
m := irc.Message{Prefix: c.Server.Prefix, Command: irc.RPL_ENDOFWHO, Params: []string{c.Nickname, "*"}, Trailing: "End of WHO list"}
c.Encode(&m)
}
// MakeOper makes this client a server operator
func (c *Client) MakeOper() {
c.AddMode(UserModeOperator)
m := irc.Message{Prefix: c.Server.Prefix, Command: irc.MODE, Params: []string{c.Nickname, "+o"}}
for name, client := range c.Server.clientsByNick {
if name == c.Nickname {
continue
}
client.Encode(&m)
}
m = irc.Message{Prefix: c.Server.Prefix, Command: irc.RPL_YOUREOPER, Params: []string{c.Nickname}, Trailing: "You are now an IRC operator"}
c.Encode(&m)
}

View File

@ -1071,3 +1071,15 @@ func IsonHandler(message *irc.Message, client *Client) {
client.Encode(&m)
}
// OperHandler is a specialized CommandHandler to respond to channel IRC OPER commands from a client
// Implemented according to RFC 1459 Section 4.1.5 and RFC 2812 Section 3.1.4
func OperHandler(message *irc.Message, client *Client) {
if len(message.Params) < 2 {
m := irc.Message{Prefix: client.Server.Prefix, Command: irc.ERR_NEEDMOREPARAMS, Params: []string{client.Nickname}, Trailing: "Not enough parameters"}
client.Encode(&m)
return
}
client.Server.Authenticate(message.Params[0], message.Params[1], client)
}