test
This commit is contained in:
parent
8250b02970
commit
da9a8a07a8
4
def.go
4
def.go
@ -40,7 +40,7 @@ type ChatWarsMessage struct {
|
|||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChatWarsMessageReport struct {
|
type ChatWarsMessageReportAck struct {
|
||||||
ObjID64 int64 `json:"obj_id"`
|
ObjID64 int64 `json:"obj_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ const (
|
|||||||
objSubTypeMessageMiniWar = 303 // from Chat Wars Mini Reports (done)
|
objSubTypeMessageMiniWar = 303 // from Chat Wars Mini Reports (done)
|
||||||
objSubTypeMessageGuildWar = 304 // from Chat Wars Reports (not done)
|
objSubTypeMessageGuildWar = 304 // from Chat Wars Reports (not done)
|
||||||
objSubTypeMessageReportReq = 305 // /report (done)
|
objSubTypeMessageReportReq = 305 // /report (done)
|
||||||
objSubTypeMessageReportAck = 306 // result from /report (not done)
|
objSubTypeMessageReportAck = 306 // result from /report (done)
|
||||||
objSubTypeMessageGReportReq = 307 // /g_report (done)
|
objSubTypeMessageGReportReq = 307 // /g_report (done)
|
||||||
objSubTypeMessageGReportAck = 308 // result from /g_report (not done)
|
objSubTypeMessageGReportAck = 308 // result from /g_report (not done)
|
||||||
objSubTypeMessageQuestResult = 309 // result from going to quest (not done)
|
objSubTypeMessageQuestResult = 309 // result from going to quest (not done)
|
||||||
|
4
msg.go
4
msg.go
@ -8,8 +8,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseSubTypeMessageReport(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageReport, error) {
|
func parseSubTypeMessageReportAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageReportAck, error) {
|
||||||
cwm := ChatWarsMessageReport{}
|
cwm := ChatWarsMessageReportAck{}
|
||||||
log.Printf("parseSubTypeMessageReport : War report identified\n")
|
log.Printf("parseSubTypeMessageReport : War report identified\n")
|
||||||
log.Printf("parseSubTypeMessageReport : Castle : %s\n", r.ReplaceAllString(m.Text, "${Castle}"))
|
log.Printf("parseSubTypeMessageReport : Castle : %s\n", r.ReplaceAllString(m.Text, "${Castle}"))
|
||||||
log.Printf("parseSubTypeMessageReport : Guild : %s\n", r.ReplaceAllString(m.Text, "${Guild}"))
|
log.Printf("parseSubTypeMessageReport : Guild : %s\n", r.ReplaceAllString(m.Text, "${Guild}"))
|
||||||
|
2
rules.go
2
rules.go
@ -9,7 +9,7 @@ func resetMsgParsingRules() {
|
|||||||
failOnError(err, "resetMsgParsingRules : truncate table msg_rules")
|
failOnError(err, "resetMsgParsingRules : truncate table msg_rules")
|
||||||
|
|
||||||
_, 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-Z0-9]{1,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){0,1}(💰Gold: (?P<Gold>\\-{0,1}[0-9]+)\\n){0,1}(📦Stock: (?P<Stock>\\-{0,1}[0-9]+)){0,1}(\\n(?P<Stamina>(🔋Stamina restored))){0,1}(\\n(?P<Crit>(⚡Critical strike))){0,1}$")
|
VALUES (5000, ` + strconv.Itoa(objSubTypeMessageReportAck) + `, "Player war report", "^(?P<Castle>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild>[A-Z0-9]{1,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){0,1}(💰Gold: (?P<Gold>\\-{0,1}[0-9]+)\\n){0,1}(📦Stock: (?P<Stock>\\-{0,1}[0-9]+)){0,1}(\\n(?P<Stamina>(🔋Stamina restored))){0,1}(\\n(?P<Crit>(⚡Critical strike))){0,1}$")
|
||||||
,(5000, ` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "Auction annouce", "^Lot #(?P<Lot>[0-9]+) : (?P<Item>.*)\\n(Quality: (?P<Quality>.*)\\n){0,1}(Condition: (?P<Cond>.*)\\n){0,1}Seller: (?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>.*)\\n(Quality: (?P<Quality>.*)\\n){0,1}(Condition: (?P<Cond>.*)\\n){0,1}Seller: (?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(objSubTypeMessageTimeAck) + `, "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>.+) (?P<Year>[0-9]{4})\\n(?s:.*)$")` +
|
,(5000, ` + strconv.Itoa(objSubTypeMessageTimeAck) + `, "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>.+) (?P<Year>[0-9]{4})\\n(?s:.*)$")` +
|
||||||
`,(5000, ` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "Mini War", "^⛳️Battle results:\\n` +
|
`,(5000, ` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "Mini War", "^⛳️Battle results:\\n` +
|
||||||
|
@ -88,10 +88,12 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
} else {
|
} else {
|
||||||
r := msgParsingRules[i].re
|
r := msgParsingRules[i].re
|
||||||
switch msgParsingRules[i].MsgTypeID {
|
switch msgParsingRules[i].MsgTypeID {
|
||||||
case objSubTypeMessageReport:
|
case objSubTypeMessageReportAck:
|
||||||
cwm, err := parseSubTypeMessageReport(m, r)
|
cwm, err := parseSubTypeMessageReport(m, r)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageReport.")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageReportAck.")
|
||||||
cwm.ObjID64 = objId
|
cwm.ObjID64 = objId
|
||||||
|
err = setObjSubTypeId(objId, objSubTypeMessageReportAck)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(ReportAck)")
|
||||||
case objSubTypeMessageMiniWar:
|
case objSubTypeMessageMiniWar:
|
||||||
cwm, err := parseSubTypeMessageMiniWar(m, r)
|
cwm, err := parseSubTypeMessageMiniWar(m, r)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageMiniWar.")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageMiniWar.")
|
||||||
@ -171,6 +173,9 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
case objSubTypeMessageGoQuest:
|
case objSubTypeMessageGoQuest:
|
||||||
err = setObjSubTypeId(objId, objSubTypeMessageGoQuest)
|
err = setObjSubTypeId(objId, objSubTypeMessageGoQuest)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(GoQuest)")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(GoQuest)")
|
||||||
|
case objSubTypeMessageGoFastFight:
|
||||||
|
err = setObjSubTypeId(objId, objSubTypeMessageGoFastFight)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(GoFastFight)")
|
||||||
case objSubTypeMessageArena:
|
case objSubTypeMessageArena:
|
||||||
err = setObjSubTypeId(objId, objSubTypeMessageArena)
|
err = setObjSubTypeId(objId, objSubTypeMessageArena)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Arena)")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Arena)")
|
||||||
|
Loading…
Reference in New Issue
Block a user