diff --git a/def.go b/def.go index 3e15789..12dafbf 100644 --- a/def.go +++ b/def.go @@ -38,6 +38,13 @@ type ChatWarsMessageAuctionAnnounce struct { End time.Time `json:"end"` } +type ChatWarsMessagePillageInc struct { + ObjID64 int64 `json:"obj_id"` + Attacker string `json:"attacker"` + Guild string `json:"guild"` + Castle string `json:"castle"` +} + type ChatWarsMessageMiniWar struct { ObjID64 int64 `json:"obj_id"` Report map[string]*ChatWarsMessageMiniWarCastle `json:"castle"` diff --git a/msg.go b/msg.go index 5375b5f..4604661 100644 --- a/msg.go +++ b/msg.go @@ -36,3 +36,12 @@ func parseSubTypeMessageMiniWar(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWars return &cwm, err } + +func parseSubTypeMessagePillageInc(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessagePillageInc, error) { + cwm := ChatWarsMessagePillageInc{} + cwm.Attacker = r.ReplaceAllString(m.Text, "${Attacker}") + cwm.Castle = r.ReplaceAllString(m.Text, "${Castle}") + cwm.Guild = r.ReplaceAllString(m.Text, "${Guild}") + + return &cwm, nil +} diff --git a/sql.go b/sql.go index e4f56b0..d3f7e17 100644 --- a/sql.go +++ b/sql.go @@ -134,6 +134,17 @@ func initDB() { failOnError(err, "initDB : create table obj_msg") log.Println("initDB : obj_msg created ...") + _, err = db.Exec(`CREATE TABLE obj_msg_pillage_inc ( + obj_id BIGINT UNSIGNED NOT NULL + ,attacker VARCHAR(32) + ,guild VARCHAR(32) + ,castle_id SMALLINT UNSIGNED NOT NULL + ,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE + ,FOREIGN KEY (castle_id) REFERENCES code_obj_castle(id) ON DELETE CASCADE + ) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`) + failOnError(err, "initDB : create table obj_msg_report") + log.Println("initDB : obj_msg_report created ...") + _, err = db.Exec(`CREATE TABLE obj_msg_report ( obj_id BIGINT UNSIGNED NOT NULL ,war_id BIGINT UNSIGNED NOT NULL @@ -1305,7 +1316,7 @@ func resetMsgParsingRules() { `.*(?P(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P\\+([0-9]+|NaN))\\n` + `(?s:.*)` + `Battle (?P