From 0359bd5cc5a62506080c42ce51bc9a10a67ea536 Mon Sep 17 00:00:00 2001 From: delthas Date: Mon, 15 Nov 2021 23:29:34 +0100 Subject: Add support for the /QUERY command This lets open a buffer to a user without sending a message. --- commands.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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) { -- cgit v1.2.3