test
This commit is contained in:
parent
f7120953f3
commit
05a8dd4fe8
10
def.go
10
def.go
@ -130,11 +130,15 @@ type ChatWarsMessageDuelFight struct {
|
||||
type ChatWarsMessageAuctionAnnounce struct {
|
||||
ObjID64 int64 `json:"obj_id"`
|
||||
LotID int32 `json:"lot_id"`
|
||||
Item string `json:"item"`
|
||||
ItemID64 int64 `json:"item_id"`
|
||||
Cond string `json:"cond"`
|
||||
Quality string `json:"quality"`
|
||||
Seller string `json:"seller"`
|
||||
Buyer string `json:"buyer"`
|
||||
SellerID64 int64 `json:"seller_id"`
|
||||
SellerGuildID64 int64 `json:"seller_guild_id"`
|
||||
SellerCastleID64 int64 `json:"seller_castle_id"`
|
||||
BuyerID64 int64 `json:"buyer_id"`
|
||||
BuyerGuildID64 int64 `json:"buyer_guild_id"`
|
||||
BuyerCastleID64 int64 `json:"buyer_castle_id"`
|
||||
Price int32 `json:"price"`
|
||||
Status string `json:"status"`
|
||||
End time.Time `json:"end"`
|
||||
|
21
msg.go
21
msg.go
@ -30,6 +30,27 @@ func parseSubTypeMessageReportAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWa
|
||||
return &cwm, nil
|
||||
}
|
||||
|
||||
func parseSubTypeMessageAuctionAnnounce(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageAuctionAnnounce, error) {
|
||||
cwm := ChatWarsMessageAuctionAnnounce{}
|
||||
|
||||
l, _ := strconv.ParseInt(r.ReplaceAllString(m.Text, "${Lot}"), 10, 32)
|
||||
cwm.LotID = int32(l)
|
||||
cwm.ItemID64 = getObjItemID(r.ReplaceAllString(m.Text, "${Item}"))
|
||||
cwm.Cond = r.ReplaceAllString(m.Text, "${Cond}")
|
||||
cwm.Quality = r.ReplaceAllString(m.Text, "${Quality}")
|
||||
cwm.SellerUserID64 = getObjUserID(r.ReplaceAllString(m.Text, "${SellerUser}"))
|
||||
cwm.SellerGuildID64 = getObjUserID(r.ReplaceAllString(m.Text, "${SellerGuild}"))
|
||||
cwm.SellerCastleID64 = getObjUserID(r.ReplaceAllString(m.Text, "${SellerCastle}"))
|
||||
cwm.BuyerUserID64 = getObjUserID(r.ReplaceAllString(m.Text, "${BuyerUser}"))
|
||||
cwm.BuyerGuildID64 = getObjUserID(r.ReplaceAllString(m.Text, "${BuyerGuild}"))
|
||||
cwm.BuyerCastleID64 = getObjUserID(r.ReplaceAllString(m.Text, "${BuyerCastle}"))
|
||||
p, _ := strconv.ParseInt(r.ReplaceAllString(m.Text, "${Price}"), 10, 32)
|
||||
cwm.Price = int32(p)
|
||||
cwm.Status = r.ReplaceAllString(m.Text, "${Status}")
|
||||
cwm.End, _ = fromChatWarsDate(r.ReplaceAllString(m.Text, "${End}"))
|
||||
return cwm, nil
|
||||
}
|
||||
|
||||
func parseSubTypeMessageGStockAnyAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageStock, error) {
|
||||
cwm := ChatWarsMessageStock{}
|
||||
items := []ChatWarsItems{}
|
||||
|
2
rules.go
2
rules.go
@ -10,7 +10,7 @@ func resetMsgParsingRules() {
|
||||
|
||||
_, err = db.Exec(`INSERT INTO msg_rules (prio, msg_type_id, descn, rule)
|
||||
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<SellerCastle>[🐉🦅🐺🦈🦌🥔🌑])( ){0,1})(\\[(?P<SellerGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<SellerUser>.*)\\nCurrent price: (?P<Price>[0-9]+) pouch\\(es\\)\\nBuyer: (?P<BuyerCastle>[🐉🦅🐺🦈🦌🥔🌑])( ){0,1})(\\[(?P<BuyerGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<BuyerUser>.*)\\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(objSubTypeMessageMiniWar) + `, "Mini War", "^⛳️Battle results:\\n` +
|
||||
`(?P<Gardian1>🔱){0,1}.*(?P<Loot1>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result1>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold1>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock1>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
|
||||
|
14
sql.go
14
sql.go
@ -172,8 +172,12 @@ func initDB() {
|
||||
,item VARCHAR(80)
|
||||
,cond VARCHAR(32)
|
||||
,quality VARCHAR(32)
|
||||
,seller VARCHAR(32)
|
||||
,buyer VARCHAR(32)
|
||||
,seller_castle_id BIGINT UNSIGNED
|
||||
,seller_guild_id BIGINT UNSIGNED
|
||||
,seller_id BIGINT UNSIGNED
|
||||
,buyer_castle_id BIGINT UNSIGNED
|
||||
,buyer_guild_id BIGINT UNSIGNED
|
||||
,buyer_id BIGINT UNSIGNED
|
||||
,price SMALLINT NOT NULL
|
||||
,status VARCHAR(32)
|
||||
,end DATETIME NOT NULL
|
||||
@ -517,14 +521,14 @@ func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error {
|
||||
return errors.New("Message type mismatch")
|
||||
}
|
||||
|
||||
stmt, err := db.Prepare(`INSERT INTO obj_msg_auction_announce (obj_id, lot_id, item, cond, quality, seller, buyer, price, status, end)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`)
|
||||
stmt, err := db.Prepare(`INSERT INTO obj_msg_auction_announce (obj_id, lot_id, item, cond, quality, seller_id, seller_guild_id, seller_castle_id, buyer_id, buyer_guild_id, buyer_castle_id, price, status, end)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
_, err = stmt.Exec(m.ObjID64, m.LotID, m.Item, m.Cond, m.Quality, m.Seller, m.Buyer, m.Price, m.Status, m.End)
|
||||
_, err = stmt.Exec(m.ObjID64, m.LotID, m.Item, m.Cond, m.Quality, m.SellerUserID64, m.SellerGuildID64, m.SellerCastleID64, m.BuyerUserID64, m.BuyerGuildID64, m.BuyerCastleID64, m.Price, m.Status, m.End)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
18
workers.go
18
workers.go
@ -169,7 +169,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageDuelFight.")
|
||||
cwm.ObjID64 = objId
|
||||
err = insertMsgDuelFight(cwm)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgAuctionAnnounce")
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgDuelFight")
|
||||
case objSubTypeMessageUnionWar:
|
||||
_, err := parseSubTypeMessageUnionWar(m, r)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageUnionWar.")
|
||||
@ -179,20 +179,8 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
cwm.Msg = m
|
||||
clientMsgGRolesAck(cwm)
|
||||
case objSubTypeMessageAuctionAnnounce:
|
||||
cwm := ChatWarsMessageAuctionAnnounce{
|
||||
ObjID64: objId,
|
||||
}
|
||||
l, _ := strconv.ParseInt(r.ReplaceAllString(m.Text, "${Lot}"), 10, 32)
|
||||
cwm.LotID = int32(l)
|
||||
cwm.Item = r.ReplaceAllString(m.Text, "${Item}")
|
||||
cwm.Cond = r.ReplaceAllString(m.Text, "${Cond}")
|
||||
cwm.Quality = r.ReplaceAllString(m.Text, "${Quality}")
|
||||
cwm.Seller = r.ReplaceAllString(m.Text, "${Seller}")
|
||||
cwm.Buyer = r.ReplaceAllString(m.Text, "${Buyer}")
|
||||
p, _ := strconv.ParseInt(r.ReplaceAllString(m.Text, "${Price}"), 10, 32)
|
||||
cwm.Price = int32(p)
|
||||
cwm.Status = r.ReplaceAllString(m.Text, "${Status}")
|
||||
cwm.End, _ = fromChatWarsDate(r.ReplaceAllString(m.Text, "${End}"))
|
||||
cwm, err := parseSubTypeMessageAuctionAnnounce(m, r)
|
||||
logOonError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageAuctionAnnounce.")
|
||||
err = insertMsgAuctionAnnounce(&cwm)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgAuctionAnnounce")
|
||||
case objSubTypeMessageTimeAck:
|
||||
|
Loading…
Reference in New Issue
Block a user