summaryrefslogtreecommitdiff
path: root/commands.go
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-07-06 22:17:13 +0200
committerdelthas <delthas@dille.cc>2022-07-06 22:17:13 +0200
commite24f9a5b7f69875d6c0e18303f7f28158a36856f (patch)
treefd3295a6732c63f9a0baf55c413ab69ed02c0b95 /commands.go
parentReset history when flushing lines (diff)
Implement /whois
Diffstat (limited to 'commands.go')
-rw-r--r--commands.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/commands.go b/commands.go
index b43fe2c..072c433 100644
--- a/commands.go
+++ b/commands.go
@@ -136,6 +136,14 @@ func init() {
Desc: "switch to the buffer containing a substring",
Handle: commandDoBuffer,
},
+ "WHOIS": {
+ AllowHome: false,
+ MinArgs: 0,
+ MaxArgs: 1,
+ Usage: "<nick>",
+ Desc: "get information about someone",
+ Handle: commandDoWhois,
+ },
"INVITE": {
AllowHome: true,
MinArgs: 1,
@@ -514,6 +522,25 @@ func commandDoTopic(app *App, args []string) (err error) {
return nil
}
+func commandDoWhois(app *App, args []string) (err error) {
+ netID, channel := app.win.CurrentBuffer()
+ s := app.sessions[netID]
+ if s == nil {
+ return errOffline
+ }
+ var nick string
+ if len(args) == 0 {
+ if s.IsChannel(channel) {
+ return fmt.Errorf("either send this command from a DM, or specify the user")
+ }
+ nick = channel
+ } else {
+ nick = args[0]
+ }
+ s.Whois(nick)
+ return nil
+}
+
func commandDoInvite(app *App, args []string) (err error) {
nick := args[0]
netID, channel := app.win.CurrentBuffer()