update job shops

This commit is contained in:
shoopea 2020-02-07 11:53:55 +08:00
parent a80eb93dc5
commit 3a637bc684
2 changed files with 34 additions and 4 deletions

22
job.go
View File

@ -2206,9 +2206,29 @@ func jobShops(j Job) {
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobShops : Unmarshal payload")
out := fmt.Sprintf("Shop summary:\n")
for _, m := range p.Msgs {
rule, err := getMsgParsingRule(m)
logOnError(err, "jobShopsSlave : getMsgParsingRule")
if rule.MsgTypeID64 == cacheObjSubType[`msg_shop_main_ack`] {
cwm, err := parseSubTypeMessageShopMainAck(m, rule.re)
logOnError(err, "jobShops : parseSubTypeMessageShopMainAck")
if cwm.Open {
out = fmt.Sprintf("%s ✔️", out)
} else {
out = fmt.Sprintf("%s ❌", out)
}
c := getObjCastle(cwm.CastleID64)
out = fmt.Sprintf("%s%s", out, c.Logo)
out = fmt.Sprintf("%s<a href=\"https://t.me/share/url?url=\/ws_%s\">%s</a>", out, cwm.Link, cwm.User)
out = fmt.Sprintf("%s [%d/%d]\n", out, cwm.Mana, cwm.ManaTotal)
}
clientDelTGMsg(m.TGUserID64, m.ID64, m.ChatID64)
}
c := TGCommand{
Type: commandReplyMsg,
Text: "Done",
Text: out,
FromMsgID64: p.MsgID64,
FromChatID64: p.ChatID64,
ParseMode: cmdParseModeHTML,

16
obj.go
View File

@ -486,8 +486,19 @@ func addObjCastle(logo string, name string) (int64, error) {
return objId, nil
}
func getObjCastleID(s string) int64 {
if v, ok := cacheObjCastle.Load(s); ok {
func getObjCastle(i interface{}) ChatWarsCastle {
if v, ok := cacheObjCastle.Load(i); ok {
c := v.(ChatWarsCastle)
return c
} else {
v, _ := cacheObjCastle.Load(``)
c := v.(ChatWarsCastle)
return c
}
}
func getObjCastleID(i interface{}) int64 {
if v, ok := cacheObjCastle.Load(i); ok {
c := v.(ChatWarsCastle)
return c.ObjID64
} else {
@ -495,7 +506,6 @@ func getObjCastleID(s string) int64 {
c := v.(ChatWarsCastle)
return c.ObjID64
}
}
func loadObjCastle() error {