|
|
@@ -95,13 +95,7 @@ func (this *SubscribeSender) SendHangupSubscribe(deviceId string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- msg := make(map[string]map[string]string)
|
|
|
- msg["thing1"] = make(map[string]string)
|
|
|
- msg["thing1"]["value"] = "挂机奖励时长已满"
|
|
|
- msg["thing3"] = make(map[string]string)
|
|
|
- msg["thing3"]["value"] = "您的挂机奖励时长已满,请打开游戏领取"
|
|
|
-
|
|
|
- this.sendWechatSubscribe(subscribeOne.OpenId, "hangup", msg)
|
|
|
+ this.sendWechatSubscribe(subscribeOne.OpenId, "hangup")
|
|
|
}
|
|
|
|
|
|
func (this *SubscribeSender) SendAutoFightSubscribe(deviceId string) {
|
|
|
@@ -112,53 +106,38 @@ func (this *SubscribeSender) SendAutoFightSubscribe(deviceId string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- msg := make(map[string]map[string]string)
|
|
|
- msg["thing2"] = make(map[string]string)
|
|
|
- msg["thing2"]["value"] = "离线闯关结束,请收取您的离线闯关奖励。"
|
|
|
- msg["thing1"] = make(map[string]string)
|
|
|
- msg["thing1"]["value"] = "离线闯关提醒"
|
|
|
-
|
|
|
- this.sendWechatSubscribe(subscribeOne.OpenId, "autofight", msg)
|
|
|
+ this.sendWechatSubscribe(subscribeOne.OpenId, "autofight")
|
|
|
}
|
|
|
|
|
|
func (this *SubscribeSender) SendGuildGameSubscribe(openIds []string) {
|
|
|
- msg := make(map[string]map[string]string)
|
|
|
- msg["thing2"] = make(map[string]string)
|
|
|
- msg["thing2"]["value"] = "门派攻防战即将开始,为门派荣誉而战吧。"
|
|
|
- msg["thing4"] = make(map[string]string)
|
|
|
- msg["thing4"]["value"] = "门派攻防战"
|
|
|
-
|
|
|
for _, openId := range openIds {
|
|
|
- this.sendWechatSubscribe(openId, "guildgame", msg)
|
|
|
+ this.sendWechatSubscribe(openId, "guildgame")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (this *SubscribeSender) SendAllianceSubscribe(openIds []string) {
|
|
|
- msg := make(map[string]map[string]string)
|
|
|
- msg["thing2"] = make(map[string]string)
|
|
|
- msg["thing2"]["value"] = "三界战场即将开始,争夺人间道统。"
|
|
|
- msg["thing4"] = make(map[string]string)
|
|
|
- msg["thing4"]["value"] = "三界争峰"
|
|
|
-
|
|
|
for _, openId := range openIds {
|
|
|
- this.sendWechatSubscribe(openId, "alliance", msg)
|
|
|
+ this.sendWechatSubscribe(openId, "alliance")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (this *SubscribeSender) SendWarHeavensSubscribe(openIds []string) {
|
|
|
- msg := make(map[string]map[string]string)
|
|
|
- msg["thing2"] = make(map[string]string)
|
|
|
- msg["thing2"]["value"] = "独战诸仙即将开始!"
|
|
|
- msg["thing4"] = make(map[string]string)
|
|
|
- msg["thing4"]["value"] = "决战诸仙"
|
|
|
-
|
|
|
for _, openId := range openIds {
|
|
|
- this.sendWechatSubscribe(openId, "warheavens", msg)
|
|
|
+ this.sendWechatSubscribe(openId, "warheavens")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (this *SubscribeSender) sendWechatSubscribe(openId string, module string, msg map[string]map[string]string) {
|
|
|
- templateID := subscribeTemplateID(module)
|
|
|
+func (this *SubscribeSender) sendWechatSubscribe(openId string, module string) {
|
|
|
+ configured, ok := subscribePushMessage(module)
|
|
|
+ if !ok {
|
|
|
+ logger.Info("[订阅推送] 模块未启用或配置缺失, module=%s", module)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ msg := map[string]map[string]string{
|
|
|
+ "thing1": {"value": configured.Title},
|
|
|
+ "thing2": {"value": configured.Description},
|
|
|
+ }
|
|
|
+ templateID := subscribeTemplateID()
|
|
|
if templateID == "" {
|
|
|
logger.Info("[push] subscribe template id not configured, channel=%s, module=%s", os.Getenv("CHANNEL"), module)
|
|
|
return
|
|
|
@@ -167,7 +146,7 @@ func (this *SubscribeSender) sendWechatSubscribe(openId string, module string, m
|
|
|
this.wxHelper.SendWechatSubscribe(openId, templateID, msg)
|
|
|
}
|
|
|
|
|
|
-func subscribeTemplateID(module string) string {
|
|
|
+func subscribeTemplateID() string {
|
|
|
templates, err := loadSubscribeTemplateConfig()
|
|
|
if err != nil {
|
|
|
logger.Info("[push] load subscribe template config failed: %v", err)
|
|
|
@@ -175,14 +154,13 @@ func subscribeTemplateID(module string) string {
|
|
|
}
|
|
|
|
|
|
channel := strings.ToLower(strings.TrimSpace(os.Getenv("CHANNEL")))
|
|
|
- moduleKey := strings.ToLower(strings.TrimSpace(module))
|
|
|
if channel != "" {
|
|
|
- if templateID := strings.TrimSpace(templates[channel][moduleKey]); templateID != "" {
|
|
|
+ if templateID := strings.TrimSpace(templates[channel]["general"]); templateID != "" {
|
|
|
return templateID
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return strings.TrimSpace(templates["default"][moduleKey])
|
|
|
+ return strings.TrimSpace(templates["default"]["general"])
|
|
|
}
|
|
|
|
|
|
func loadSubscribeTemplateConfig() (map[string]map[string]string, error) {
|