g_withdraw start

This commit is contained in:
shoopea 2019-10-04 18:38:03 +08:00
parent dbf8d57e31
commit 422fd7ac25
3 changed files with 41 additions and 17 deletions

27
bot.go
View File

@ -111,7 +111,8 @@ func botHelp(m *tb.Message) {
/backup_import <URL> - import message database from URL /backup_import <URL> - import message database from URL
/get_item_id <string> - identify item_id from string /get_item_id <string> - identify item_id from string
/clients - list all connected clients /clients - list all connected clients
/g_deposit_all - deposit all res to vault`, /g_deposit_all - deposit all res to vault
/g_withdraw <item> <qty> .. - withdraw items`,
FromMsgID64: int64(m.ID), FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID, FromChatID64: m.Chat.ID,
} }
@ -722,27 +723,19 @@ func botGWithdraw(m *tb.Message) {
if !m.Private() { if !m.Private() {
return return
} }
/*
r := regexp.MustCompile("^(( )*[a-z0-9]+ [0-9]+( )*)+$")
if r.MatchString(m.Payload) {
p := JobPayloadGWithdraw{ p := JobPayloadGWithdraw{
MsgID64: int64(m.ID), MsgID64: int64(m.ID),
ChatID64: m.Chat.ID, ChatID64: m.Chat.ID,
Items: nil, Request: m.Payload,
Status: 0, Status: 0,
} }
*/ b, _ := json.Marshal(p)
r := regexp.MustCompile("[a-z0-9]+ [0-9]+") t := time.Now().UTC()
for _, l := range r.FindAllStringSubmatch(m.Payload, -1) { _, err := createJob(objSubTypeJobGWithdraw, objJobPriority, int64(m.Chat.ID), 0, t, b)
fmt.Printf("%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 { if false {
c := TGCommand{ c := TGCommand{

29
job.go
View File

@ -890,3 +890,32 @@ func jobGDeposit(j Job) {
logOnError(err, "jobGDeposit : setJobDone") logOnError(err, "jobGDeposit : setJobDone")
return return
} }
func jobGWithdraw(j Job) {
var p JobPayloadGWithdraw
err := setJobStart(j.ID64)
logOnError(err, "jobGWithdraw : setJobStart")
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobGWithdraw : Unmarshal payload")
r := regexp.MustCompile("[a-z0-9]+ [0-9]+")
for _, l := range r.FindAllStringSubmatch(p.Request, -1) {
fmt.Printf("jobGWithdraw : %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)
*/
}
err = setJobDone(j.ID64)
logOnError(err, "jobGWithdraw : setJobDone")
return
}

View File

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