refactor: clean code

This commit is contained in:
Fu Diwei
2025-04-24 23:14:17 +08:00
parent 794695c313
commit a117fd7d93
19 changed files with 175 additions and 107 deletions

View File

@@ -10,8 +10,8 @@ import (
)
type NotifierConfig struct {
// Telegram API Token。
ApiToken string `json:"apiToken"`
// Telegram Bot API Token。
BotToken string `json:"botToken"`
// Telegram Chat ID。
ChatId int64 `json:"chatId"`
}
@@ -43,7 +43,7 @@ func (n *NotifierProvider) WithLogger(logger *slog.Logger) notifier.Notifier {
}
func (n *NotifierProvider) Notify(ctx context.Context, subject string, message string) (res *notifier.NotifyResult, err error) {
srv, err := telegram.New(n.config.ApiToken)
srv, err := telegram.New(n.config.BotToken)
if err != nil {
return nil, err
}

View File

@@ -45,7 +45,7 @@ func TestNotify(t *testing.T) {
}, "\n"))
notifier, err := provider.NewNotifier(&provider.NotifierConfig{
ApiToken: fApiToken,
BotToken: fApiToken,
ChatId: fChartId,
})
if err != nil {