summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-12-21 15:57:30 +0100
committerdelthas <delthas@dille.cc>2022-12-21 15:57:38 +0100
commit08449325007875e9ef858481733ee3fbe1a4b2eb (patch)
tree2b10f620ddf1f235fdc2593affefc0a714372709
parentBump go-libnp (diff)
Implement /OPER
Fixes: https://todo.sr.ht/~taiite/senpai/105
-rw-r--r--commands.go17
-rw-r--r--doc/senpai.1.scd3
-rw-r--r--irc/session.go4
3 files changed, 24 insertions, 0 deletions
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: "<username> <password>",
+ 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* <nickname>
Change your nickname.
+*OPER* <username> <password>
+ Log in to an operator account.
+
*MODE* <nick/channel> <flags> [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")
}