diff options
author | delthas <delthas@dille.cc> | 2021-11-15 23:29:34 +0100 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-11-16 22:38:58 +0100 |
commit | 0359bd5cc5a62506080c42ce51bc9a10a67ea536 (patch) | |
tree | 85635285a5651068a53fae00d914f8b03c896966 /commands.go | |
parent | Add support for user buffers (diff) |
Add support for the /QUERY command
This lets open a buffer to a user without sending a message.
Diffstat (limited to 'commands.go')
-rw-r--r-- | commands.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/commands.go b/commands.go index 4e534c1..701fe4b 100644 --- a/commands.go +++ b/commands.go @@ -89,6 +89,14 @@ func init() { Desc: "part a channel", Handle: commandDoPart, }, + "QUERY": { + AllowHome: true, + MinArgs: 1, + MaxArgs: 1, + Usage: "[nick]", + Desc: "opens a buffer to a user", + Handle: commandDoQuery, + }, "QUIT": { AllowHome: true, MaxArgs: 1, @@ -410,6 +418,18 @@ func commandDoPart(app *App, args []string) (err error) { return nil } +func commandDoQuery(app *App, args []string) (err error) { + netID, _ := app.win.CurrentBuffer() + s := app.sessions[netID] + target := args[0] + if s.IsChannel(target) { + return fmt.Errorf("cannot query a channel, use JOIN instead") + } + i, _ := app.win.AddBuffer(netID, "", target) + app.win.JumpBufferIndex(i) + return nil +} + func commandDoQuit(app *App, args []string) (err error) { reason := "" if 0 < len(args) { |