diff options
author | Hubert Hirtz <hubert@hirtz.pm> | 2021-02-18 17:13:16 +0100 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-02-18 17:25:31 +0100 |
commit | fc101c7f0aa0323ef97fd55db6534aa65f4831af (patch) | |
tree | 54f62f02f18e773103a9291a032008c198b50b6b | |
parent | Recognize beginning of commands (diff) |
Add the QUIT command
-rw-r--r-- | commands.go | 16 | ||||
-rw-r--r-- | doc/senpai.1.scd | 9 | ||||
-rw-r--r-- | irc/states.go | 14 |
3 files changed, 36 insertions, 3 deletions
diff --git a/commands.go b/commands.go index 993698d..b1cc9dd 100644 --- a/commands.go +++ b/commands.go @@ -64,6 +64,12 @@ func init() { Desc: "part a channel", Handle: commandDoPart, }, + "QUIT": { + AllowHome: true, + Usage: "[reason]", + Desc: "quit senpai", + Handle: commandDoQuit, + }, "QUOTE": { MinArgs: 1, AllowHome: true, @@ -248,6 +254,16 @@ func commandDoPart(app *App, buffer string, args []string) (err error) { return } +func commandDoQuit(app *App, buffer string, args []string) (err error) { + reason := "" + if 0 < len(args) { + reason = args[0] + } + app.s.Quit(reason) + app.win.Exit() + return +} + func commandDoQuote(app *App, buffer string, args []string) (err error) { app.s.SendRaw(args[0]) return diff --git a/doc/senpai.1.scd b/doc/senpai.1.scd index 49464d4..9298552 100644 --- a/doc/senpai.1.scd +++ b/doc/senpai.1.scd @@ -109,12 +109,15 @@ _name_ is matched case-insensitively. It can be one of the following: *HELP* [search] Show the list of command (or a commands that match the given search terms). -*J*, *JOIN* <channel> +*JOIN* <channel> Join the given channel. -*PART* [channel] +*PART* [channel] [reason] Part the given channel, defaults to the current one if omitted. +*QUIT* [reason] + Quits senpai. + *NAMES* Show the member list of the current channel. Powerlevels (such as _@_ for "operator", or _+_ for "voice") are shown in green. @@ -128,7 +131,7 @@ _name_ is matched case-insensitively. It can be one of the following: *MSG* <target> <content> Send _content_ to _target_. -*R* <content> +*REPLY* <content> Reply to the last person who sent a private message. *ME* <content> diff --git a/irc/states.go b/irc/states.go index 87c2a06..9737565 100644 --- a/irc/states.go +++ b/irc/states.go @@ -96,6 +96,9 @@ type ( Channel string Topic string } + actionQuit struct { + Reason string + } actionPrivMsg struct { Target string @@ -390,6 +393,15 @@ func (s *Session) setTopic(act actionSetTopic) (err error) { return } +func (s *Session) Quit(reason string) { + s.acts <- actionQuit{reason} +} + +func (s *Session) quit(act actionQuit) (err error) { + err = s.send("QUIT :%s\r\n", act.Reason) + return +} + func (s *Session) PrivMsg(target, content string) { s.acts <- actionPrivMsg{target, content} } @@ -469,6 +481,8 @@ func (s *Session) run() { err = s.part(act) case actionSetTopic: err = s.setTopic(act) + case actionQuit: + err = s.quit(act) case actionPrivMsg: err = s.privMsg(act) case actionTyping: |