This commit is contained in:
shoopea 2020-01-02 20:04:12 +08:00
parent c5e26e5849
commit 444eb64f2a
7 changed files with 211 additions and 210 deletions

28
bot.go
View File

@ -293,8 +293,8 @@ func botMsgRescan(m *tb.Message) {
} }
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
log.Printf("botMsgRescan : json : %s\n", string(b)) log.Printf("botMsgRescan : json : %s\n", string(b))
_, err := createJob(objSubTypeJobRescanMsg, objJobPriorityRescanMsg, int64(m.Sender.ID), 0, time.Now().UTC(), b) _, err := createJob(cacheObjSubType[`job_rescan_msg`], objJobPriorityRescanMsg, int64(m.Sender.ID), 0, time.Now().UTC(), b)
logOnError(err, "botMsgRescan : createJob(objSubTypeJobRescanMsg)") logOnError(err, "botMsgRescan : createJob(cacheObjSubType[`job_rescan_msg`])")
if err != nil { if err != nil {
c := TGCommand{ c := TGCommand{
Type: commandReplyMsg, Type: commandReplyMsg,
@ -352,8 +352,8 @@ func botMsgRescanAll(m *tb.Message) {
ChatID64: m.Chat.ID, ChatID64: m.Chat.ID,
} }
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
_, err := createJob(objSubTypeJobRescanMsg, objJobPriorityRescanAllMsg, int64(m.Sender.ID), 0, time.Now().UTC(), b) _, err := createJob(cacheObjSubType[`job_rescan_msg`], objJobPriorityRescanAllMsg, int64(m.Sender.ID), 0, time.Now().UTC(), b)
logOnError(err, "botMsgRescan : createJob(objSubTypeJobRescanMsg)") logOnError(err, "botMsgRescan : createJob(cacheObjSubType[`job_rescan_msg`])")
if err != nil { if err != nil {
c := TGCommand{ c := TGCommand{
@ -407,8 +407,8 @@ func botBackupExport(m *tb.Message) {
ChatID64: m.Chat.ID, ChatID64: m.Chat.ID,
} }
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
_, err := createJob(objSubTypeJobBackupExport, objJobPriorityBackup, int64(m.Sender.ID), 0, time.Now().UTC(), b) _, err := createJob(cacheObjSubType[`job_backup_export`], objJobPriorityBackup, int64(m.Sender.ID), 0, time.Now().UTC(), b)
logOnError(err, "botBackupExport : createJob(objSubTypeJobBackupExport)") logOnError(err, "botBackupExport : createJob(cacheObjSubType[`job_backup_export`])")
return return
} }
@ -459,8 +459,8 @@ func botBackupImport(m *tb.Message) {
ChatID64: m.Chat.ID, ChatID64: m.Chat.ID,
} }
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
_, err := createJob(objSubTypeJobBackupImport, objJobPriorityBackup, int64(m.Sender.ID), 0, time.Now().UTC(), b) _, err := createJob(cacheObjSubType[`job_backup_import`], objJobPriorityBackup, int64(m.Sender.ID), 0, time.Now().UTC(), b)
logOnError(err, "botBackupImport : createJob(objSubTypeJobBackupImport)") logOnError(err, "botBackupImport : createJob(cacheObjSubType[`job_backup_import`])")
return return
} }
@ -665,7 +665,7 @@ func botGStock(m *tb.Message) {
} }
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
t := time.Now().UTC().Add(1 * time.Second) t := time.Now().UTC().Add(1 * time.Second)
_, err = createJob(objSubTypeJobGStock, objJobPriority, userID64, 0, t, b) _, err = createJob(cacheObjSubType[`job_gstock`], objJobPriority, userID64, 0, t, b)
if err != nil { if err != nil {
c := TGCommand{ c := TGCommand{
@ -781,7 +781,7 @@ func botVaultItem(m *tb.Message) {
if len(p.ItemListID64) > 0 { if len(p.ItemListID64) > 0 {
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
t := time.Now().UTC() t := time.Now().UTC()
_, err := createJob(objSubTypeJobVaultItemStatus, objJobPriority, int64(m.Sender.ID), 0, t, b) _, err := createJob(cacheObjSubType[`job_vault_item_status`], objJobPriority, int64(m.Sender.ID), 0, t, b)
if err != nil { if err != nil {
c := TGCommand{ c := TGCommand{
Type: commandReplyMsg, Type: commandReplyMsg,
@ -831,7 +831,7 @@ func botVault(m *tb.Message, itemTypeList []int64) {
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
t := time.Now().UTC() t := time.Now().UTC()
_, err := createJob(objSubTypeJobVaultUserStatus, objJobPriority, int64(m.Sender.ID), 0, t, b) _, err := createJob(cacheObjSubType[`job_vault_user_status`], objJobPriority, int64(m.Sender.ID), 0, t, b)
if err != nil { if err != nil {
c := TGCommand{ c := TGCommand{
@ -899,7 +899,7 @@ func botGDepositAll(m *tb.Message) {
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
t := time.Now().UTC() t := time.Now().UTC()
_, err := createJob(objSubTypeJobGDeposit, objJobPriority, int64(m.Chat.ID), 0, t, b) _, err := createJob(cacheObjSubType[`job_gdeposit`], objJobPriority, int64(m.Chat.ID), 0, t, b)
//log.Printf("botGDepositAll : json : %s\n", string(b)) //log.Printf("botGDepositAll : json : %s\n", string(b))
@ -939,7 +939,7 @@ func botGWithdraw(m *tb.Message) {
} }
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
t := time.Now().UTC() t := time.Now().UTC()
_, err := createJob(objSubTypeJobGWithdraw, objJobPriority, int64(m.Chat.ID), 0, t, b) _, err := createJob(cacheObjSubType[`job_gwithdraw`], objJobPriority, int64(m.Chat.ID), 0, t, b)
if err != nil { if err != nil {
c := TGCommand{ c := TGCommand{
Type: commandReplyMsg, Type: commandReplyMsg,
@ -999,7 +999,7 @@ func botTimer(m *tb.Message) {
} }
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
t := time.Now().UTC().Add(d) t := time.Now().UTC().Add(d)
objID64, err := createJob(objSubTypeJobMsgClient, objJobPriority, int64(m.Chat.ID), 0, t, b) objID64, err := createJob(cacheObjSubType[`job_msg_client`], objJobPriority, int64(m.Chat.ID), 0, t, b)
logOnError(err, "botTimer : createJob") logOnError(err, "botTimer : createJob")
if err != nil { if err != nil {
c := TGCommand{ c := TGCommand{

View File

@ -31,7 +31,7 @@ func cronSendWarReport() {
ChatID64: cfg.Bot.Reportchat, ChatID64: cfg.Bot.Reportchat,
} }
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err := createJobCallback(objSubTypeJobFwdMsg, c.TGUserID64, cacheObjSubType[`msg_report_ack`], b, 1*time.Minute) err := createJobCallback(cacheObjSubType[`job_msg_fwd`], c.TGUserID64, cacheObjSubType[`msg_report_ack`], b, 1*time.Minute)
logOnError(err, "cronSendWarReport : createJobCallback") logOnError(err, "cronSendWarReport : createJobCallback")
clientSendCWMsgDelay(c.TGUserID64, `/report`, 0) clientSendCWMsgDelay(c.TGUserID64, `/report`, 0)
} }
@ -46,7 +46,7 @@ func cronSetDef() {
if c.Active { if c.Active {
p := JobPayloadSetDef{} p := JobPayloadSetDef{}
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err := createJobCallback(objSubTypeJobSetDef, c.TGUserID64, cacheObjSubType[`msg_me_ack`], b, 1*time.Minute) err := createJobCallback(cacheObjSubType[`job_set_def`], c.TGUserID64, cacheObjSubType[`msg_me_ack`], b, 1*time.Minute)
logOnError(err, "cronSetDef : createJobCallback") logOnError(err, "cronSetDef : createJobCallback")
clientSendCWMsgDelay(c.TGUserID64, `🏅Me`, 0) clientSendCWMsgDelay(c.TGUserID64, `🏅Me`, 0)
} }
@ -64,7 +64,7 @@ func cronGetHammerTime() {
clt.Mux.Unlock() clt.Mux.Unlock()
p := JobPayloadGetHammerTime{} p := JobPayloadGetHammerTime{}
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGetHammerTime, clt.TGUserID64, cacheObjSubType[`msg_time_ack`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_get_hammer_time`], clt.TGUserID64, cacheObjSubType[`msg_time_ack`], b, 1*time.Minute)
logOnError(err, "cronGetHammerTime : createJobCallback") logOnError(err, "cronGetHammerTime : createJobCallback")
clientSendCWMsgDelay(clt.TGUserID64, `/time`, 0) clientSendCWMsgDelay(clt.TGUserID64, `/time`, 0)
} }

View File

@ -595,7 +595,7 @@
"obj_type": "job" "obj_type": "job"
}, },
{ {
"intl_id": "job_fwd_msg", "intl_id": "job_msg_fwd",
"name": "Forward Message job", "name": "Forward Message job",
"obj_type": "job" "obj_type": "job"
}, },

41
def.go
View File

@ -570,27 +570,28 @@ const (
cacheObjSubType[`msg_pillage_defeat`] = 402 // You tried stopping (done) cacheObjSubType[`msg_pillage_defeat`] = 402 // You tried stopping (done)
cacheObjSubType[`msg_level_up_req`] = 403 // /level_up cacheObjSubType[`msg_level_up_req`] = 403 // /level_up
cacheObjSubType[`msg_level_up_ack`] = 404 cacheObjSubType[`msg_level_up_ack`] = 404
cacheObjSubType[`job_pillage`] = 601
cacheObjSubType[`job_tribute`] = 602
cacheObjSubType[`job_status`] = 603
cacheObjSubType[`job_gwithdraw`] = 604
cacheObjSubType[`job_gstock`] = 605
cacheObjSubType[`job_rescan_msg`] = 606
cacheObjSubType[`job_set_done`] = 607
cacheObjSubType[`job_msg_client`] = 608
cacheObjSubType[`job_msg_refresh`] = 609
cacheObjSubType[`job_backup_export`] = 610
cacheObjSubType[`job_backup_import`] = 611
cacheObjSubType[`job_gdeposit`] = 612
cacheObjSubType[`job_gdeposit_fwd`] = 613
cacheObjSubType[`job_save_res`] = 614
cacheObjSubType[`job_vault_user_status`] = 615
cacheObjSubType[`job_vault_item_status`] = 616
cacheObjSubType[`job_msg_fwd`] = 617 // rename to objSubTypeJobMsgFwd
cacheObjSubType[`job_set_def`] = 618
cacheObjSubType[`job_msg_del`] = 619
cacheObjSubType[`job_get_hammer_time`] = 620
*/ */
objSubTypeJobPillage = 601
objSubTypeJobTribute = 602
objSubTypeJobStatus = 603
objSubTypeJobGWithdraw = 604
objSubTypeJobGStock = 605
objSubTypeJobRescanMsg = 606
objSubTypeJobSetJobDone = 607
objSubTypeJobMsgClient = 608
objSubTypeJobMsgRefresh = 609
objSubTypeJobBackupExport = 610
objSubTypeJobBackupImport = 611
objSubTypeJobGDeposit = 612
objSubTypeJobGDepositForward = 613
objSubTypeJobSaveRes = 614
objSubTypeJobVaultUserStatus = 615
objSubTypeJobVaultItemStatus = 616
objSubTypeJobFwdMsg = 617 // rename to objSubTypeJobMsgFwd
objSubTypeJobSetDef = 618
objSubTypeJobMsgDel = 619
objSubTypeJobGetHammerTime = 620
objSubTypeItemResource = 701 objSubTypeItemResource = 701
objSubTypeItemAlch = 702 objSubTypeItemAlch = 702
objSubTypeItemMisc = 703 objSubTypeItemMisc = 703

32
job.go
View File

@ -266,8 +266,8 @@ func jobRescan(j Job) {
Text: fmt.Sprintf("%d messages processed in %s.", len(ids), time.Since(start)), Text: fmt.Sprintf("%d messages processed in %s.", len(ids), time.Since(start)),
} }
b, _ := json.Marshal(r) b, _ := json.Marshal(r)
_, err := createJob(objSubTypeJobSetJobDone, objJobPriorityRescanAllMsg, j.UserID64, j.ID64, time.Now().UTC(), b) _, err := createJob(cacheObjSubType[`job_set_done`], objJobPriorityRescanAllMsg, j.UserID64, j.ID64, time.Now().UTC(), b)
logOnError(err, "jobRescan : createJob(objSubTypeJobSetJobDone)") logOnError(err, "jobRescan : createJob(cacheObjSubType[`job_set_done`])")
} else if len(ids) == 1 { } else if len(ids) == 1 {
SQLMsgIdentifyQueue <- ids[0] SQLMsgIdentifyQueue <- ids[0]
@ -717,7 +717,7 @@ func jobGStock(j Job) {
case 0: // send /g_stock_res case 0: // send /g_stock_res
p.Progress = 1 p.Progress = 1
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
jobID64, err := createJob(objSubTypeJobGStock, objJobPriority, j.UserID64, 0, time.Unix(maxUnixTimestamp, 0).UTC(), b) jobID64, err := createJob(cacheObjSubType[`job_gstock`], objJobPriority, j.UserID64, 0, time.Unix(maxUnixTimestamp, 0).UTC(), b)
logOnError(err, "jobGStock : createJob") logOnError(err, "jobGStock : createJob")
setJobCallback(jobID64, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`]) setJobCallback(jobID64, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`])
setJobCallback(jobID64, j.UserID64, cacheObjSubType[`msg_busy`]) setJobCallback(jobID64, j.UserID64, cacheObjSubType[`msg_busy`])
@ -737,7 +737,7 @@ func jobGStock(j Job) {
} }
p.Progress = 2 p.Progress = 2
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gstock`], j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_alch") clientSendCWMsg(j.UserID64, "/g_stock_alch")
} else if rule.MsgTypeID64 == cacheObjSubType[`msg_busy`] || rule.MsgTypeID64 == cacheObjSubType[`msg_battle`] { } else if rule.MsgTypeID64 == cacheObjSubType[`msg_busy`] || rule.MsgTypeID64 == cacheObjSubType[`msg_battle`] {
@ -761,7 +761,7 @@ func jobGStock(j Job) {
} }
p.Progress = 3 p.Progress = 3
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gstock`], j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_misc") clientSendCWMsg(j.UserID64, "/g_stock_misc")
case 3: // send /g_stock_rec case 3: // send /g_stock_rec
@ -775,7 +775,7 @@ func jobGStock(j Job) {
} }
p.Progress = 4 p.Progress = 4
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gstock`], j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_rec") clientSendCWMsg(j.UserID64, "/g_stock_rec")
case 4: // send /g_stock_parts case 4: // send /g_stock_parts
@ -789,7 +789,7 @@ func jobGStock(j Job) {
} }
p.Progress = 5 p.Progress = 5
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gstock`], j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_parts") clientSendCWMsg(j.UserID64, "/g_stock_parts")
case 5: // send /g_stock_other case 5: // send /g_stock_other
@ -803,7 +803,7 @@ func jobGStock(j Job) {
} }
p.Progress = 6 p.Progress = 6
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
err = createJobCallback(objSubTypeJobGStock, j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gstock`], j.UserID64, cacheObjSubType[`msg_gstock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGStock : createJobCallback") logOnError(err, "jobGStock : createJobCallback")
clientSendCWMsg(j.UserID64, "/g_stock_other") clientSendCWMsg(j.UserID64, "/g_stock_other")
case 6: // collate everything and reply case 6: // collate everything and reply
@ -943,7 +943,7 @@ func jobGDeposit(j Job) {
clientSendCWMsgDelay(p.ChatID64, `📦Resources`, delay) clientSendCWMsgDelay(p.ChatID64, `📦Resources`, delay)
p.Status = cacheObjSubType[`msg_stock_ack`] p.Status = cacheObjSubType[`msg_stock_ack`]
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_stock_ack`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gdeposit`], j.UserID64, cacheObjSubType[`msg_stock_ack`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
@ -951,7 +951,7 @@ func jobGDeposit(j Job) {
clientSendCWMsgDelay(p.ChatID64, `Alchemy`, delay) clientSendCWMsgDelay(p.ChatID64, `Alchemy`, delay)
p.Status = 1 // FIXME UPDATE WITH PROPER TYPE p.Status = 1 // FIXME UPDATE WITH PROPER TYPE
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_orderbook_acl`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gdeposit`], j.UserID64, cacheObjSubType[`msg_orderbook_acl`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
@ -959,7 +959,7 @@ func jobGDeposit(j Job) {
clientSendCWMsgDelay(p.ChatID64, `🗃Misc`, delay) clientSendCWMsgDelay(p.ChatID64, `🗃Misc`, delay)
p.Status = 1 // FIXME UPDATE WITH PROPER TYPE p.Status = 1 // FIXME UPDATE WITH PROPER TYPE
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_orderbook_acl`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gdeposit`], j.UserID64, cacheObjSubType[`msg_orderbook_acl`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
@ -967,7 +967,7 @@ func jobGDeposit(j Job) {
clientSendCWMsgDelay(p.ChatID64, `⚒Crafting`, delay) clientSendCWMsgDelay(p.ChatID64, `⚒Crafting`, delay)
p.Status = cacheObjSubType[`msg_stock_any_ack`] p.Status = cacheObjSubType[`msg_stock_any_ack`]
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_stock_any_ack`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gdeposit`], j.UserID64, cacheObjSubType[`msg_stock_any_ack`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
@ -975,7 +975,7 @@ func jobGDeposit(j Job) {
clientSendCWMsgDelay(p.ChatID64, `🏷Equipment`, delay) clientSendCWMsgDelay(p.ChatID64, `🏷Equipment`, delay)
p.Status = 1 // FIXME UPDATE WITH PROPER TYPE p.Status = 1 // FIXME UPDATE WITH PROPER TYPE
b, _ = json.Marshal(&p) b, _ = json.Marshal(&p)
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, cacheObjSubType[`msg_orderbook_acl`], b, 1*time.Minute) err = createJobCallback(cacheObjSubType[`job_gdeposit`], j.UserID64, cacheObjSubType[`msg_orderbook_acl`], b, 1*time.Minute)
logOnError(err, "jobGDeposit : createJobCallback") logOnError(err, "jobGDeposit : createJobCallback")
delay = delay + 2*time.Second delay = delay + 2*time.Second
} }
@ -1002,7 +1002,7 @@ func jobGDeposit(j Job) {
Quantity: cwm.Stock[stockIdx].Quantity, Quantity: cwm.Stock[stockIdx].Quantity,
} }
b2, _ := json.Marshal(p2) b2, _ := json.Marshal(p2)
err = createJobCallback(objSubTypeJobGDepositForward, j.UserID64, cacheObjSubType[`msg_g_deposit_req`], b2, time.Duration(1*time.Minute)) err = createJobCallback(cacheObjSubType[`job_gdeposit_fwd`], j.UserID64, cacheObjSubType[`msg_g_deposit_req`], b2, time.Duration(1*time.Minute))
} }
} }
} }
@ -1024,7 +1024,7 @@ func jobGDeposit(j Job) {
Quantity: cwm.Stock[stockIdx].Quantity, Quantity: cwm.Stock[stockIdx].Quantity,
} }
b2, _ := json.Marshal(p2) b2, _ := json.Marshal(p2)
err = createJobCallback(objSubTypeJobGDepositForward, j.UserID64, cacheObjSubType[`msg_g_deposit_req`], b2, time.Duration(1*time.Minute)) err = createJobCallback(cacheObjSubType[`job_gdeposit_fwd`], j.UserID64, cacheObjSubType[`msg_g_deposit_req`], b2, time.Duration(1*time.Minute))
} }
} }
} }
@ -1283,7 +1283,7 @@ func jobGWithdraw(j Job) {
ChatWarsItems ChatWarsItems
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
t := time.Now().UTC() t := time.Now().UTC()
_, err := createJob(objSubTypeJobGDeposit, objJobPriority, int64(m.Chat.ID), 0, t, b) _, err := createJob(cacheObjSubType[`job_gdeposit`], objJobPriority, int64(m.Chat.ID), 0, t, b)
*/ */
} }

38
sql.go
View File

@ -560,25 +560,25 @@ func initDB() {
,(` + strconv.Itoa(cacheObjSubType[`msg_level_up_req`]) + `, "level_up_req", "Level Up Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_level_up_req`]) + `, "level_up_req", "Level Up Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(cacheObjSubType[`msg_level_up_ack`]) + `, "level_up_ack", "Level Up Ack", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_level_up_ack`]) + `, "level_up_ack", "Level Up Ack", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(cacheObjSubType[`msg_top`]Req) + `, "top_req", "Top Req", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(cacheObjSubType[`msg_top`]Req) + `, "top_req", "Top Req", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeJobPillage) + `, "job_pillage", "Pillage job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_pillage`]) + `, "job_pillage", "Pillage job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobTribute) + `, "job_tribute", "Tribute job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_tribute`]) + `, "job_tribute", "Tribute job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobGWithdraw) + `, "job_gwithdraw", "GWithdrawal job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_gwithdraw`]) + `, "job_gwithdraw", "GWithdrawal job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobGStock) + `, "job_gstock", "GStock job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_gstock`]) + `, "job_gstock", "GStock job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobRescanMsg) + `, "job_rescan_msg", "Rescan message job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_rescan_msg`]) + `, "job_rescan_msg", "Rescan message job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobSetJobDone) + `, "job_set_done", "Set job as done job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_set_done`]) + `, "job_set_done", "Set job as done job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobMsgClient) + `, "job_msg_client", "Send message via client", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_msg_client`]) + `, "job_msg_client", "Send message via client", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobMsgRefresh) + `, "job_msg_refresh", "Refresh message from client", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_msg_refresh`]) + `, "job_msg_refresh", "Refresh message from client", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobBackupExport) + `, "job_backup_export", "Export Backup", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_backup_export`]) + `, "job_backup_export", "Export Backup", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobBackupImport) + `, "job_backup_import", "Import Backup", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_backup_import`]) + `, "job_backup_import", "Import Backup", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobGDeposit) + `, "job_gdeposit", "GDeposit job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_gdeposit`]) + `, "job_gdeposit", "GDeposit job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobGDepositForward) + `, "job_gdeposit_fwd", "GDeposit Forward job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_gdeposit_fwd`]) + `, "job_gdeposit_fwd", "GDeposit Forward job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobSaveRes) + `, "job_save_res", "Save resources job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_save_res`]) + `, "job_save_res", "Save resources job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobVaultUserStatus) + `, "job_vault_user_status", "Vault User Status job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_vault_user_status`]) + `, "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(cacheObjSubType[`job_vault_item_status`]) + `, "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(cacheObjSubType[`job_msg_fwd`]) + `, "job_fwd_msg", "Forward Message job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobSetDef) + `, "job_set_def", "Set Defense job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_set_def`]) + `, "job_set_def", "Set Defense job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobMsgDel) + `, "job_msg_del", "Msg Del job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_msg_del`]) + `, "job_msg_del", "Msg Del job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobGetHammerTime) + `, "job_get_hammer_time", "Get Hammer Time job", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(cacheObjSubType[`job_get_hammer_time`]) + `, "job_get_hammer_time", "Get Hammer Time job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeItemResource) + `, "item_res", "Resource", ` + strconv.Itoa(objTypeItem) + `) ,(` + strconv.Itoa(objSubTypeItemResource) + `, "item_res", "Resource", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemAlch) + `, "item_alch", "Alchemy", ` + strconv.Itoa(objTypeItem) + `) ,(` + strconv.Itoa(objSubTypeItemAlch) + `, "item_alch", "Alchemy", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemMisc) + `, "item_misc", "Miscelaneous", ` + strconv.Itoa(objTypeItem) + `) ,(` + strconv.Itoa(objSubTypeItemMisc) + `, "item_misc", "Miscelaneous", ` + strconv.Itoa(objTypeItem) + `)

View File

@ -420,7 +420,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
Date: m.Date, Date: m.Date,
} }
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
_, err = createJob(objSubTypeJobPillage, objJobPriority, m.TGUserID64, m.ObjID64, m.Date.Add(time.Duration(25+rand.Intn(35))*time.Second), b) _, err = createJob(cacheObjSubType[`job_pillage`], objJobPriority, m.TGUserID64, m.ObjID64, m.Date.Add(time.Duration(25+rand.Intn(35))*time.Second), b)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : createJob(JobPillage)") logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : createJob(JobPillage)")
} }
case cacheObjSubType[`msg_me_ack`]: case cacheObjSubType[`msg_me_ack`]:
@ -464,7 +464,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
ObjID64: m.ObjID64, ObjID64: m.ObjID64,
} }
b, _ := json.Marshal(&p) b, _ := json.Marshal(&p)
_, err = createJob(objSubTypeJobMsgRefresh, objJobPriority, m.TGUserID64, m.ObjID64, cwm.End.Add(5*time.Minute).UTC(), b) _, err = createJob(cacheObjSubType[`job_msg_refresh`], objJobPriority, m.TGUserID64, m.ObjID64, cwm.End.Add(5*time.Minute).UTC(), b)
/* hack for autobid - FIXME */ /* hack for autobid - FIXME */
/* /*
if cwm.Price == 0 && cwm.ItemID64 == getObjItemID(`k05`, `Hunter blade`) { if cwm.Price == 0 && cwm.ItemID64 == getObjItemID(`k05`, `Hunter blade`) {
@ -549,37 +549,37 @@ func JobWorker(id int, jobs <-chan Job) {
//log.Printf("JobWorker[%d] : Starting job %d (timeout : %s).\n", id, j.ID64, j.Timeout.Format(time.RFC3339)) //log.Printf("JobWorker[%d] : Starting job %d (timeout : %s).\n", id, j.ID64, j.Timeout.Format(time.RFC3339))
if time.Now().UTC().Before(j.Timeout) { if time.Now().UTC().Before(j.Timeout) {
switch j.JobTypeID { switch j.JobTypeID {
case objSubTypeJobRescanMsg: case cacheObjSubType[`job_rescan_msg`]:
jobRescan(j) jobRescan(j)
case objSubTypeJobSetJobDone: case cacheObjSubType[`job_set_done`]:
jobSetDone(j) jobSetDone(j)
case objSubTypeJobPillage: case cacheObjSubType[`job_pillage`]:
jobPillage(j) jobPillage(j)
case objSubTypeJobMsgClient: case cacheObjSubType[`job_msg_client`]:
jobMsgClient(j) jobMsgClient(j)
case objSubTypeJobMsgRefresh: case cacheObjSubType[`job_msg_refresh`]:
jobMsgRefresh(j) jobMsgRefresh(j)
case objSubTypeJobBackupExport: case cacheObjSubType[`job_backup_export`]:
jobBackupExport(j) jobBackupExport(j)
case objSubTypeJobBackupImport: case cacheObjSubType[`job_backup_import`]:
jobBackupImport(j) jobBackupImport(j)
case objSubTypeJobGStock: case cacheObjSubType[`job_gstock`]:
jobGStock(j) jobGStock(j)
case objSubTypeJobGDeposit: case cacheObjSubType[`job_gdeposit`]:
jobGDeposit(j) jobGDeposit(j)
case objSubTypeJobGDepositForward: case cacheObjSubType[`job_gdeposit_fwd`]:
jobGDepositForward(j) jobGDepositForward(j)
case objSubTypeJobGWithdraw: case cacheObjSubType[`job_gwithdraw`]:
jobGWithdraw(j) jobGWithdraw(j)
case objSubTypeJobVaultUserStatus: case cacheObjSubType[`job_vault_user_status`]:
jobVaultUserStatus(j) jobVaultUserStatus(j)
case objSubTypeJobVaultItemStatus: case cacheObjSubType[`job_vault_item_status`]:
jobVaultItemStatus(j) jobVaultItemStatus(j)
case objSubTypeJobFwdMsg: case cacheObjSubType[`job_msg_fwd`]:
jobFwdMsg(j) jobFwdMsg(j)
case objSubTypeJobSetDef: case cacheObjSubType[`job_set_def`]:
jobSetDef(j) jobSetDef(j)
case objSubTypeJobGetHammerTime: case cacheObjSubType[`job_get_hammer_time`]:
jobGetHammerTime(j) jobGetHammerTime(j)
default: default:
log.Printf("jobWorker["+strconv.Itoa(id)+"] : No handler for job type #%d.\n", j.JobTypeID) log.Printf("jobWorker["+strconv.Itoa(id)+"] : No handler for job type #%d.\n", j.JobTypeID)