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

Commit

Permalink
feat(task): add subscribe disable telegraph support
Browse files Browse the repository at this point in the history
  • Loading branch information
indes committed Feb 2, 2019
1 parent b19eb18 commit a00570c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bot/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,29 @@ func BroadNews(source *model.Source, subs []model.Subscribe, contents []model.Co
for _, content := range contents {
for _, sub := range subs {
var disableNotification bool
var telegraphURL string
if sub.EnableNotification == 1 {
disableNotification = false
} else {
disableNotification = true
}

if sub.EnableTelegraph == 1 {
telegraphURL = content.TelegraphUrl

} else {
telegraphURL = ""

}
u.ID = int(sub.UserID)

message := `
*%s*
%s
[原文](%s)
%s
`
message = fmt.Sprintf(message, source.Title, content.Title, content.RawLink, content.TelegraphUrl)

message = fmt.Sprintf(message, source.Title, content.Title, content.RawLink, telegraphURL)
_, err := B.Send(&u, message, &telebot.SendOptions{
ParseMode: telebot.ModeMarkdown,
DisableNotification: disableNotification,
Expand Down

0 comments on commit a00570c

Please sign in to comment.