diff --git a/bot.go b/bot.go index da57cd7..ecfd36b 100644 --- a/bot.go +++ b/bot.go @@ -604,9 +604,16 @@ func botGDepositAll(m *tb.Message) { } p := JobPayloadGDeposit{ - MsgID64: int64(m.ID), - ChatID64: m.Chat.ID, + 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) diff --git a/job.go b/job.go index f9377c6..df2a95a 100644 --- a/job.go +++ b/job.go @@ -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 +} diff --git a/sql.go b/sql.go index fbc9037..1915747 100644 --- a/sql.go +++ b/sql.go @@ -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;`) diff --git a/workers.go b/workers.go index fcd535b..528b8b4 100644 --- a/workers.go +++ b/workers.go @@ -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) }