update set def
This commit is contained in:
parent
0d6cce136d
commit
0fb27e8309
20
cron.go
20
cron.go
@ -10,7 +10,8 @@ import (
|
||||
|
||||
func startCron() *cron.Cron {
|
||||
c := cron.New(cron.WithLocation(time.UTC))
|
||||
c.AddFunc("15 0,8,16 * * *", cronSendWarReport)
|
||||
c.AddFunc("15 7,15,23 * * *", cronSendWarReport)
|
||||
c.AddFunc("58 6,14,22 * * *", cronSetDef)
|
||||
c.Start()
|
||||
return c
|
||||
}
|
||||
@ -30,7 +31,22 @@ func cronSendWarReport() {
|
||||
b, _ := json.Marshal(&p)
|
||||
err := createJobCallback(objSubTypeJobFwdMsg, c.TGUserID64, objSubTypeMessageReportAck, b, 1*time.Minute)
|
||||
logOnError(err, "cronSendWarReport : createJobCallback")
|
||||
clientSendCWMsg(c.TGUserID64, `/report`)
|
||||
clientSendCWMsgDelay(c.TGUserID64, `/report`, 0)
|
||||
}
|
||||
}
|
||||
muxClients.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
func cronSetDef() {
|
||||
muxClients.RLock()
|
||||
for _, c := range clients {
|
||||
if c.Active {
|
||||
p := JobPayloadSetDef{}
|
||||
b, _ := json.Marshal(&p)
|
||||
err := createJobCallback(objSubTypeJobSetDef, c.TGUserID64, objSubTypeMessageMeAck, b, 1*time.Minute)
|
||||
logOnError(err, "cronSetDef : createJobCallback")
|
||||
clientSendCWMsgDelay(c.TGUserID64, `🏅Me`, 0)
|
||||
}
|
||||
}
|
||||
muxClients.RUnlock()
|
||||
|
4
def.go
4
def.go
@ -290,6 +290,9 @@ type Job struct {
|
||||
Payload []byte
|
||||
}
|
||||
|
||||
type JobPayloadSetDef struct {
|
||||
}
|
||||
|
||||
type JobPayloadFwdMsg struct {
|
||||
ChatID64 int64 `json:"chat_id"`
|
||||
}
|
||||
@ -535,6 +538,7 @@ const (
|
||||
objSubTypeJobVaultUserStatus = 615
|
||||
objSubTypeJobVaultItemStatus = 616
|
||||
objSubTypeJobFwdMsg = 617
|
||||
objSubTypeJobSetDef = 618
|
||||
objSubTypeItemResource = 701
|
||||
objSubTypeItemAlch = 702
|
||||
objSubTypeItemMisc = 703
|
||||
|
17
job.go
17
job.go
@ -1168,3 +1168,20 @@ func jobFwdMsg(j Job) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func jobSetDef(j Job) {
|
||||
var p JobPayloadSetDef
|
||||
err := setJobStart(j.ID64)
|
||||
logOnError(err, "jobSetDef : setJobStart")
|
||||
|
||||
err = json.Unmarshal(j.Payload, &p)
|
||||
logOnError(err, "jobSetDef : Unmarshal payload")
|
||||
|
||||
cwm, err := getObjMsg(j.Trigger)
|
||||
logOnError(err, "jobSetDef : getObjMsg msg")
|
||||
|
||||
err = setJobDone(j.ID64)
|
||||
logOnError(err, "jobSetDef : setJobDone")
|
||||
|
||||
return
|
||||
}
|
||||
|
1
sql.go
1
sql.go
@ -567,6 +567,7 @@ func initDB() {
|
||||
,(` + strconv.Itoa(objSubTypeJobVaultUserStatus) + `, "job_vault_user_status", "Vault User Status job", ` + strconv.Itoa(objTypeJob) + `)
|
||||
,(` + strconv.Itoa(objSubTypeJobVaultItemStatus) + `, "job_vault_item_status", "Vault Item Status job", ` + strconv.Itoa(objTypeJob) + `)
|
||||
,(` + strconv.Itoa(objSubTypeJobFwdMsg) + `, "job_fwd_msg", "Forward Message job", ` + strconv.Itoa(objTypeJob) + `)
|
||||
,(` + strconv.Itoa(objSubTypeJobSetDef) + `, "job_set_def", "Set Defense job", ` + strconv.Itoa(objTypeJob) + `)
|
||||
,(` + strconv.Itoa(objSubTypeItemResource) + `, "item_res", "Time", ` + strconv.Itoa(objTypeItem) + `)
|
||||
,(` + strconv.Itoa(objSubTypeItemAlch) + `, "item_alch", "Time", ` + strconv.Itoa(objTypeItem) + `)
|
||||
,(` + strconv.Itoa(objSubTypeItemMisc) + `, "item_misc", "Time", ` + strconv.Itoa(objTypeItem) + `)
|
||||
|
@ -577,6 +577,8 @@ func JobWorker(id int, jobs <-chan Job) {
|
||||
jobVaultItemStatus(j)
|
||||
case objSubTypeJobFwdMsg:
|
||||
jobFwdMsg(j)
|
||||
case objSubTypeJobSetDef:
|
||||
jobSetDef(j)
|
||||
default:
|
||||
log.Printf("jobWorker["+strconv.Itoa(id)+"] : No handler for job type #%d.\n", j.JobTypeID)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user