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
+13 -2
View File
@@ -2,6 +2,7 @@ package private
import (
"fmt"
"log"
"strings"
"git.trj.tw/golang/mtfosbot/model"
@@ -107,6 +108,11 @@ func UpdateFacebookPagePost(c *context.Context) {
for _, g := range page.Groups {
if g.Notify {
bot, err := g.GetBot()
if err != nil || bot == nil {
log.Println("get group binding bot fail ::: ", err)
continue
}
tmpl := g.Tmpl
if len(tmpl) > 0 {
tmpl = strings.Replace(tmpl, "{link}", v.Link, -1)
@@ -117,7 +123,7 @@ func UpdateFacebookPagePost(c *context.Context) {
msg := line.TextMessage{
Text: tmpl,
}
line.PushMessage(g.ID, msg)
line.PushMessage(bot.AccessToken, g.ID, msg)
}
}
}
@@ -169,6 +175,11 @@ func UpdateInstagramPost(c *context.Context) {
for _, g := range ig.Groups {
if g.Notify {
bot, err := g.GetBot()
if err != nil || bot == nil {
log.Println("get group binding bot fail :: ", err)
continue
}
tmpl := g.Tmpl
if len(tmpl) > 0 {
tmpl = strings.Replace(tmpl, "{link}", v.Link, -1)
@@ -178,7 +189,7 @@ func UpdateInstagramPost(c *context.Context) {
}
msg := line.TextMessage{Text: tmpl}
line.PushMessage(g.ID, msg)
line.PushMessage(bot.AccessToken, g.ID, msg)
}
}
}