diff --git a/client.go b/client.go index 93d900b..7ded020 100644 --- a/client.go +++ b/client.go @@ -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) +} diff --git a/commands.go b/commands.go index cef9a65..421c109 100644 --- a/commands.go +++ b/commands.go @@ -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) +}