update client

This commit is contained in:
shoopea 2020-01-12 17:56:08 +08:00
parent 44762e03ea
commit 3fb623cc2b
3 changed files with 54 additions and 54 deletions

View File

@ -183,7 +183,6 @@ func clientMsgMeAck(m *ChatWarsMessageMeAck) {
if m.State == `🛌Rest` {
clt.CWIdle = true
}
log.Printf("clientMsgMeAck : Class : %s (%s)\n", clt.CWClass, clt.Login)
}
}
clt.Mux.Unlock()

62
msg.go
View File

@ -282,26 +282,24 @@ func parseSubTypeMessageMeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMe
i, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Level}"), 10, 64)
cwm.Level = i
log.Printf("parseSubTypeMessageReport : Class : %s\n", cwm.Class)
/*
log.Printf("parseSubTypeMessageReport : Me report identified\n")
log.Printf("parseSubTypeMessageReport : Castle : %s\n", r.ReplaceAllString(m.Text, "${Castle}"))
log.Printf("parseSubTypeMessageReport : Level : %s\n", r.ReplaceAllString(m.Text, "${Level}"))
log.Printf("parseSubTypeMessageReport : Atk : %s\n", r.ReplaceAllString(m.Text, "${Atk}"))
log.Printf("parseSubTypeMessageReport : Def : %s\n", r.ReplaceAllString(m.Text, "${Def}"))
log.Printf("parseSubTypeMessageReport : ExpNow : %s\n", r.ReplaceAllString(m.Text, "${ExpNow}"))
log.Printf("parseSubTypeMessageReport : ExpLvl : %s\n", r.ReplaceAllString(m.Text, "${ExpLvl}"))
log.Printf("parseSubTypeMessageReport : StaminaNow : %s\n", r.ReplaceAllString(m.Text, "${StaminaNow}"))
log.Printf("parseSubTypeMessageReport : StaminaMax : %s\n", r.ReplaceAllString(m.Text, "${StaminaMax}"))
log.Printf("parseSubTypeMessageReport : Gold : %s\n", r.ReplaceAllString(m.Text, "${Gold}"))
log.Printf("parseSubTypeMessageReport : Pogs : %s\n", r.ReplaceAllString(m.Text, "${Pogs}"))
log.Printf("parseSubTypeMessageReport : Gems : %s\n", r.ReplaceAllString(m.Text, "${Gems}"))
log.Printf("parseSubTypeMessageReport : AtkGear : %s\n", r.ReplaceAllString(m.Text, "${AtkGear}"))
log.Printf("parseSubTypeMessageReport : DefGear : %s\n", r.ReplaceAllString(m.Text, "${DefGear}"))
log.Printf("parseSubTypeMessageReport : BagUsed : %s\n", r.ReplaceAllString(m.Text, "${BagUsed}"))
log.Printf("parseSubTypeMessageReport : BagDispo : %s\n", r.ReplaceAllString(m.Text, "${BagDispo}"))
log.Printf("parseSubTypeMessageMeAck : Me report identified\n")
log.Printf("parseSubTypeMessageMeAck : Castle : %s\n", r.ReplaceAllString(m.Text, "${Castle}"))
log.Printf("parseSubTypeMessageMeAck : Level : %s\n", r.ReplaceAllString(m.Text, "${Level}"))
log.Printf("parseSubTypeMessageMeAck : Class : %s\n", cwm.Class)
log.Printf("parseSubTypeMessageMeAck : Atk : %s\n", r.ReplaceAllString(m.Text, "${Atk}"))
log.Printf("parseSubTypeMessageMeAck : Def : %s\n", r.ReplaceAllString(m.Text, "${Def}"))
log.Printf("parseSubTypeMessageMeAck : ExpNow : %s\n", r.ReplaceAllString(m.Text, "${ExpNow}"))
log.Printf("parseSubTypeMessageMeAck : ExpLvl : %s\n", r.ReplaceAllString(m.Text, "${ExpLvl}"))
log.Printf("parseSubTypeMessageMeAck : StaminaNow : %s\n", r.ReplaceAllString(m.Text, "${StaminaNow}"))
log.Printf("parseSubTypeMessageMeAck : StaminaMax : %s\n", r.ReplaceAllString(m.Text, "${StaminaMax}"))
log.Printf("parseSubTypeMessageMeAck : Gold : %s\n", r.ReplaceAllString(m.Text, "${Gold}"))
log.Printf("parseSubTypeMessageMeAck : Pogs : %s\n", r.ReplaceAllString(m.Text, "${Pogs}"))
log.Printf("parseSubTypeMessageMeAck : Gems : %s\n", r.ReplaceAllString(m.Text, "${Gems}"))
log.Printf("parseSubTypeMessageMeAck : AtkGear : %s\n", r.ReplaceAllString(m.Text, "${AtkGear}"))
log.Printf("parseSubTypeMessageMeAck : DefGear : %s\n", r.ReplaceAllString(m.Text, "${DefGear}"))
log.Printf("parseSubTypeMessageMeAck : BagUsed : %s\n", r.ReplaceAllString(m.Text, "${BagUsed}"))
log.Printf("parseSubTypeMessageMeAck : BagDispo : %s\n", r.ReplaceAllString(m.Text, "${BagDispo}"))
*/
cwm.Msg = m
return &cwm, nil
@ -392,19 +390,19 @@ func parseSubTypeMessageUnionWar(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWar
*/
cwm := ChatWarsMessageUnionWar{}
/*
log.Printf("parseSubTypeMessageReport : War report identified\n")
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 : User : %s\n", r.ReplaceAllString(m.Text, "${User}"))
log.Printf("parseSubTypeMessageReport : Attack : %s\n", r.ReplaceAllString(m.Text, "${Attack}"))
log.Printf("parseSubTypeMessageReport : AttackMod : %s\n", r.ReplaceAllString(m.Text, "${AttackMod}"))
log.Printf("parseSubTypeMessageReport : Defense : %s\n", r.ReplaceAllString(m.Text, "${Defense}"))
log.Printf("parseSubTypeMessageReport : Level : %s\n", r.ReplaceAllString(m.Text, "${Level}"))
log.Printf("parseSubTypeMessageReport : Exp : %s\n", r.ReplaceAllString(m.Text, "${Exp}"))
log.Printf("parseSubTypeMessageReport : Gold : %s\n", r.ReplaceAllString(m.Text, "${Gold}"))
log.Printf("parseSubTypeMessageReport : Stock : %s\n", r.ReplaceAllString(m.Text, "${Stock}"))
log.Printf("parseSubTypeMessageReport : Stamina : %s\n", r.ReplaceAllString(m.Text, "${Stamina}"))
log.Printf("parseSubTypeMessageReport : Crit : %s\n", r.ReplaceAllString(m.Text, "${Crit}"))
log.Printf("parseSubTypeMessageUnionWar : War report identified\n")
log.Printf("parseSubTypeMessageUnionWar : Castle : %s\n", r.ReplaceAllString(m.Text, "${Castle}"))
log.Printf("parseSubTypeMessageUnionWar : Guild : %s\n", r.ReplaceAllString(m.Text, "${Guild}"))
log.Printf("parseSubTypeMessageUnionWar : User : %s\n", r.ReplaceAllString(m.Text, "${User}"))
log.Printf("parseSubTypeMessageUnionWar : Attack : %s\n", r.ReplaceAllString(m.Text, "${Attack}"))
log.Printf("parseSubTypeMessageUnionWar : AttackMod : %s\n", r.ReplaceAllString(m.Text, "${AttackMod}"))
log.Printf("parseSubTypeMessageUnionWar : Defense : %s\n", r.ReplaceAllString(m.Text, "${Defense}"))
log.Printf("parseSubTypeMessageUnionWar : Level : %s\n", r.ReplaceAllString(m.Text, "${Level}"))
log.Printf("parseSubTypeMessageUnionWar : Exp : %s\n", r.ReplaceAllString(m.Text, "${Exp}"))
log.Printf("parseSubTypeMessageUnionWar : Gold : %s\n", r.ReplaceAllString(m.Text, "${Gold}"))
log.Printf("parseSubTypeMessageUnionWar : Stock : %s\n", r.ReplaceAllString(m.Text, "${Stock}"))
log.Printf("parseSubTypeMessageUnionWar : Stamina : %s\n", r.ReplaceAllString(m.Text, "${Stamina}"))
log.Printf("parseSubTypeMessageUnionWar : Crit : %s\n", r.ReplaceAllString(m.Text, "${Crit}"))
*/
return &cwm, nil
}

View File

@ -363,10 +363,10 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
case cacheObjSubType[`msg_withdraw_code`]:
case cacheObjSubType[`msg_withdraw_rcv`]:
cwm, err := parseSubTypeMessageWithdrawRcv(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_withdraw_rcv`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_withdraw_rcv`]")
for _, i := range cwm.ItemList {
err = insertMsgItem(cwm.Msg.ObjID64, i.ItemID64, i.Quantity)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Inserting cacheObjSubType[`msg_withdraw_rcv`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Inserting cacheObjSubType[`msg_withdraw_rcv`]")
}
case cacheObjSubType[`msg_stock_req`]:
case cacheObjSubType[`msg_misc_req`]:
@ -378,14 +378,14 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
case cacheObjSubType[`msg_gstock_oth_req`]:
case cacheObjSubType[`msg_gstock_any_ack`]:
_, err := parseSubTypeMessageGStockAnyAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_gstock_any_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_gstock_any_ack`]")
case cacheObjSubType[`msg_report_ack`]:
cwm, err := parseSubTypeMessageReportAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_report_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_report_ack`]")
cwm.ObjID64 = objId
case cacheObjSubType[`msg_quest_res_ambush`]:
cwm, err := parseSubTypeMessageQuestResultAmbush(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res_ambush`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res_ambush`]")
if m.Date.Add(3 * time.Minute).After(time.Now().UTC()) {
if m.ChatID64 == chtwrsbotID64 && m.TGSenderUserID64 == chtwrsbotID64 {
s := TGCommand{
@ -403,7 +403,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
}
case cacheObjSubType[`msg_pillage_inc`]:
cwm, err := parseSubTypeMessagePillageInc(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_pillage_inc`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_pillage_inc`]")
cwm.ObjID64 = objId
err = insertMsgPillageInc(cwm)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgPillageInc")
@ -425,13 +425,13 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
}
case cacheObjSubType[`msg_me_ack`]:
cwm, err := parseSubTypeMessageMeAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_me_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_me_ack`]")
clientMsgMeAck(cwm)
_, err = addObjXP(cwm.CWUserID64, cwm.ExpNow, cwm.ExpLvl, cwm.Level, m.Date)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : addObjXP(MeAck)")
case cacheObjSubType[`msg_go_quest_ack`]:
cwm, err := parseSubTypeMessageGoQuestAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_go_quest_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_go_quest_ack`]")
uid, err := clientGetCWUserID64(m.TGUserID64)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving UserID64.")
if err != nil {
@ -440,22 +440,23 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
clientMsgGoQuestAck(cwm)
_, err = addObjQuest(uid, cwm.QuestTypeID64, cwm.Duration, m.Date.UTC())
}
err = setClientBusy(m.TGUserID64, m.Date, cwm.Duration)
case cacheObjSubType[`msg_duel_fight`]:
cwm, err := parseSubTypeMessageDuelFight(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_duel_fight`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_duel_fight`]")
cwm.ObjID64 = objId
err = insertMsgDuelFight(cwm)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgDuelFight")
case cacheObjSubType[`msg_union_war`]:
_, err := parseSubTypeMessageUnionWar(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_union_war`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_union_war`]")
case cacheObjSubType[`msg_groles_ack`]:
cwm, err := parseSubTypeMessageGRolesAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_groles_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_groles_ack`]")
clientMsgGRolesAck(cwm)
case cacheObjSubType[`msg_auction_announce`]:
cwm, err := parseSubTypeMessageAuctionAnnounce(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_auction_announce`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_auction_announce`]")
cwm.ObjID64 = objId
err = insertMsgAuctionAnnounce(cwm)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgAuctionAnnounce")
@ -474,30 +475,32 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
}
case cacheObjSubType[`msg_time_ack`]:
_, err := parseSubTypeMessageTimeAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_time_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_time_ack`]")
case cacheObjSubType[`msg_orderbook_acl`]:
_, err := parseSubTypeMessageOrderbookAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_orderbook_acl`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_orderbook_acl`]")
case cacheObjSubType[`msg_stock_ack`]:
_, err := parseSubTypeMessageStockAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_stock_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_stock_ack`]")
case cacheObjSubType[`msg_g_deposit_req`]:
_, err := parseSubTypeMessageGDepositReq(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_g_deposit_req`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_g_deposit_req`]")
case cacheObjSubType[`msg_g_deposit_ack`]:
cwm, err := parseSubTypeMessageGDepositAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_g_deposit_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_g_deposit_ack`]")
err = insertMsgItem(cwm.Msg.ObjID64, cwm.ItemID64, cwm.Quantity)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Inserting cacheObjSubType[`msg_g_deposit_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Inserting cacheObjSubType[`msg_g_deposit_ack`]")
case cacheObjSubType[`msg_stock_any_ack`]:
_, err := parseSubTypeMessageStockAnyAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_stock_any_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_stock_any_ack`]")
case cacheObjSubType[`msg_exchange_ack`]:
_, err := parseSubTypeMessageExchangeAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_exchange_ack`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_exchange_ack`]")
case cacheObjSubType[`msg_quest_res`]:
_, err := parseSubTypeMessageQuestResult(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res`].")
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res`]")
err = setClientIdle(m.TGUserID64, m.Date)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setClientIdle")
default:
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID64, objId, m.Text)
}