insert min/max
This commit is contained in:
parent
a749436cac
commit
27bd1ab491
2
cron.go
2
cron.go
@ -141,7 +141,7 @@ func cronSaveClients() {
|
||||
|
||||
func cronCheckVaultLimit() {
|
||||
clt, err := getLockedRandomClient()
|
||||
logOnError(err, "cronGetHammerTime : getLockedRandomClient")
|
||||
logOnError(err, "cronCheckVaultLimit : getLockedRandomClient")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
38
job.go
38
job.go
@ -2379,9 +2379,10 @@ func jobCraftAll(j Job) {
|
||||
|
||||
func jobCheckVaultLimit(j Job) {
|
||||
var (
|
||||
p JobPayloadCheckVaultLimit
|
||||
p2 JobPayloadGetVault
|
||||
b []byte
|
||||
p JobPayloadCheckVaultLimit
|
||||
p2 JobPayloadGetVault
|
||||
b []byte
|
||||
out string
|
||||
)
|
||||
|
||||
err := setJobStart(j.ID64)
|
||||
@ -2423,6 +2424,37 @@ func jobCheckVaultLimit(j Job) {
|
||||
err = json.Unmarshal(b, &p2)
|
||||
logOnError(err, "jobCheckVaultLimit : Unmarshal(p2)")
|
||||
|
||||
var empty bool = true
|
||||
out = "Stock summary :\n"
|
||||
for _, l := range cfg.Bot.VaultLimit {
|
||||
id := getObjItemID(l.Item, ``)
|
||||
obj, err := getObjItem(id)
|
||||
if err == nil {
|
||||
for _, i := range p2.Vault {
|
||||
if id == i.ItemID64 {
|
||||
if i.Quantity > l.Max {
|
||||
empty = false
|
||||
out = fmt.Sprintf("%s- [%s] %d above max\n", out, obj.Names[0], i.Quantity-l.Max)
|
||||
} else if i.Quantity < l.Min {
|
||||
empty = false
|
||||
out = fmt.Sprintf("%s- [%s] %d below min\n", out, obj.Names[0], l.Min-i.Quantity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if empty {
|
||||
out = fmt.Sprintf("%s- all good !", out)
|
||||
}
|
||||
|
||||
c := TGCommand{
|
||||
Type: commandSendMsg,
|
||||
Text: out,
|
||||
ToChatID64: p.ChatID64,
|
||||
ParseMode: cmdParseModeHTML,
|
||||
}
|
||||
TGCmdQueue <- c
|
||||
|
||||
err = setJobDone(j.ID64)
|
||||
logOnError(err, "jobCheckVaultLimit : setJobDone")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user