Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: hide credentials in tg sender #1107

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions senders/telegram/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ func (sender *Sender) Init(senderSettings interface{}, logger moira.Logger, loca

sender.logger = logger
sender.bot, err = telebot.NewBot(telebot.Settings{
Token: cfg.APIToken,
Poller: &telebot.LongPoller{Timeout: pollerTimeout},
Token: cfg.APIToken,
Poller: &telebot.LongPoller{Timeout: pollerTimeout},
OnError: sender.customOnErrorFunc,
})
if err != nil {
return sender.removeTokenFromError(err)
Expand Down Expand Up @@ -123,3 +124,11 @@ func (sender *Sender) runTelebot(contactType string) {
func telegramLockKey(contactType string) string {
return telegramLockPrefix + contactType
}

func (sender *Sender) customOnErrorFunc(err error, _ telebot.Context) {
err = sender.removeTokenFromError(err)

sender.logger.Error().
almostinf marked this conversation as resolved.
Show resolved Hide resolved
Error(err).
Msg("Error inside telebot")
}
Loading