commit 0359bd5
delthas
·
2021-11-15 22:29:34 +0000 UTC
parent 916a9c8
Add support for the /QUERY command This lets open a buffer to a user without sending a message.
1 files changed,
+20,
-0
+20,
-0
1@@ -89,6 +89,14 @@ func init() {
2 Desc: "part a channel",
3 Handle: commandDoPart,
4 },
5+ "QUERY": {
6+ AllowHome: true,
7+ MinArgs: 1,
8+ MaxArgs: 1,
9+ Usage: "[nick]",
10+ Desc: "opens a buffer to a user",
11+ Handle: commandDoQuery,
12+ },
13 "QUIT": {
14 AllowHome: true,
15 MaxArgs: 1,
16@@ -410,6 +418,18 @@ func commandDoPart(app *App, args []string) (err error) {
17 return nil
18 }
19
20+func commandDoQuery(app *App, args []string) (err error) {
21+ netID, _ := app.win.CurrentBuffer()
22+ s := app.sessions[netID]
23+ target := args[0]
24+ if s.IsChannel(target) {
25+ return fmt.Errorf("cannot query a channel, use JOIN instead")
26+ }
27+ i, _ := app.win.AddBuffer(netID, "", target)
28+ app.win.JumpBufferIndex(i)
29+ return nil
30+}
31+
32 func commandDoQuit(app *App, args []string) (err error) {
33 reason := ""
34 if 0 < len(args) {