Browse Source

Add avatar to @tiktok bot

pull/14/head
James Mills 1 month ago
parent
commit
23bbc78946
Signed by: prologic GPG Key ID: AC4C014F1440EBD6
  1. 14
      jobs.go

14
jobs.go

@ -138,7 +138,7 @@ func NewTikTokJob(conf *Config) cron.Job {
name := "tiktok"
url := fmt.Sprintf("@<%s %s>", name, URLForFeed(conf, name))
conf.Feeds[name] = &Feed{
feed := &Feed{
Name: name,
Description: fmt.Sprintf(
"I am @%s an automated feed that twts every 30m with the current time (UTC)",
@ -146,6 +146,18 @@ func NewTikTokJob(conf *Config) cron.Job {
),
}
fn := filepath.Join(conf.DataDir, fmt.Sprintf("%s.png", feed.Name))
if Exists(fn) && feed.Avatar == "" {
feed.Avatar = fmt.Sprintf("%s/%s/avatar.png", conf.BaseURL, feed.Name)
if avatarHash, err := FastHashFile(fn); err == nil {
feed.Avatar += "#" + avatarHash
} else {
log.WithError(err).Warnf("error updating avatar hash for %s", feed.Name)
}
}
conf.Feeds[name] = feed
return &TikTokJob{
conf: conf,
name: name,

Loading…
Cancel
Save