summaryrefslogtreecommitdiff
path: root/commands.go
diff options
context:
space:
mode:
authorAlexey Yerin <yyp@disroot.org>2021-05-21 13:05:45 +0300
committerHubert Hirtz <hubert@hirtz.pm>2021-05-21 12:33:50 +0200
commitb37d05f6de774aaf8d10166b199c1117235e2312 (patch)
tree127f5c126f6cd072a266d292dea8fabc94e873bb /commands.go
parentRemove parenthesis around notices (diff)
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.
Diffstat (limited to 'commands.go')
-rw-r--r--commands.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/commands.go b/commands.go
index 6190ed8..6e68d27 100644
--- a/commands.go
+++ b/commands.go
@@ -122,7 +122,13 @@ func init() {
}
}
-func noCommand(app *App, buffer, content string) {
+func noCommand(app *App, buffer, content string) error {
+ // You can't send messages to home buffer, and it might get
+ // delivered to a user "home" without a bouncer, which will be bad.
+ if buffer == "home" {
+ return fmt.Errorf("Can't send message to home")
+ }
+
app.s.PrivMsg(buffer, content)
if !app.s.HasCapability("echo-message") {
buffer, line, _ := app.formatMessage(irc.MessageEvent{
@@ -135,6 +141,8 @@ func noCommand(app *App, buffer, content string) {
})
app.win.AddLine(buffer, false, line)
}
+
+ return nil
}
func commandDoHelp(app *App, buffer string, args []string) (err error) {
@@ -434,8 +442,7 @@ func (app *App) handleInput(buffer, content string) error {
cmdName, rawArgs, isCommand := parseCommand(content)
if !isCommand {
- noCommand(app, buffer, content)
- return nil
+ return noCommand(app, buffer, content)
}
if cmdName == "" {
return fmt.Errorf("lone slash at the begining")