Skip to content

Commit

Permalink
style: Fix indentation and add logging in Telegram notification
Browse files Browse the repository at this point in the history
  • Loading branch information
revelaction committed Sep 28, 2024
1 parent ced7c79 commit 9de2a23
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/ical-git/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func initialize(path string) (context.Context, context.CancelFunc, *schedule.Sch
}

for _, image := range conf.Images {
slog.Info("📝 Config: 📸", "name", image.Name, "type", image.Type, "value", image.TruncatedValue())
slog.Info("📝 Config: 📸", "name", image.Name, "type", image.Type, "value", image.TruncatedValue())
}

// Create context to cance the tick goroutine on SIGHUP
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Config struct {

Alarms []alarm.Alarm

Images []Image
Images []Image

FetcherGit FetcherGit `toml:"fetcher_git"`

Expand Down Expand Up @@ -142,7 +142,7 @@ func Load(data []byte) (Config, error) {
conf.Images = make([]Image, 0)
}

// We support base64 and external URL
// We support base64 and external URL
for i, im := range conf.Images {
// check if Value is base64
data, err := decodeBase64URI(im.Value)
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ images = [
t.Fatalf("Expected value for name 'birthday.jpg' to be '%s', but got '%s'", expectedValue, im.Value)
}

if im.Type != expectedType{
if im.Type != expectedType {
t.Fatalf("Expected type for name 'birthday.jpg' to be '%s', but got '%s'", expectedValue, im.Type)
}

Expand Down
5 changes: 4 additions & 1 deletion notify/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/revelaction/ical-git/config"
"github.com/revelaction/ical-git/notify"
"html/template"
"log/slog"
"time"
)

Expand Down Expand Up @@ -55,11 +56,13 @@ func (t *Telegram) Notify(n notify.Notification) error {
msg = text
}

_, err = t.bot.Send(msg)
m, err := t.bot.Send(msg)
if err != nil {
return err
}

slog.Info("Image File Id", "id", m.Photo[len(m.Photo)-1].FileID)

return nil
}

Expand Down

0 comments on commit 9de2a23

Please sign in to comment.