diff options
author | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-24 22:25:54 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-24 22:25:54 +0200 |
commit | 7814ff17e30f85c1f16b90eb66bf5c2a0e850bca (patch) | |
tree | 8f7e6a46510e7e69ba6b076b519b90ae8fe90cca | |
parent | Drop username and hostname from TopicWho (diff) |
Allow /part with a reason
-rw-r--r-- | app.go | 18 | ||||
-rw-r--r-- | irc/states.go | 7 |
2 files changed, 16 insertions, 9 deletions
@@ -359,15 +359,21 @@ func (app *App) handleInput(buffer, content string) { case "J", "JOIN": app.s.Join(args) case "PART": - if buffer == ui.Home { - return + channel := buffer + reason := args + spl := strings.SplitN(args, " ", 2) + if 0 < len(spl) && app.s.IsChannel(spl[0]) { + channel = spl[0] + if 1 < len(spl) { + reason = spl[1] + } else { + reason = "" + } } - if args == "" { - args = buffer + if channel != ui.Home { + app.s.Part(channel, reason) } - - app.s.Part(args) case "NAMES": if buffer == ui.Home { return diff --git a/irc/states.go b/irc/states.go index 4dd0751..2628a9e 100644 --- a/irc/states.go +++ b/irc/states.go @@ -80,6 +80,7 @@ type ( } actionPart struct { Channel string + Reason string } actionSetTopic struct { Channel string @@ -289,12 +290,12 @@ func (s *Session) join(act actionJoin) (err error) { return } -func (s *Session) Part(channel string) { - s.acts <- actionPart{channel} +func (s *Session) Part(channel, reason string) { + s.acts <- actionPart{channel, reason} } func (s *Session) part(act actionPart) (err error) { - err = s.send("PART %s\r\n", act.Channel) + err = s.send("PART %s :%s\r\n", act.Channel, act.Reason) return } |