first step for automated g_deposit

This commit is contained in:
shoopea 2019-08-16 18:29:07 +08:00
parent c7a631a252
commit 41f02309d5
3 changed files with 34 additions and 0 deletions

27
bot.go
View File

@ -32,6 +32,7 @@ func BotHandlers(b *tb.Bot) {
b.Handle("/timer", botTimer) b.Handle("/timer", botTimer)
b.Handle("/g_stock", botGStock) b.Handle("/g_stock", botGStock)
b.Handle("/g_deposit_all", botGDepositAll)
b.Handle("/backup_export", botBackupExport) b.Handle("/backup_export", botBackupExport)
b.Handle("/backup_import", botBackupImport) b.Handle("/backup_import", botBackupImport)
@ -597,6 +598,32 @@ func botGStock(m *tb.Message) {
return return
} }
func botGDepositAll(m *tb.Message) {
if !m.Private() {
return
}
p := JobPayloadGDeposit{
MsgID64: int64(m.ID),
ChatID64: m.Chat.ID,
}
b, _ := json.Marshal(p)
t := time.Now().UTC()
_, err := createJob(objSubTypeJobGDeposit, objJobPriority, int64(m.Chat.ID), t, b)
if err != nil {
c := TGCommand{
Type: commandReplyMsg,
Text: fmt.Sprintf("%s", err),
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
}
return
}
func botTimer(m *tb.Message) { func botTimer(m *tb.Message) {
if !m.Private() { if !m.Private() {
return return

6
def.go
View File

@ -234,6 +234,11 @@ type JobPayloadGStock struct {
ChatID64 int64 `json:"chat_id"` ChatID64 int64 `json:"chat_id"`
} }
type JobPayloadGDeposit struct {
MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"`
}
type JobPayloadRescanMsg struct { type JobPayloadRescanMsg struct {
Query string `json:"query"` Query string `json:"query"`
MsgID64 int64 `json:"msg_id"` MsgID64 int64 `json:"msg_id"`
@ -377,6 +382,7 @@ const (
objSubTypeJobMsgRefresh = 609 objSubTypeJobMsgRefresh = 609
objSubTypeJobBackupExport = 610 objSubTypeJobBackupExport = 610
objSubTypeJobBackupImport = 611 objSubTypeJobBackupImport = 611
objSubTypeJobGDeposit = 612
objSubTypeItemResource = 701 objSubTypeItemResource = 701
objSubTypeItemAlch = 702 objSubTypeItemAlch = 702
objSubTypeItemMisc = 703 objSubTypeItemMisc = 703

1
sql.go
View File

@ -494,6 +494,7 @@ func initDB() {
,(` + strconv.Itoa(objSubTypeJobMsgRefresh) + `, "job_msg_refresh", "Refresh message from client", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(objSubTypeJobMsgRefresh) + `, "job_msg_refresh", "Refresh message from client", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobBackupExport) + `, "job_backup_export", "Export Backup", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(objSubTypeJobBackupExport) + `, "job_backup_export", "Export Backup", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobBackupImport) + `, "job_backup_import", "Import Backup", ` + strconv.Itoa(objTypeJob) + `) ,(` + strconv.Itoa(objSubTypeJobBackupImport) + `, "job_backup_import", "Import Backup", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobGDeposit) + `, "job_gdeposit", "GDeposit job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeItemResource) + `, "item_res", "Time", ` + strconv.Itoa(objTypeItem) + `) ,(` + strconv.Itoa(objSubTypeItemResource) + `, "item_res", "Time", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemAlch) + `, "item_alch", "Time", ` + strconv.Itoa(objTypeItem) + `) ,(` + strconv.Itoa(objSubTypeItemAlch) + `, "item_alch", "Time", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemMisc) + `, "item_misc", "Time", ` + strconv.Itoa(objTypeItem) + `) ,(` + strconv.Itoa(objSubTypeItemMisc) + `, "item_misc", "Time", ` + strconv.Itoa(objTypeItem) + `)