commit b37d05f

Alexey Yerin  ·  2021-05-21 10:05:45 +0000 UTC
parent a731c1d
Disallow sending messages to home

This is not a channel and if one wants to send messages to user "home",
they would do "/msg home ..." instead.
1 files changed,  +10, -3
+10, -3
 1@@ -122,7 +122,13 @@ func init() {
 2 	}
 3 }
 4 
 5-func noCommand(app *App, buffer, content string) {
 6+func noCommand(app *App, buffer, content string) error {
 7+	// You can't send messages to home buffer, and it might get
 8+	// delivered to a user "home" without a bouncer, which will be bad.
 9+	if buffer == "home" {
10+		return fmt.Errorf("Can't send message to home")
11+	}
12+
13 	app.s.PrivMsg(buffer, content)
14 	if !app.s.HasCapability("echo-message") {
15 		buffer, line, _ := app.formatMessage(irc.MessageEvent{
16@@ -135,6 +141,8 @@ func noCommand(app *App, buffer, content string) {
17 		})
18 		app.win.AddLine(buffer, false, line)
19 	}
20+
21+	return nil
22 }
23 
24 func commandDoHelp(app *App, buffer string, args []string) (err error) {
25@@ -434,8 +442,7 @@ func (app *App) handleInput(buffer, content string) error {
26 
27 	cmdName, rawArgs, isCommand := parseCommand(content)
28 	if !isCommand {
29-		noCommand(app, buffer, content)
30-		return nil
31+		return noCommand(app, buffer, content)
32 	}
33 	if cmdName == "" {
34 		return fmt.Errorf("lone slash at the begining")