commit 7814ff1
Hubert Hirtz
·
2020-08-24 20:25:54 +0000 UTC
parent 30b582d
Allow /part with a reason
2 files changed,
+16,
-9
M
app.go
M
app.go
+12,
-6
1@@ -359,15 +359,21 @@ func (app *App) handleInput(buffer, content string) {
2 case "J", "JOIN":
3 app.s.Join(args)
4 case "PART":
5- if buffer == ui.Home {
6- return
7+ channel := buffer
8+ reason := args
9+ spl := strings.SplitN(args, " ", 2)
10+ if 0 < len(spl) && app.s.IsChannel(spl[0]) {
11+ channel = spl[0]
12+ if 1 < len(spl) {
13+ reason = spl[1]
14+ } else {
15+ reason = ""
16+ }
17 }
18
19- if args == "" {
20- args = buffer
21+ if channel != ui.Home {
22+ app.s.Part(channel, reason)
23 }
24-
25- app.s.Part(args)
26 case "NAMES":
27 if buffer == ui.Home {
28 return
+4,
-3
1@@ -80,6 +80,7 @@ type (
2 }
3 actionPart struct {
4 Channel string
5+ Reason string
6 }
7 actionSetTopic struct {
8 Channel string
9@@ -289,12 +290,12 @@ func (s *Session) join(act actionJoin) (err error) {
10 return
11 }
12
13-func (s *Session) Part(channel string) {
14- s.acts <- actionPart{channel}
15+func (s *Session) Part(channel, reason string) {
16+ s.acts <- actionPart{channel, reason}
17 }
18
19 func (s *Session) part(act actionPart) (err error) {
20- err = s.send("PART %s\r\n", act.Channel)
21+ err = s.send("PART %s :%s\r\n", act.Channel, act.Reason)
22 return
23 }
24