summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app.go18
-rw-r--r--irc/states.go7
2 files changed, 16 insertions, 9 deletions
diff --git a/app.go b/app.go
index 48621a2..4ccf47a 100644
--- a/app.go
+++ b/app.go
@@ -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
}