diff options
author | delthas <delthas@dille.cc> | 2022-07-06 22:17:13 +0200 |
---|---|---|
committer | delthas <delthas@dille.cc> | 2022-07-06 22:17:13 +0200 |
commit | e24f9a5b7f69875d6c0e18303f7f28158a36856f (patch) | |
tree | fd3295a6732c63f9a0baf55c413ab69ed02c0b95 | |
parent | Reset history when flushing lines (diff) |
Implement /whois
-rw-r--r-- | commands.go | 27 | ||||
-rw-r--r-- | irc/session.go | 4 |
2 files changed, 31 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() diff --git a/irc/session.go b/irc/session.go index 9da44cc..2bf2623 100644 --- a/irc/session.go +++ b/irc/session.go @@ -564,6 +564,10 @@ func (s *Session) NewHistoryRequest(target string) *HistoryRequest { } } +func (s *Session) Whois(nick string) { + s.out <- NewMessage("WHOIS", nick) +} + func (s *Session) Invite(nick, channel string) { s.out <- NewMessage("INVITE", nick, channel) } |