diff options
author | Hubert Hirtz <hubert@hirtz.pm> | 2021-10-23 18:42:50 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-10-23 18:45:10 +0200 |
commit | 5ab6aa2d817d25a59876bfcc336603cf89b90001 (patch) | |
tree | 74da92ee10df707e435108ea4581d18c151043a6 /commands.go | |
parent | Add support for the INVITE message (diff) |
Add an /invite command
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 6a30f5f..a548092 100644 --- a/commands.go +++ b/commands.go @@ -121,6 +121,14 @@ func init() { Desc: "switch to the buffer containing a substring", Handle: commandDoBuffer, }, + "INVITE": { + AllowHome: true, + MinArgs: 1, + MaxArgs: 2, + Usage: "<name> [channel]", + Desc: "invite someone to a channel", + Handle: commandDoInvite, + }, } } @@ -383,6 +391,18 @@ func commandDoTopic(app *App, args []string) (err error) { return } +func commandDoInvite(app *App, args []string) (err error) { + nick := args[0] + channel := app.win.CurrentBuffer() + if len(args) == 2 { + channel = args[1] + } else if channel == Home { + return fmt.Errorf("cannot invite to home") + } + app.s.Invite(nick, channel) + return nil +} + // implemented from https://golang.org/src/strings/strings.go?s=8055:8085#L310 func fieldsN(s string, n int) []string { s = strings.TrimSpace(s) |