Skip to content

Commit

Permalink
fix(senders): fix error validation in telegram (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
almostinf authored Aug 3, 2023
1 parent 267f7f4 commit f29ce12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions senders/telegram/handle_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ func (sender *Sender) handleMessage(message *telebot.Message) error {
return err
}
if responseMessage != "" {
_, err = sender.bot.Send(message.Chat, responseMessage)
if _, err = sender.bot.Send(message.Chat, responseMessage); err != nil {
return removeTokenFromError(err, sender.bot)
}
}
return removeTokenFromError(err, sender.bot)
return nil
}

func (sender *Sender) getResponseMessage(message *telebot.Message) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion senders/telegram/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func removeTokenFromError(err error, bot *telebot.Bot) error {
if bot != nil {
url = bot.URL
}
if strings.Contains(err.Error(), url) {
if err != nil && strings.Contains(err.Error(), url) {
return errors.New(moira.ReplaceSubstring(err.Error(), "/bot", "/", hidden))
}
return err
Expand Down

0 comments on commit f29ce12

Please sign in to comment.