From 36382d6f114ef508b8c8bbbdbe799a2bc5a16a4e Mon Sep 17 00:00:00 2001 From: shoopea Date: Wed, 2 Oct 2019 12:43:27 +0800 Subject: [PATCH] initiate withdrawal --- bot.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ def.go | 7 +++++++ 2 files changed, 57 insertions(+) diff --git a/bot.go b/bot.go index 4f7f6a4..24cb9ae 100644 --- a/bot.go +++ b/bot.go @@ -34,6 +34,7 @@ func BotHandlers(b *tb.Bot) { b.Handle("/g_stock", botGStock) b.Handle("/g_deposit_all", botGDepositAll) + b.Handle("/g_withdraw", botGWithdraw) b.Handle("/save_res", botSaveRes) b.Handle("/backup_export", botBackupExport) @@ -716,6 +717,55 @@ func botGDepositAll(m *tb.Message) { return } +func botGWithdraw(m *tb.Message) { + if !m.Private() { + return + } + + p := JobPayloadGWithdraw{ + MsgID64: int64(m.ID), + ChatID64: m.Chat.ID, + items: nil, + Status: 0, + } + + r := regexp.MustCompile("^(( )*[a-z0-9]+ [0-9]+( )*)+$") + for _, l := range r.FindAllStringSubmatch(m.Payload, -1) { + fmt.Print("%v\n", l) + /* + i := getObjItemID(``, l[1]) + q, _ := strconv.ParseInt(l[2], 10, 64) + */ + /* + ChatWarsItems + b, _ := json.Marshal(p) + t := time.Now().UTC() + _, err := createJob(objSubTypeJobGDeposit, objJobPriority, int64(m.Chat.ID), 0, t, b) + */ + } + if false { + c := TGCommand{ + Type: commandReplyMsg, + Text: fmt.Sprintf("%s", err), + FromMsgID64: int64(m.ID), + FromChatID64: m.Chat.ID, + } + TGCmdQueue <- c + } else { + c := TGCommand{ + Type: commandReplyMsg, + Text: "Withdrawal started", + FromMsgID64: int64(m.ID), + FromChatID64: m.Chat.ID, + } + TGCmdQueue <- c + } + + //log.Printf("botGDepositAll : json : %s\n", string(b)) + + return +} + func botTimer(m *tb.Message) { if !m.Private() { return diff --git a/def.go b/def.go index 394e818..6dfff70 100644 --- a/def.go +++ b/def.go @@ -293,6 +293,13 @@ type JobPayloadGStock struct { ChatID64 int64 `json:"chat_id"` } +type JobPayloadGWithdraw struct { + MsgID64 int64 `json:"msg_id"` + ChatID64 int64 `json:"chat_id"` + Items []ChatWarsItems `json:"items"` + Status int `json:"status"` +} + type JobPayloadGDeposit struct { MsgID64 int64 `json:"msg_id"` ChatID64 int64 `json:"chat_id"`