test new shop layout

This commit is contained in:
shoopea 2020-02-14 12:50:22 +08:00
parent b1689e7c15
commit cb944c8a36

28
job.go
View File

@ -2255,35 +2255,43 @@ func jobShops(j Job) {
out = fmt.Sprintf("%s - %s\n", out, guru) out = fmt.Sprintf("%s - %s\n", out, guru)
} }
} }
var (
status string
username string
eta string
)
if cwm.Open { if cwm.Open {
out = fmt.Sprintf("%s ✅", out) status = ``
} else { } else {
out = fmt.Sprintf("%s ⛔", out) status = ``
} }
c := getObjCastle(cwm.CastleID64) c := getObjCastle(cwm.CastleID64)
out = fmt.Sprintf("%s%s", out, c.Logo)
for _, s := range cfg.Bot.Shops { for _, s := range cfg.Bot.Shops {
if s.Link == cwm.Link { if s.Link == cwm.Link {
out = fmt.Sprintf("%s@%s", out, s.Username) username = s.Username
break break
} }
} }
out = fmt.Sprintf("%s [%4d💧]", out, cwm.Mana)
out = fmt.Sprintf("%s <a href=\"https://t.me/share/url?url=/ws_%s\">%s</a>", out, cwm.Link, cwm.User)
eta = ``
if cwm.Mana < cwm.ManaTotal { if cwm.Mana < cwm.ManaTotal {
out = fmt.Sprintf("%s ", out)
t := (cwm.ManaTotal - cwm.Mana) / ((cwm.ManaTotal / 250) + 1) t := (cwm.ManaTotal - cwm.Mana) / ((cwm.ManaTotal / 250) + 1)
d := time.Duration(t) * time.Minute d := time.Duration(t) * time.Minute
if d.Hours() > 1 { if d.Hours() > 1 {
out = fmt.Sprintf("%s%.0fh", out, d.Hours()) eta = fmt.Sprintf("%s%.0fh", eta, d.Hours())
} }
d = d - d.Truncate(1*time.Hour) d = d - d.Truncate(1*time.Hour)
if d.Minutes() > 0 { if d.Minutes() > 0 {
out = fmt.Sprintf("%s%.0fm", out, d.Minutes()) eta = fmt.Sprintf("%s%.0fm", eta, d.Minutes())
} }
} }
out = fmt.Sprintf("%s\n", out) if eta == `` {
eta = "full"
}
out = fmt.Sprintf("%s %s%s<a href=\"https://t.me/share/url?url=/ws_%s\">#%d</a> [%d💧 %s] @%s\n", out, status, c.Logo, cwm.Link, cwm.ShopNumber, cwm.Mana, eta, username)
} }
} }