Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix misuse of sub.EnableTelegraph
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt committed Dec 16, 2019
1 parent f503cea commit ee354e3
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions bot/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,28 @@ func SendError(c *tb.Chat) {
func BroadNews(source *model.Source, subs []model.Subscribe, contents []model.Content) {

log.Printf("Source Title: <%s> Subscriber: %d New Contents: %d", source.Title, len(subs), len(contents))
var buf []byte
wb := bytes.NewBuffer(buf)
for _, content := range contents {

previewText := trimDescription(content.Description, config.PreviewText)
tpldata := &config.TplData{
SourceTitle: source.Title,
ContentTitle: content.Title,
RawLink: content.RawLink,
PreviewText: previewText,
TelegraphURL: content.TelegraphUrl,
EnableTelegraph: config.EnableTelegraph,
}

var buf []byte
wb := bytes.NewBuffer(buf)
if err := config.MessageTpl.Execute(wb, tpldata); err != nil {
log.Println(err)
return
}

for _, sub := range subs {
tpldata := &config.TplData{
SourceTitle: source.Title,
ContentTitle: content.Title,
RawLink: content.RawLink,
PreviewText: previewText,
TelegraphURL: content.TelegraphUrl,
EnableTelegraph: sub.EnableTelegraph == 1 && content.TelegraphUrl != "",
}

wb.Reset()
if err := config.MessageTpl.Execute(wb, tpldata); err != nil {
log.Println(err)
return
}

u := &tb.User{
ID: int(sub.UserID),
}
Expand Down

0 comments on commit ee354e3

Please sign in to comment.