Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Print error to the log, don't send it to user
Browse files Browse the repository at this point in the history
It could leak the bot token in case of a network error. Credits for the bug
go to @Meidum.
  • Loading branch information
ilyaglow committed Aug 16, 2018
1 parent 7e76b3c commit 416909a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ func (c *Client) Run() {
log.Printf("username: %s, id: %d, text: %s", update.CallbackQuery.Message.From.UserName, update.CallbackQuery.Message.From.ID, update.CallbackQuery.Message.Text)
go func() {
if err := c.processCallback(update.CallbackQuery); err != nil {
msg := tgbotapi.NewMessage(update.CallbackQuery.Message.Chat.ID, err.Error())
msg.ReplyToMessageID = update.CallbackQuery.Message.MessageID
go c.Bot.Send(msg)
log.Println(err)
}
}()
} else {
Expand All @@ -49,8 +47,7 @@ func (c *Client) Run() {
if c.CheckAuth(update.Message.From) {
go func() {
if err := c.processMessage(update.Message); err != nil {
msg.Text = err.Error()
go c.Bot.Send(msg)
log.Println(err)
}
}()
} else {
Expand Down

0 comments on commit 416909a

Please sign in to comment.