This commit is contained in:
shoopea 2019-05-18 22:15:24 +08:00
parent a204f36c65
commit ef2b2dd117
4 changed files with 35 additions and 6 deletions

4
def.go
View File

@ -44,6 +44,10 @@ type ChatWarsMessageReport struct {
ObjID64 int64 `json:"obj_id"`
}
type ChatWarsMessageDuelFight struct {
ObjID64 int64 `json:"obj_id"`
}
type ChatWarsMessageAuctionAnnounce struct {
ObjID64 int64 `json:"obj_id"`
LotID int32 `json:"lot_id"`

21
msg.go
View File

@ -27,6 +27,27 @@ func parseSubTypeMessageReport(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsM
return &cwm, nil
}
func parseSubTypeMessageReport(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageReport, error) {
cwm := ChatWarsMessageDuelFight{}
log.Printf("parseSubTypeMessageReport : Duel fight identified\n")
log.Printf("parseSubTypeMessageReport : Castle1 : %s\n", r.ReplaceAllString(m.Text, "${Castle1}"))
log.Printf("parseSubTypeMessageReport : Guild1 : %s\n", r.ReplaceAllString(m.Text, "${Guild1}"))
log.Printf("parseSubTypeMessageReport : Duelist1 : %s\n", r.ReplaceAllString(m.Text, "${Duelist1}"))
log.Printf("parseSubTypeMessageReport : Life1 : %s\n", r.ReplaceAllString(m.Text, "${Life1}"))
log.Printf("parseSubTypeMessageReport : Castle2 : %s\n", r.ReplaceAllString(m.Text, "${Castle2}"))
log.Printf("parseSubTypeMessageReport : Guild2 : %s\n", r.ReplaceAllString(m.Text, "${Guild2}"))
log.Printf("parseSubTypeMessageReport : Duelist2 : %s\n", r.ReplaceAllString(m.Text, "${Duelist2}"))
log.Printf("parseSubTypeMessageReport : Life2 : %s\n", r.ReplaceAllString(m.Text, "${Life2}"))
log.Printf("parseSubTypeMessageReport : WinCastle : %s\n", r.ReplaceAllString(m.Text, "${WinCastle}"))
log.Printf("parseSubTypeMessageReport : WinGuild : %s\n", r.ReplaceAllString(m.Text, "${WinGuild}"))
log.Printf("parseSubTypeMessageReport : WinDuelist : %s\n", r.ReplaceAllString(m.Text, "${WinDuelist}"))
log.Printf("parseSubTypeMessageReport : LossCastle : %s\n", r.ReplaceAllString(m.Text, "${LossCastle}"))
log.Printf("parseSubTypeMessageReport : LossGuild : %s\n", r.ReplaceAllString(m.Text, "${LossGuild}"))
log.Printf("parseSubTypeMessageReport : LossDuelist : %s\n", r.ReplaceAllString(m.Text, "${LossDuelist}"))
return &cwm, nil
}
func parseSubTypeMessageMiniWar(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageMiniWar, error) {
t, err := time.Parse("02/01/06 15:04", r.ReplaceAllString(m.Text, "${Time}"))
logOnError(err, "parseSubTypeMessageMiniWar : parsing time : "+r.ReplaceAllString(m.Text, "${Time}"))

1
sql.go
View File

@ -1345,6 +1345,7 @@ func resetMsgParsingRules() {
`(?P<Life2>(\\-){0,1}[0-9]+).*(?P<Castle2>[🐉🦅🐺🦈🦌🥔🌑]).*(\\[(?P<Guild2>[A-Z0-9]{1,3})\\]){0,1}(?P<Duelist2>.*)\\n` +
`(?s:.*)` +
`(\\[(?P<WinGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<WinDuelist>.*) from .*(?P<WinCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle stands victorious over (\\[(?P<LossGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<LossDuelist>.*) from .*(?P<LossCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle, with blood slowly dripping from his weapon.\\n` +
`You received: (?P<Exp>[0-9]+) exp.\\n` +
`(?s:.*)$")
;`)
failOnError(err, "resetMsgParsingRules : populate table msg_rules")

View File

@ -102,7 +102,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(MiniWar)")
case objSubTypeMessagePillageInc:
cwm, err := parseSubTypeMessagePillageInc(m, r)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageMiniWar.")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessagePillageInc.")
cwm.ObjID64 = objId
err = insertMsgPillageInc(cwm)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgPillageInc")
@ -145,19 +145,22 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
err = setObjSubTypeId(objId, objSubTypeMessageQuest)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Quest)")
case objSubTypeMessageGoQuest:
err = setObjSubTypeId(objId, objSubTypeMessageQuest)
err = setObjSubTypeId(objId, objSubTypeMessageGoQuest)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(GoQuest)")
case objSubTypeMessageArena:
err = setObjSubTypeId(objId, objSubTypeMessageQuest)
cwm, err := parseSubTypeMessageArena(m, r)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageArena.")
cwm.ObjID64 = objId
err = setObjSubTypeId(objId, objSubTypeMessageArena)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Arena)")
case objSubTypeMessageGoArena:
err = setObjSubTypeId(objId, objSubTypeMessageQuest)
err = setObjSubTypeId(objId, objSubTypeMessageGoArena)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(GoArena)")
case objSubTypeMessageTop:
err = setObjSubTypeId(objId, objSubTypeMessageQuest)
err = setObjSubTypeId(objId, objSubTypeMessageTop)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Top)")
case objSubTypeMessageMenu:
err = setObjSubTypeId(objId, objSubTypeMessageQuest)
err = setObjSubTypeId(objId, objSubTypeMessageMenu)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Menu)")
case objSubTypeMessageAuctionAnnounce:
cwm := ChatWarsMessageAuctionAnnounce{