initiate withdrawal

This commit is contained in:
shoopea 2019-10-02 12:43:27 +08:00
parent 01ef73c11d
commit 36382d6f11
2 changed files with 57 additions and 0 deletions

50
bot.go
View File

@ -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

7
def.go
View File

@ -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"`