From 05a8dd4fe8a2eac31284fda100c95549cc1bac9c Mon Sep 17 00:00:00 2001 From: shoopea Date: Thu, 6 Jun 2019 13:52:22 +0800 Subject: [PATCH] test --- def.go | 24 ++++++++++++++---------- msg.go | 21 +++++++++++++++++++++ rules.go | 2 +- sql.go | 30 +++++++++++++++++------------- workers.go | 18 +++--------------- 5 files changed, 56 insertions(+), 39 deletions(-) diff --git a/def.go b/def.go index 1082db3..54c561f 100644 --- a/def.go +++ b/def.go @@ -128,16 +128,20 @@ type ChatWarsMessageDuelFight struct { } type ChatWarsMessageAuctionAnnounce struct { - ObjID64 int64 `json:"obj_id"` - LotID int32 `json:"lot_id"` - Item string `json:"item"` - Cond string `json:"cond"` - Quality string `json:"quality"` - Seller string `json:"seller"` - Buyer string `json:"buyer"` - Price int32 `json:"price"` - Status string `json:"status"` - End time.Time `json:"end"` + ObjID64 int64 `json:"obj_id"` + LotID int32 `json:"lot_id"` + ItemID64 int64 `json:"item_id"` + Cond string `json:"cond"` + Quality string `json:"quality"` + 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"` } type ChatWarsMessagePillageInc struct { diff --git a/msg.go b/msg.go index c338af7..b8bd28b 100644 --- a/msg.go +++ b/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{} diff --git a/rules.go b/rules.go index d47ecbd..357176c 100644 --- a/rules.go +++ b/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[๐Ÿ‰๐Ÿฆ…๐Ÿบ๐Ÿฆˆ๐ŸฆŒ๐Ÿฅ”๐ŸŒ‘])(\\[(?P[A-Z0-9]{1,3})\\]){0,1}(?P([A-Za-z0-9 ]*)) โš”:(?P[0-9]+)(?P\\((-|\\+)[0-9]+\\)){0,1} ๐Ÿ›ก:(?P[0-9]+) Lvl: (?P[0-9]+)\\nYour result on the battlefield:\\n(๐Ÿ”ฅExp: (?P[0-9]+)\\n){0,1}(๐Ÿ’ฐGold: (?P\\-{0,1}[0-9]+)\\n){0,1}(๐Ÿ“ฆStock: (?P\\-{0,1}[0-9]+)){0,1}(\\n(?P(๐Ÿ”‹Stamina restored))){0,1}(\\n(?P(โšกCritical strike))){0,1}$") - ,(5000, ` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "Auction annouce", "^Lot #(?P[0-9]+) : (?P.*)\\n(Quality: (?P.*)\\n){0,1}(Condition: (?P.*)\\n){0,1}Seller: (?P.*)\\nCurrent price: (?P[0-9]+) pouch\\(es\\)\\nBuyer: (?P.*)\\nEnd At: (?P.*)\\nStatus: (?P.*)(\\n)*(?s:.*)") + ,(5000, ` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "Auction annouce", "^Lot #(?P[0-9]+) : (?P.*)\\n(Quality: (?P.*)\\n){0,1}(Condition: (?P.*)\\n){0,1}Seller: (?P[๐Ÿ‰๐Ÿฆ…๐Ÿบ๐Ÿฆˆ๐ŸฆŒ๐Ÿฅ”๐ŸŒ‘])( ){0,1})(\\[(?P[A-Z0-9]{1,3})\\]){0,1}(?P.*)\\nCurrent price: (?P[0-9]+) pouch\\(es\\)\\nBuyer: (?P[๐Ÿ‰๐Ÿฆ…๐Ÿบ๐Ÿฆˆ๐ŸฆŒ๐Ÿฅ”๐ŸŒ‘])( ){0,1})(\\[(?P[A-Z0-9]{1,3})\\]){0,1}(?P.*)\\nEnd At: (?P.*)\\nStatus: (?P.*)(\\n)*(?s:.*)") ,(5000, ` + strconv.Itoa(objSubTypeMessageTimeAck) + `, "Time", "^In Chat Wars world now\\n(?P