add pre group one bot setting

This commit is contained in:
Jay
2019-06-25 17:02:03 +08:00
parent c605b2d9e9
commit 8c432b9b68
13 changed files with 185 additions and 56 deletions
+7 -1
View File
@@ -2,6 +2,7 @@ package background
import (
"fmt"
"log"
"net/http"
"regexp"
"sort"
@@ -138,6 +139,11 @@ func getPageHTML(page *model.FacebookPage) {
for _, v := range page.Groups {
if v.Notify {
bot, err := v.GetBot()
if err != nil || bot == nil {
log.Println("get group binding bot fail :: ", err)
continue
}
tmpl := v.Tmpl
if len(tmpl) > 0 {
tmpl = strings.Replace(tmpl, "{link}", lastData.Link, -1)
@@ -148,7 +154,7 @@ func getPageHTML(page *model.FacebookPage) {
msg := line.TextMessage{
Text: tmpl,
}
line.PushMessage(v.ID, msg)
line.PushMessage(bot.AccessToken, v.ID, msg)
}
}
}
+7 -1
View File
@@ -2,6 +2,7 @@ package background
import (
"fmt"
"log"
"strings"
"time"
@@ -61,6 +62,11 @@ func checkStream(ch *model.TwitchChannel, info *twitch.StreamInfo) {
link := fmt.Sprintf("https://twitch.tv/%s", ch.Name)
for _, v := range ch.Groups {
if v.Notify {
bot, err := v.GetBot()
if err != nil || bot == nil {
log.Println("get group binding bot fail :: ", err)
continue
}
tmpl := v.Tmpl
if len(tmpl) > 0 {
tmpl = strings.Replace(tmpl, "{txt}", info.Title, -1)
@@ -71,7 +77,7 @@ func checkStream(ch *model.TwitchChannel, info *twitch.StreamInfo) {
msg := line.TextMessage{
Text: tmpl,
}
line.PushMessage(v.ID, msg)
line.PushMessage(bot.AccessToken, v.ID, msg)
}
}
}