This commit is contained in:
shoopea 2019-05-08 22:34:47 +08:00
parent 7078baee23
commit b19faf6b5d
3 changed files with 36 additions and 24 deletions

41
def.go
View File

@ -30,26 +30,27 @@ const (
objTypeWarReport = 5 objTypeWarReport = 5
objTypeJob = 6 objTypeJob = 6
objSubTypeMessageUnknown = 301 objSubTypeMessageUnknown = 301
objSubTypeMessageWar = 302 objSubTypeMessageWar = 302
objSubTypeMessageMiniWar = 303 objSubTypeMessageMiniWar = 303
objSubTypeMessageGuildWar = 304 objSubTypeMessageGuildWar = 304
objSubTypeMessageReport = 305 objSubTypeMessageReport = 305
objSubTypeMessageGReport = 306 objSubTypeMessageGReport = 306
objSubTypeMessageQuest = 307 objSubTypeMessageQuest = 307
objSubTypeMessageFight = 308 objSubTypeMessageFight = 308
objSubTypeMessageHero = 309 objSubTypeMessageHero = 309
objSubTypeMessageMe = 310 objSubTypeMessageMe = 310
objSubTypeMessageInventory = 311 objSubTypeMessageInventory = 311
objSubTypeMessagePillageInc = 312 objSubTypeMessagePillageInc = 312
objSubTypeMessageTributeInc = 313 objSubTypeMessageTributeInc = 313
objSubTypeMessagePillageAck = 314 objSubTypeMessagePillageAck = 314
objSubTypeMessageTributeAck = 315 objSubTypeMessageTributeAck = 315
objSubTypeJobPillage = 601 objSubTypeMessageAuctionAnnounce = 316
objSubTypeJobTribute = 602 objSubTypeJobPillage = 601
objSubTypeJobStatus = 603 objSubTypeJobTribute = 602
objSubTypeJobWithdrawal = 604 objSubTypeJobStatus = 603
objSubTypeJobGStock = 605 objSubTypeJobWithdrawal = 604
objSubTypeJobGStock = 605
MQGetMsgWorkers = 3 MQGetMsgWorkers = 3
SQLCWMsgWorkers = 6 SQLCWMsgWorkers = 6

10
sql.go
View File

@ -188,12 +188,14 @@ func initDB() {
,(` + strconv.Itoa(objSubTypeMessageInventory) + `, "inv", "Inventory", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(objSubTypeMessageInventory) + `, "inv", "Inventory", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "pillage_inc", "Pillage incoming", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "pillage_inc", "Pillage incoming", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTributeInc) + `, "tribute_inc", "Request incoming", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(objSubTypeMessageTributeInc) + `, "tribute_inc", "Request incoming", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageAck) + `, "pillage_ack", "Pillage acknoledged", ` + strconv.Itoa(objTypeMessage) + `) ,(` + strconv.Itoa(objSubTypeMessagePillageAck) + `, "pillage_ack", "Pillage acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTributeAck) + `, "tribute_ack", "Request acknoledged", ` + strconv.Itoa(objTypeMessage) + `);`) ,(` + strconv.Itoa(objSubTypeMessageTributeAck) + `, "tribute_ack", "Request acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "auction_announce", "Auction announce", ` + strconv.Itoa(objTypeMessage) + `);`)
failOnError(err, "initDB : populate table code_obj_sub_type") failOnError(err, "initDB : populate table code_obj_sub_type")
_, err = db.Exec(`INSERT INTO msg_rules (prio, descn, rule, msg_type_id) _, err = db.Exec(`INSERT INTO msg_rules (prio, msg_type_id, descn, rule)
VALUES (5000, "Player war report", "^(?P<Castle>[🐉🦅🐺🦈🦌🥔🌑])(?P<Guild>(\\[[A-Z]{3}\\]){0,1})(?P<User>([A-Za-z0-9 ]*)) ⚔:(?P<Attack>[0-9]+)(?P<AttackMod>\\((-|\\+)[0-9]+\\)){0,1} 🛡:(?P<Defense>[0-9]+) Lvl: (?P<Level>[0-9]+)\\nYour result on the battlefield:\\n🔥Exp: (?P<Exp>[0-9]+)\\n💰Gold: (?P<Gold>-{0,1}[0-9]+)\\n📦Stock: (?P<Stock>-{0,1}[0-9]+)(\\n)*(?P<Stamina>(🔋Stamina restored)){0,1}(\\n)*(?P<Crit>(⚡Critical strike)){0,1}(\\n)*(?s:.*)$", ` + strconv.Itoa(objSubTypeMessageReport) + `);`) VALUES (5000, ` + strconv.Itoa(objSubTypeMessageReport) + `, "Player war report", "^(?P<Castle>[🐉🦅🐺🦈🦌🥔🌑])(?P<Guild>(\\[[A-Z]{3}\\]){0,1})(?P<User>([A-Za-z0-9 ]*)) ⚔:(?P<Attack>[0-9]+)(?P<AttackMod>\\((-|\\+)[0-9]+\\)){0,1} 🛡:(?P<Defense>[0-9]+) Lvl: (?P<Level>[0-9]+)\\nYour result on the battlefield:\\n🔥Exp: (?P<Exp>[0-9]+)\\n💰Gold: (?P<Gold>-{0,1}[0-9]+)\\n📦Stock: (?P<Stock>-{0,1}[0-9]+)(\\n)*(?P<Stamina>(🔋Stamina restored)){0,1}(\\n)*(?P<Crit>(⚡Critical strike)){0,1}(\\n)*(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "Auction annouce", "^Lot #(?P<Lot>[0-9]+) : (?P<Item>.*)\\nSeller: (?P<Seller>.*)\\nCurrent price: (?P<Price>[0-9]+) pouch\\(es\\)\\nBuyer: (?P<Buyer>.*)\\nEnd At: (?P<End>.*)\\nStatus: (?P<Status>.*)(\\n)*(?s:.*);`)
failOnError(err, "initDB : populate table msg_rules") failOnError(err, "initDB : populate table msg_rules")
log.Println("Database set up") log.Println("Database set up")

View File

@ -99,6 +99,15 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stock : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stock}"), objId) log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stock : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stock}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stamina : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stamina}"), objId) log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stamina : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stamina}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Crit : %s (%d)\n", r.ReplaceAllString(m.Text, "${Crit}"), objId) log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Crit : %s (%d)\n", r.ReplaceAllString(m.Text, "${Crit}"), objId)
case objSubTypeMessageAuctionAnnounce:
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Auction announce (%d)\n", objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Lot : %s (%d)\n", r.ReplaceAllString(m.Text, "${Lot}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Item : %s (%d)\n", r.ReplaceAllString(m.Text, "${Item}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Seller : %s (%d)\n", r.ReplaceAllString(m.Text, "${Seller}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Buyer : %s (%d)\n", r.ReplaceAllString(m.Text, "${Buyer}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Price : %s (%d)\n", r.ReplaceAllString(m.Text, "${Price}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Status : %s (%d)\n", r.ReplaceAllString(m.Text, "${Status}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : End : %s (%d)\n", r.ReplaceAllString(m.Text, "${End}"), objId)
default: default:
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID, objId) log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID, objId)
} }