update items and jobs

This commit is contained in:
shoopea 2019-08-19 18:41:43 +08:00
parent b56aabcc7e
commit 26c84a1049
4 changed files with 47 additions and 2 deletions

7
bot.go
View File

@ -606,7 +606,14 @@ func botGDepositAll(m *tb.Message) {
p := JobPayloadGDeposit{
MsgID64: int64(m.ID),
ChatID64: m.Chat.ID,
ResObjID64: nil,
}
p.ResObjID64 = append(p.ResObjID64, getObjItemID(`02`, `Stick`))
p.ResObjID64 = append(p.ResObjID64, getObjItemID(`04`, `Bone`))
p.ResObjID64 = append(p.ResObjID64, getObjItemID(`09`, `Cloth`))
p.ResObjID64 = append(p.ResObjID64, getObjItemID(`21`, `Bone powder`))
b, _ := json.Marshal(p)
t := time.Now().UTC()
_, err := createJob(objSubTypeJobGDeposit, objJobPriority, int64(m.Chat.ID), t, b)

34
job.go
View File

@ -703,3 +703,37 @@ func jobGStock(j Job) {
logOnError(err, "jobGStock : setJobDone")
return
}
func jobGDeposit(j Job) {
var p JobPayloadGDeposit
err := setJobStart(j.ID64)
logOnError(err, "jobGDeposit : setJobStart")
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobGDeposit : Unmarshal payload")
for i := range p.ResObjID64 {
clientSendCWMsg(p.ChatID64, "/g_stock_res")
}
/*
clientSendCWMsg(m.Chat.ID, "/g_stock_res")
clientSendCWMsg(m.Chat.ID, "/g_stock_alch")
clientSendCWMsg(m.Chat.ID, "/g_stock_misc")
clientSendCWMsg(m.Chat.ID, "/g_stock_rec")
clientSendCWMsg(m.Chat.ID, "/g_stock_parts")
clientSendCWMsg(m.Chat.ID, "/g_stock_other")
*/
if err == nil {
m := TGCommand{
Type: commandReplyMsg,
Text: "Message sent.",
FromMsgID64: p.MsgID64,
FromChatID64: p.ChatID64,
}
TGCmdQueue <- m
}
err = setJobDone(j.ID64)
logOnError(err, "jobGDeposit : setJobDone")
return
}

2
sql.go
View File

@ -298,6 +298,8 @@ func initDB() {
obj_id BIGINT UNSIGNED NOT NULL
,intl_id VARCHAR(32)
,weight SMALLINT NOT NULL
,trade TINYINT NOT NULL
,auction TINYINT NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (intl_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)

View File

@ -530,6 +530,8 @@ func JobWorker(id int, jobs <-chan Job) {
jobBackupImport(j)
case objSubTypeJobGStock:
jobGStock(j)
case objSubTypeJobGDeposit:
jobGDeposit(j)
default:
log.Printf("jobWorker["+strconv.Itoa(id)+"] : No handler for job type #%d.\n", j.JobTypeID)
}