test
This commit is contained in:
parent
47f5d91212
commit
eae31c3630
2
def.go
2
def.go
@ -49,6 +49,7 @@ const (
|
|||||||
objSubTypeMessagePillageAck = 314
|
objSubTypeMessagePillageAck = 314
|
||||||
objSubTypeMessageTributeAck = 315
|
objSubTypeMessageTributeAck = 315
|
||||||
objSubTypeMessageAuctionAnnounce = 316
|
objSubTypeMessageAuctionAnnounce = 316
|
||||||
|
objSubtypeMessageTime = 317
|
||||||
objSubTypeJobPillage = 601
|
objSubTypeJobPillage = 601
|
||||||
objSubTypeJobTribute = 602
|
objSubTypeJobTribute = 602
|
||||||
objSubTypeJobStatus = 603
|
objSubTypeJobStatus = 603
|
||||||
@ -103,6 +104,7 @@ func fromChatWarsDate(d string) (t time.Time, err error) {
|
|||||||
log.Printf("fromChatWarsDate : Year : %s\n", r.ReplaceAllString(d, "${Year}"))
|
log.Printf("fromChatWarsDate : Year : %s\n", r.ReplaceAllString(d, "${Year}"))
|
||||||
log.Printf("fromChatWarsDate : Hour : %s\n", r.ReplaceAllString(d, "${Hour}"))
|
log.Printf("fromChatWarsDate : Hour : %s\n", r.ReplaceAllString(d, "${Hour}"))
|
||||||
log.Printf("fromChatWarsDate : Minute : %s\n", r.ReplaceAllString(d, "${Minute}"))
|
log.Printf("fromChatWarsDate : Minute : %s\n", r.ReplaceAllString(d, "${Minute}"))
|
||||||
|
|
||||||
return time.Now(), nil
|
return time.Now(), nil
|
||||||
} else {
|
} else {
|
||||||
return time.Now(), errors.New("Wrong format")
|
return time.Now(), errors.New("Wrong format")
|
||||||
|
6
sql.go
6
sql.go
@ -190,12 +190,14 @@ func initDB() {
|
|||||||
,(` + 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 acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
|
,(` + strconv.Itoa(objSubTypeMessagePillageAck) + `, "pillage_ack", "Pillage acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
,(` + strconv.Itoa(objSubTypeMessageTributeAck) + `, "tribute_ack", "Request acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
|
,(` + strconv.Itoa(objSubTypeMessageTributeAck) + `, "tribute_ack", "Request acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
,(` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "auction_announce", "Auction announce", ` + strconv.Itoa(objTypeMessage) + `);`)
|
,(` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "auction_announce", "Auction announce", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
|
,(` + strconv.Itoa(objSubTypeMessageTime) + `, "time", "Time", ` + 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, msg_type_id, descn, rule)
|
_, err = db.Exec(`INSERT INTO msg_rules (prio, msg_type_id, descn, rule)
|
||||||
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:.*)$")
|
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:.*)");`)
|
,(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:.*)")
|
||||||
|
,(5000, ` + strconv.Itoa(objSubtypeMessageTime) + `, "Time", "^In Chat Wars world now\\n(?P<Time>.*)\\n(?P<Hour>[0-9]{2}):(?P<Minute>[0-9]{2})\\n(?P<Day>[0-9]{2}) (?P<Month>[a-zA-Z]+) (?P<Year>[0-9]{4})\\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")
|
||||||
|
10
workers.go
10
workers.go
@ -110,6 +110,16 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : End : %s (%d)\n", r.ReplaceAllString(m.Text, "${End}"), objId)
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : End : %s (%d)\n", r.ReplaceAllString(m.Text, "${End}"), objId)
|
||||||
_, err := fromChatWarsDate(r.ReplaceAllString(m.Text, "${End}"))
|
_, err := fromChatWarsDate(r.ReplaceAllString(m.Text, "${End}"))
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : AuctionAnnounce : end")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : AuctionAnnounce : end")
|
||||||
|
case objSubTypeMessageTime:
|
||||||
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Time (%d)\n", objId)
|
||||||
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Time : %s (%d)\n", r.ReplaceAllString(m.Text, "${Time}"), objId)
|
||||||
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Hour : %s (%d)\n", r.ReplaceAllString(m.Text, "${Hour}"), objId)
|
||||||
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Minute : %s (%d)\n", r.ReplaceAllString(m.Text, "${Minute}"), objId)
|
||||||
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Day : %s (%d)\n", r.ReplaceAllString(m.Text, "${Day}"), objId)
|
||||||
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Month : %s (%d)\n", r.ReplaceAllString(m.Text, "${Month}"), objId)
|
||||||
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Year : %s (%d)\n", r.ReplaceAllString(m.Text, "${Year}"), objId)
|
||||||
|
_, err := fromChatWarsDate(r.ReplaceAllString(m.Text, "${Day}") + " " + r.ReplaceAllString(m.Text, "${Month}") + " " + r.ReplaceAllString(m.Text, "${Year}") + " " + r.ReplaceAllString(m.Text, "${Hour}") + ":" + r.ReplaceAllString(m.Text, "${Minute}"))
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : AuctionAnnounce : time")
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user