Add Handler support for OPER command
This commit is contained in:
parent
1b12cbfb34
commit
08973839bc
15
client.go
15
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"}
|
m := irc.Message{Prefix: c.Server.Prefix, Command: irc.RPL_ENDOFWHO, Params: []string{c.Nickname, "*"}, Trailing: "End of WHO list"}
|
||||||
c.Encode(&m)
|
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)
|
||||||
|
}
|
||||||
|
12
commands.go
12
commands.go
@ -1071,3 +1071,15 @@ func IsonHandler(message *irc.Message, client *Client) {
|
|||||||
client.Encode(&m)
|
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)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user