diff --git a/def.go b/def.go index 92421e8..8e59eed 100644 --- a/def.go +++ b/def.go @@ -1,5 +1,9 @@ package main +import ( + "regexp" +) + type ChatWarsMessage struct { UserID64 int64 `json:"user_id"` SenderUserID64 int64 `json:"sender_user_id"` @@ -15,6 +19,7 @@ type MessageParsingRule struct { Description string Rule string MsgTypeID int32 + re *regexp.Regexp } const ( diff --git a/workers.go b/workers.go index 986a228..eced4f0 100644 --- a/workers.go +++ b/workers.go @@ -3,7 +3,6 @@ package main import ( "encoding/json" "log" - "regexp" "strconv" "time" @@ -78,8 +77,6 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) { logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving message.") if err == nil { log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Message retrieved (%d)\n%s\n", objId, m.Text) - // War reports - // r := regexp.MustCompile(`^(?P.)(?P(\[[A-Z]{3}\]){0,1})(?P([A-Za-z0-9 ]*)) ⚔:(?P[0-9]+) .:(?P[0-9]+) Lvl: (?P[0-9]+)\nYour result on the battlefield:\n.Exp: (?P[0-9]+)\n.Gold: (?P[0-9]+)\n.Stock: (?P[0-9]+)\n(?s:.*)$`) // FIXME defense/exp/gold/stock characters ! for i = 0; i < len(msgParsingRules) && msgParsingRules[i].re.FindStringSubmatch(m.Text) != nil; i++ { }