From 08449325007875e9ef858481733ee3fbe1a4b2eb Mon Sep 17 00:00:00 2001 From: delthas Date: Wed, 21 Dec 2022 15:57:30 +0100 Subject: Implement /OPER Fixes: https://todo.sr.ht/~taiite/senpai/105 --- commands.go | 17 +++++++++++++++++ doc/senpai.1.scd | 3 +++ irc/session.go | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/commands.go b/commands.go index 3428ff2..6fb501f 100644 --- a/commands.go +++ b/commands.go @@ -89,6 +89,14 @@ func init() { Desc: "change your nickname", Handle: commandDoNick, }, + "OPER": { + AllowHome: true, + MinArgs: 2, + MaxArgs: 2, + Usage: " ", + Desc: "log in to an operator account", + Handle: commandDoOper, + }, "MODE": { AllowHome: true, MaxArgs: maxArgsInfinite, @@ -420,6 +428,15 @@ func commandDoNick(app *App, args []string) (err error) { return } +func commandDoOper(app *App, args []string) (err error) { + s := app.CurrentSession() + if s == nil { + return errOffline + } + s.Oper(args[0], args[1]) + return +} + func commandDoMode(app *App, args []string) (err error) { _, target := app.win.CurrentBuffer() if len(args) > 0 && !strings.HasPrefix(args[0], "+") && !strings.HasPrefix(args[0], "-") { diff --git a/doc/senpai.1.scd b/doc/senpai.1.scd index 4cb3578..c6b45e2 100644 --- a/doc/senpai.1.scd +++ b/doc/senpai.1.scd @@ -178,6 +178,9 @@ _name_ is matched case-insensitively. It can be one of the following: *NICK* Change your nickname. +*OPER* + Log in to an operator account. + *MODE* [args] Change channel or user modes. diff --git a/irc/session.go b/irc/session.go index 0e0d6ba..cd56ee1 100644 --- a/irc/session.go +++ b/irc/session.go @@ -361,6 +361,10 @@ func (s *Session) ChangeNick(nick string) { s.out <- NewMessage("NICK", nick) } +func (s *Session) Oper(username string, password string) { + s.out <- NewMessage("OPER", username, password) +} + func (s *Session) MOTD() { s.out <- NewMessage("MOTD") } -- cgit v1.2.3