test new shop layout

This commit is contained in:
shoopea 2020-02-11 10:00:00 +08:00
parent 2abb957a55
commit e9042797d9
4 changed files with 15 additions and 7 deletions

4
bot.go
View File

@ -804,9 +804,9 @@ func botShops(m *ChatWarsMessage) {
Slaves: int64(len(clts)), Slaves: int64(len(clts)),
Shops: make([]string, 0), Shops: make([]string, 0),
} }
for j, link := range cfg.Bot.Shops { for j, s := range cfg.Bot.Shops {
if (j / len(clts)) == i { if (j / len(clts)) == i {
j2.Shops = append(j2.Shops, link) j2.Shops = append(j2.Shops, s.Link)
} }
} }
b, err = json.Marshal(j2) b, err = json.Marshal(j2)

View File

@ -31,7 +31,6 @@
"max_qty": 10000 "max_qty": 10000
} }
], ],
"shops": [ "abcd", "shops": [{"username": "user", "link": "abcd" }]
"0123" ]
} }
} }

5
def.go
View File

@ -45,7 +45,10 @@ type Config struct {
Min int64 `json:"min_qty"` Min int64 `json:"min_qty"`
Max int64 `json:"max_qty"` Max int64 `json:"max_qty"`
} `json:"vault_limit"` } `json:"vault_limit"`
Shops []string `json:"shops"` Shops []struct {
Username string `json:"username"`
Link string `json:"link"`
} `json:"shops"`
} `json:"bot"` } `json:"bot"`
} }

10
job.go
View File

@ -2258,8 +2258,14 @@ func jobShops(j Job) {
} }
c := getObjCastle(cwm.CastleID64) c := getObjCastle(cwm.CastleID64)
out = fmt.Sprintf("%s%s", out, c.Logo) 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) for _, s := range cfg.Bot.Shops {
out = fmt.Sprintf("%s [%d : %d]", out, cwm.Mana, cwm.ManaTotal) if s.Link == cwm.Link {
out = fmt.Sprintf("%s@%s", out, s.Username)
}
break
}
out = fmt.Sprintf("%s [%d💧]", out, cwm.Mana)
out = fmt.Sprintf("%s Visit <a href=\"https://t.me/share/url?url=/ws_%s\">%s</a>", out, cwm.Link, cwm.User)
if cwm.Mana < cwm.ManaTotal { if cwm.Mana < cwm.ManaTotal {
d := time.Duration(((cwm.ManaTotal-cwm.Mana)*60)/((cwm.ManaTotal/250)+1)) * time.Second d := time.Duration(((cwm.ManaTotal-cwm.Mana)*60)/((cwm.ManaTotal/250)+1)) * time.Second