Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
orvice committed Apr 24, 2024
1 parent 3992904 commit eca659a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package notify

import (
"context"
"gopkg.in/telegram-bot-api.v4"
"log/slog"

tgbotapi "gopkg.in/telegram-bot-api.v4"
)

var notifiers []Notifier
Expand All @@ -24,7 +26,6 @@ func NewTelegramNotifier(token string, chatID int64) (*TelegramNotifier, error)
if err != nil {
return nil, err
}

return &TelegramNotifier{
bot: bot,
token: token,
Expand All @@ -34,8 +35,13 @@ func NewTelegramNotifier(token string, chatID int64) (*TelegramNotifier, error)

func (t *TelegramNotifier) Send(ctx context.Context, s string) error {
msg := tgbotapi.NewMessage(t.chatID, s)
_, err := t.bot.Send(msg)
return err
resp, err := t.bot.Send(msg)
if err != nil {
slog.Error("send message error", "error", err.Error())
return err
}
slog.Info("send message success", "resp", resp)
return nil
}

func Init() {
Expand Down

0 comments on commit eca659a

Please sign in to comment.