commit 9336f97

delthas  ·  2021-10-31 16:21:12 +0000 UTC
parent 19e0026
/mode: default channel to the current channel
1 files changed,  +7, -2
+7, -2
 1@@ -76,9 +76,9 @@ func init() {
 2 		},
 3 		"MODE": {
 4 			AllowHome: true,
 5-			MinArgs:   2,
 6+			MinArgs:   1,
 7 			MaxArgs:   5, // <channel> <flags> <limit> <user> <ban mask>
 8-			Usage:     "<nick/channel> <flags> [args]",
 9+			Usage:     "[<nick/channel>] <flags> [args]",
10 			Desc:      "change channel or user modes",
11 			Handle:    commandDoMode,
12 		},
13@@ -359,6 +359,11 @@ func commandDoNick(app *App, args []string) (err error) {
14 }
15 
16 func commandDoMode(app *App, args []string) (err error) {
17+	if strings.HasPrefix(args[0], "+") || strings.HasPrefix(args[0], "-") {
18+		// if we do eg /MODE +P, automatically insert the current channel: /MODE #<current-chan> +P
19+		_, channel := app.win.CurrentBuffer()
20+		args = append([]string{channel}, args...)
21+	}
22 	channel := args[0]
23 	flags := args[1]
24 	modeArgs := args[2:]