summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.go20
-rw-r--r--doc/senpai.1.scd6
-rw-r--r--irc/session.go4
3 files changed, 29 insertions, 1 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)
diff --git a/doc/senpai.1.scd b/doc/senpai.1.scd
index 52f8568..7ecc50b 100644
--- a/doc/senpai.1.scd
+++ b/doc/senpai.1.scd
@@ -135,7 +135,8 @@ _name_ is matched case-insensitively. It can be one of the following:
Reply to the last person who sent a private message.
*ME* <content>
- Send a message prefixed with your nick (a user action).
+ Send a message prefixed with your nick (a user action). If sent from home,
+ reply to the last person who sent a private message.
*QUOTE* <raw message>
Send _raw message_ verbatim.
@@ -149,6 +150,9 @@ _name_ is matched case-insensitively. It can be one of the following:
*MODE* <nick/channel> <flags> [args]
Change channel or user modes.
+*INVITE* <nick> [channel]
+ Invite _nick_ to _channel_ (the current channel if not given).
+
# SEE ALSO
*senpai*(5)
diff --git a/irc/session.go b/irc/session.go
index 8a3c86b..b98b514 100644
--- a/irc/session.go
+++ b/irc/session.go
@@ -449,6 +449,10 @@ func (s *Session) NewHistoryRequest(target string) *HistoryRequest {
}
}
+func (s *Session) Invite(nick, channel string) {
+ s.out <- NewMessage("INVITE", nick, channel)
+}
+
func (s *Session) HandleMessage(msg Message) (Event, error) {
if s.registered {
return s.handleRegistered(msg)