update job
This commit is contained in:
parent
e99839e67a
commit
16b3a70c96
4
def.go
4
def.go
@ -334,6 +334,10 @@ type ChatWarsMessageTimeAck struct {
|
||||
WeatherNext string `json:"weather_next"`
|
||||
}
|
||||
|
||||
type ChatWarsMessageInspectAck struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ChatWarsMessageJobGWithdrawAck struct {
|
||||
Msg *ChatWarsMessage `json:"msg"`
|
||||
Ref string `json:"ref"`
|
||||
|
70
job.go
70
job.go
@ -1520,12 +1520,11 @@ func jobGWithdraw(j Job) {
|
||||
}
|
||||
}
|
||||
|
||||
p2 := JobPayloadMsgDel{
|
||||
Delay: (10 * time.Second),
|
||||
ObjMsgID64: j.Trigger,
|
||||
m, err := getObjMsg(j.Trigger)
|
||||
logOnError(err, "jobGWithdraw : getObjMsg")
|
||||
if err == nil {
|
||||
p.CleanupMsg = append(p.CleanupMsg, *m)
|
||||
}
|
||||
b2, _ := json.Marshal(p2)
|
||||
createJob(cacheObjSubType[`job_msg_del`], objJobPriority, j.UserID64, 0, time.Now().UTC(), b2)
|
||||
|
||||
if isUnique {
|
||||
for _, req := range p.Items {
|
||||
@ -1552,9 +1551,68 @@ func jobGWithdraw(j Job) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if id == cacheObjSubType[`msg_inspect_ack`] {
|
||||
m, err := getObjMsg(j.Trigger)
|
||||
logOnError(err, "jobGWithdraw : getObjMsg")
|
||||
rule, err := getMsgParsingRule(m)
|
||||
logOnError(err, "jobGWithdraw : getMsgParsingRule")
|
||||
cwm, err := parseSubTypeMessageInspectAck(m, rule.re)
|
||||
logOnError(err, "jobGWithdraw : parseSubTypeMessageInspectAck")
|
||||
for k, req := range p.Items {
|
||||
if req.Code == p.Inspecting {
|
||||
p.Items[k].Available = 1
|
||||
p.Items[k].Name = cwm.Name
|
||||
p.Items[k].Inspect = false
|
||||
break
|
||||
}
|
||||
}
|
||||
p.Inspecting = ``
|
||||
|
||||
m, err := getObjMsg(j.Trigger)
|
||||
logOnError(err, "jobGWithdraw : getObjMsg")
|
||||
if err == nil {
|
||||
p.CleanupMsg = append(p.CleanupMsg, *m)
|
||||
}
|
||||
|
||||
if id == cacheObjSubType[`msg_msg_job_gwithdraw_ack`] {
|
||||
for _, req := range p.Items {
|
||||
if req.Inspect {
|
||||
p2 = JobPayloadMsgDel{
|
||||
MsgTypeID64: cacheObjSubType[`msg_g_inspect_req`],
|
||||
Delay: (10 * time.Second),
|
||||
ObjMsgID64: 0,
|
||||
}
|
||||
b2, _ = json.Marshal(p2)
|
||||
createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute)
|
||||
|
||||
p.Inspecting = req.Code
|
||||
b, _ := json.Marshal(p)
|
||||
|
||||
id, err := createJob(cacheObjSubType[`job_gwithdraw`], objJobPriority, j.UserID64, 0, time.Unix(maxUnixTimestamp, 0).UTC(), b)
|
||||
logOnError(err, "jobGWithdraw : createJob")
|
||||
setJobCallback(id, int64(bot.Me.ID), cacheObjSubType[`msg_invalid_action`])
|
||||
setJobCallback(id, int64(bot.Me.ID), cacheObjSubType[`msg_inspect_ack`])
|
||||
clientSendCWMsg(j.UserID64, fmt.Sprintf("/g_inspect_%s", p.Inspecting))
|
||||
err = setJobDone(j.ID64)
|
||||
logOnError(err, "jobGWithdraw : setJobDone")
|
||||
return
|
||||
}
|
||||
}
|
||||
} else if id == cacheObjSubType[`msg_invalid_action`] {
|
||||
|
||||
for k, req := range p.Items {
|
||||
if req.Code == p.Inspecting {
|
||||
p.Items[k].Available = 1
|
||||
p.Items[k].Inspect = false
|
||||
break
|
||||
}
|
||||
}
|
||||
p.Inspecting = ``
|
||||
m, err := getObjMsg(j.Trigger)
|
||||
logOnError(err, "jobGWithdraw : getObjMsg")
|
||||
if err == nil {
|
||||
p.CleanupMsg = append(p.CleanupMsg, *m)
|
||||
}
|
||||
} else if id == cacheObjSubType[`msg_msg_job_gwithdraw_ack`] {
|
||||
m, err := getObjMsg(j.Trigger)
|
||||
logOnError(err, "jobGWithdraw : getObjMsg")
|
||||
rule, err := getMsgParsingRule(m)
|
||||
|
7
msg.go
7
msg.go
@ -27,6 +27,13 @@ func getMsgParsingRule(m *ChatWarsMessage) (*MessageParsingRule, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func parseSubTypeMessageInspectAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageInspectAck, error) {
|
||||
cwm := ChatWarsMessageInspectAck{}
|
||||
cwm.Name = r.ReplaceAllString(m.Text, "${Item}")
|
||||
log.Printf("parseSubTypeMessageInspectAck : Name : %s\n", cwm.Name)
|
||||
return &cwm, nil
|
||||
}
|
||||
|
||||
func parseSubTypeMessageExchangeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageExchangeAck, error) {
|
||||
cwm := ChatWarsMessageExchangeAck{}
|
||||
deals := []ChatWarsExchangeDeal{}
|
||||
|
Loading…
Reference in New Issue
Block a user