go-chat-bot / bot

IRC, Slack, Telegram and RocketChat bot written in go
MIT License
824 stars 194 forks source link

Errors are shown publicly #121

Open ghost opened 4 years ago

ghost commented 4 years ago

Parsing errors are shown publicly, which is kinda odd considering that "command not found", which undoubtably is thrown more frequent, is only logged.

I believe these lines are at fault, https://github.com/go-chat-bot/bot/blob/master/bot.go#L183-L187

Patch attached:

Index: bot.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- bot.go  (revision 3da6cae4547763aa55828a9f75ed4693bed5d36f)
+++ bot.go  (date 1574671039000)
@@ -180,11 +180,7 @@
 func (b *Bot) MessageReceived(channel *ChannelData, message *Message, sender *User) {
    command, err := parse(message, channel, sender)
    if err != nil {
-       b.SendMessage(OutgoingMessage{
-           Target:  channel.Channel,
-           Message: err.Error(),
-           Sender:  sender,
-       })
+       log.Fatalf("Error: %v, Channel: %v, Sender: %v", channel.Channel, err.Error(), sender.ID)
        return
    }