testtest
This commit is contained in:
parent
b310196953
commit
278fb1cab6
29
def.go
29
def.go
@ -101,7 +101,7 @@ type Job struct {
|
||||
}
|
||||
|
||||
type JobPayloadPillage struct {
|
||||
Date time.Time `json:"date"`
|
||||
ObjID64 int64 `json:"obj_id"`
|
||||
}
|
||||
|
||||
type JobPayloadTribute struct {
|
||||
@ -166,15 +166,17 @@ const (
|
||||
objSubTypeMessageMe = 310
|
||||
objSubTypeMessageInventory = 311
|
||||
objSubTypeMessagePillageInc = 312
|
||||
objSubTypeMessageTributeInc = 313
|
||||
objSubTypeMessagePillageAck = 314
|
||||
objSubTypeMessageTributeAck = 315
|
||||
objSubTypeMessageAuctionAnnounce = 316
|
||||
objSubTypeMessageAuctionUpdReq = 317
|
||||
objSubTypeMessageAuctionUpdAck = 318
|
||||
objSubTypeMessageTimeAck = 319
|
||||
objSubTypeMessageTimeReq = 320
|
||||
objSubTypeMessageGo = 321
|
||||
objSubTypeMessagePillageGo = 313
|
||||
objSubTypeMessagePillageWin = 314
|
||||
objSubTypeMessagePillageLoss = 315
|
||||
objSubTypeMessageTributeInc = 316
|
||||
objSubTypeMessageTributeAck = 317
|
||||
objSubTypeMessageAuctionAnnounce = 318
|
||||
objSubTypeMessageAuctionUpdReq = 319
|
||||
objSubTypeMessageAuctionUpdAck = 320
|
||||
objSubTypeMessageTimeAck = 321
|
||||
objSubTypeMessageTimeReq = 322
|
||||
objSubTypeMessageGo = 323
|
||||
objSubTypeJobPillage = 601
|
||||
objSubTypeJobTribute = 602
|
||||
objSubTypeJobStatus = 603
|
||||
@ -189,9 +191,10 @@ const (
|
||||
objSubTypeItemPart = 705
|
||||
objSubTypeItemOther = 706
|
||||
|
||||
objJobStatusNew = 0
|
||||
objJonStatusPending = 10
|
||||
objJobStatusDone = 20
|
||||
objJobStatusNew = 0
|
||||
objJobStatusPillageGo = 1
|
||||
objJonStatusPending = 10
|
||||
objJobStatusDone = 20
|
||||
|
||||
objJobPriority = 1
|
||||
objJobPriorityRescanMsg = 2
|
||||
|
30
job.go
30
job.go
@ -93,16 +93,32 @@ func jobSetDone(j Job) {
|
||||
}
|
||||
|
||||
func jobPillage(j Job) {
|
||||
var r JobPayloadPillage
|
||||
/*
|
||||
var r JobPayloadPillage
|
||||
|
||||
err := setJobStart(j.ID64)
|
||||
logOnError(err, "jobPillage : setJobStart")
|
||||
err := setJobStart(j.ID64)
|
||||
logOnError(err, "jobPillage : setJobStart")
|
||||
|
||||
err = json.Unmarshal(j.Payload, &r)
|
||||
logOnError(err, "jobPillage : Unmarshal payload")
|
||||
err = json.Unmarshal(j.Payload, &r)
|
||||
logOnError(err, "jobPillage : Unmarshal payload")
|
||||
|
||||
err = setJobDone(j.ID64)
|
||||
logOnError(err, "jobPillage : setJobDone")
|
||||
ids := getSQLListID64(` select og.id
|
||||
from obj og
|
||||
,obj_msg omg
|
||||
,obj op
|
||||
,obj_msg omp
|
||||
,obj_job oj
|
||||
where omg.obj_id = og.id
|
||||
and og.obj_sub_type_id = ` + strconv.Itoa(objSubTypeMessageGo) `
|
||||
and omg.user_id = oj.user_id
|
||||
and omg.sender_user_id = oj.user_id
|
||||
and oj.obj_id = ` + strconv.Itoa(j.ID64) `
|
||||
and omp.obj_id = op.id
|
||||
and op.id = ` + strconv.Itoa(r.ObjID64) `
|
||||
and omg.date between omp.date and addtime(omp.date, '0 0:3:0.000000');`
|
||||
|
||||
err = setJobStatus(j.ID64, objJobStatusPillageGo, time.Now().Add(5 * time.second))
|
||||
logOnError(err, "jobPillage : setJobDone")
|
||||
*/
|
||||
return
|
||||
}
|
||||
|
6
sql.go
6
sql.go
@ -310,8 +310,10 @@ func initDB() {
|
||||
,(` + strconv.Itoa(objSubTypeMessageMe) + `, "me", "Hero short summary", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessageInventory) + `, "inv", "Inventory", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "pillage_inc", "Pillage incoming", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessagePillageGo) + `, "pillage_go", "Pillage go", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessagePillageWin) + `, "pillage_win", "Pillage win", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessagePillageLoss) + `, "pillage_loss", "Pillage loss", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessageTributeInc) + `, "tribute_inc", "Tribute incoming", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessagePillageAck) + `, "pillage_ack", "Pillage acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessageTributeAck) + `, "tribute_ack", "Tribute acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "auction_announce", "Auction announce", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
,(` + strconv.Itoa(objSubTypeMessageAuctionUpdReq) + `, "auction_upd_req", "Auction update request", ` + strconv.Itoa(objTypeMessage) + `)
|
||||
@ -1321,6 +1323,8 @@ func resetMsgParsingRules() {
|
||||
`Battle (?P<Time>[0-9]{2}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2})$")
|
||||
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "Pillage Inc", "^You were strolling around on your horse when you noticed (\\[(?P<Guild>[A-Z0-9]{1,3})\\]){0,1}(?P<Attacker>.*) of .{1}(?P<Castle>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)) Castle trying to pillage a local village. To stop him click /go$")
|
||||
,(5000, ` + strconv.Itoa(objSubTypeMessageGo) + `, "Go", "^/go$")
|
||||
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageGo) + `,"Pillage Go", "^You lift up your sword and charge at the violator.$")
|
||||
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageWin) + `,"Pillage Win", "^You successfully defeated (\\[(?P<Guild>[A-Z0-9]{1,3})\\]){0,1}(?P<Attacker>.*). As he was crawling away, you picked up some of the gold he left behind. Received (?P<Gold>[0-9]+) gold and (?P<Exp>[0-9]+) exp.$`)
|
||||
;`)
|
||||
failOnError(err, "resetMsgParsingRules : populate table msg_rules")
|
||||
}
|
||||
|
36
workers.go
36
workers.go
@ -108,24 +108,32 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgPillageInc")
|
||||
err = setObjSubTypeId(objId, objSubTypeMessagePillageInc)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageInc)")
|
||||
if m.Date.Add(3 * time.Minute).After(time.Now()) {
|
||||
p := JobPayloadPillage{
|
||||
Date: m.Date,
|
||||
}
|
||||
b, _ := json.Marshal(&p)
|
||||
err = createJob(objSubTypeJobPillage, objJobPriority, m.UserID64, time.Now().Add(time.Duration(25+rand.Intn(35))*time.Second), b)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : createJob(JobPillage)")
|
||||
s := TGCommand{
|
||||
Type: commandSendMsg,
|
||||
Text: fmt.Sprintf("Catching pillage (%s)", m.Date.Format(time.RFC3339)),
|
||||
ToUserID64: m.UserID64,
|
||||
}
|
||||
TGCmdQueue <- s
|
||||
// if m.Date.Add(3 * time.Minute).After(time.Now()) {
|
||||
p := JobPayloadPillage{
|
||||
ObjID64: objId,
|
||||
}
|
||||
b, _ := json.Marshal(&p)
|
||||
err = createJob(objSubTypeJobPillage, objJobPriority, m.UserID64, m.Date.Add(time.Duration(25+rand.Intn(35))*time.Second), b)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : createJob(JobPillage)")
|
||||
s := TGCommand{
|
||||
Type: commandSendMsg,
|
||||
Text: fmt.Sprintf("Catching pillage (%s)", m.Date.Format(time.RFC3339)),
|
||||
ToUserID64: m.UserID64,
|
||||
}
|
||||
TGCmdQueue <- s
|
||||
// }
|
||||
case objSubTypeMessageGo:
|
||||
err = setObjSubTypeId(objId, objSubTypeMessageGo)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Go)")
|
||||
|
||||
case objSubTypeMessagePillageGo:
|
||||
err = setObjSubTypeId(objId, objSubTypeMessagePillageGo)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageGo)")
|
||||
case objSubTypeMessagePillageWin:
|
||||
err = setObjSubTypeId(objId, objSubTypeMessagePillageWin)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageWin)")
|
||||
case objSubTypeMessagePillageLoss:
|
||||
err = setObjSubTypeId(objId, objSubTypeMessagePillageLoss)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageLoss)")
|
||||
case objSubTypeMessageAuctionAnnounce:
|
||||
cwm := ChatWarsMessageAuctionAnnounce{
|
||||
ObjID64: objId,
|
||||
|
Loading…
Reference in New Issue
Block a user