upd test
This commit is contained in:
parent
b91ed6f98a
commit
d2db3b9d1d
42
def.go
42
def.go
@ -9,27 +9,45 @@ type ChatWarsMessage struct {
|
|||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MessageParsingRule struct {
|
||||||
|
ID int32
|
||||||
|
Priority int32
|
||||||
|
Description string
|
||||||
|
Rule string
|
||||||
|
MsgTypeID int32
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
objTypeUser = 1
|
objTypeUser = 1
|
||||||
objTypeGuild = 2
|
objTypeGuild = 2
|
||||||
objTypeMessage = 3
|
objTypeMessage = 3
|
||||||
objTypeWar = 4
|
objTypeWar = 4
|
||||||
objTypeWarReport = 5
|
objTypeWarReport = 5
|
||||||
|
objTypeJob = 6
|
||||||
|
|
||||||
objSubTypeMessageUnprocess = 1
|
objSubTypeMessageUnknown = 301
|
||||||
objSubTypeMessageUnknown = 2
|
objSubTypeMessageWar = 302
|
||||||
objSubTypeMessageWar = 3
|
objSubTypeMessageMiniWar = 303
|
||||||
objSubTypeMessageMiniWar = 4
|
objSubTypeMessageGuildWar = 304
|
||||||
objSubTypeMessageGuildWar = 5
|
objSubTypeMessageReport = 305
|
||||||
objSubTypeMessageReport = 6
|
objSubTypeMessageGReport = 306
|
||||||
objSubTypeMessageGReport = 7
|
objSubTypeMessageQuest = 307
|
||||||
objSubTypeMessageQuest = 8
|
objSubTypeMessageFight = 308
|
||||||
objSubTypeMessageFight = 9
|
objSubTypeMessageHero = 309
|
||||||
objSubTypeMessageHero = 10
|
objSubTypeMessageMe = 310
|
||||||
objSubTypeMessageMe = 11
|
objSubTypeMessageInventory = 311
|
||||||
objSubTypeMessageInventory = 12
|
objSubTypeMessagePillageInc = 312
|
||||||
|
objSubTypeMessageTributeInc = 313
|
||||||
|
objSubTypeMessagePillageAck = 314
|
||||||
|
objSubTypeMessageTributeAck = 315
|
||||||
|
objSubTypeJobPillage = 601
|
||||||
|
objSubTypeJobTribute = 602
|
||||||
|
objSubTypeJobStatus = 603
|
||||||
|
objSubTypeJobWithdrawal = 604
|
||||||
|
objSubTypeJobGStock = 605
|
||||||
|
|
||||||
MQGetMsgWorkers = 3
|
MQGetMsgWorkers = 3
|
||||||
SQLCWMsgWorkers = 6
|
SQLCWMsgWorkers = 6
|
||||||
SQLIdentifyMsgWorkers = 6
|
SQLIdentifyMsgWorkers = 6
|
||||||
|
SQLJobWorkers = 3
|
||||||
)
|
)
|
||||||
|
30
sql.go
30
sql.go
@ -42,7 +42,7 @@ func initDB() {
|
|||||||
log.Println("Database cleaned up")
|
log.Println("Database cleaned up")
|
||||||
|
|
||||||
_, err = db.Exec(`CREATE TABLE code_obj_type (
|
_, err = db.Exec(`CREATE TABLE code_obj_type (
|
||||||
id SMALLINT(5) UNSIGNED NOT NULL
|
id SMALLINT UNSIGNED NOT NULL
|
||||||
,intl_id VARCHAR(32) NOT NULL
|
,intl_id VARCHAR(32) NOT NULL
|
||||||
,name VARCHAR(80) NOT NULL
|
,name VARCHAR(80) NOT NULL
|
||||||
,PRIMARY KEY (id)
|
,PRIMARY KEY (id)
|
||||||
@ -50,7 +50,7 @@ func initDB() {
|
|||||||
failOnError(err, "initDB : create table code_obj_type")
|
failOnError(err, "initDB : create table code_obj_type")
|
||||||
|
|
||||||
_, err = db.Exec(`CREATE TABLE code_obj_sub_type (
|
_, err = db.Exec(`CREATE TABLE code_obj_sub_type (
|
||||||
id SMALLINT(5) UNSIGNED NOT NULL
|
id SMALLINT UNSIGNED NOT NULL
|
||||||
,intl_id VARCHAR(32) NOT NULL
|
,intl_id VARCHAR(32) NOT NULL
|
||||||
,name VARCHAR(80) NOT NULL
|
,name VARCHAR(80) NOT NULL
|
||||||
,obj_type_id SMALLINT UNSIGNED NOT NULL
|
,obj_type_id SMALLINT UNSIGNED NOT NULL
|
||||||
@ -64,6 +64,8 @@ func initDB() {
|
|||||||
,obj_type_id SMALLINT UNSIGNED NOT NULL
|
,obj_type_id SMALLINT UNSIGNED NOT NULL
|
||||||
,obj_sub_type_id SMALLINT UNSIGNED NOT NULL
|
,obj_sub_type_id SMALLINT UNSIGNED NOT NULL
|
||||||
,PRIMARY KEY (id)
|
,PRIMARY KEY (id)
|
||||||
|
,FOREIGN KEY (obj_type_id) REFERENCSE code_obj_type(id) ON DELETE CASCADE
|
||||||
|
,FOREIGN KEY (obj_sub_type_id) REFERENCSE code_obj_sub_type(id) ON DELETE CASCADE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
|
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
|
||||||
failOnError(err, "initDB : create table obj")
|
failOnError(err, "initDB : create table obj")
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ func initDB() {
|
|||||||
failOnError(err, "initDB : create table obj_user")
|
failOnError(err, "initDB : create table obj_user")
|
||||||
|
|
||||||
_, err = db.Exec(`CREATE TABLE obj_guild (
|
_, err = db.Exec(`CREATE TABLE obj_guild (
|
||||||
obj_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT
|
obj_id BIGINT UNSIGNED NOT NULL
|
||||||
,tag VARCHAR(32) NOT NULL
|
,tag VARCHAR(32) NOT NULL
|
||||||
,name VARCHAR(80) NOT NULL
|
,name VARCHAR(80) NOT NULL
|
||||||
,chat_id BIGINT NOT NULL
|
,chat_id BIGINT NOT NULL
|
||||||
@ -136,18 +138,28 @@ func initDB() {
|
|||||||
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
|
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
|
||||||
failOnError(err, "initDB : create table obj_msg_report")
|
failOnError(err, "initDB : create table obj_msg_report")
|
||||||
|
|
||||||
|
_, err = db.Exec(`CREATE TABLE msg_rules (
|
||||||
|
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
|
||||||
|
,prio SMALLINT NOT NULL
|
||||||
|
,descn VARCHAR(32) NOT NULL
|
||||||
|
,rule VARCHAR(4096) NOT NULL
|
||||||
|
,msg_type_id
|
||||||
|
,UNIQUE KEY (id)
|
||||||
|
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
|
||||||
|
failOnError(err, "initDB : create table msg_rules")
|
||||||
|
|
||||||
_, err = db.Exec(`INSERT INTO code_obj_type (id, intl_id, name)
|
_, err = db.Exec(`INSERT INTO code_obj_type (id, intl_id, name)
|
||||||
VALUES (` + strconv.Itoa(objTypeUser) + `, "user", "User")
|
VALUES (` + strconv.Itoa(objTypeUser) + `, "user", "User")
|
||||||
,(` + strconv.Itoa(objTypeGuild) + `, "guild", "Guild")
|
,(` + strconv.Itoa(objTypeGuild) + `, "guild", "Guild")
|
||||||
,(` + strconv.Itoa(objTypeMessage) + `, "msg", "Message")
|
,(` + strconv.Itoa(objTypeMessage) + `, "msg", "Message")
|
||||||
,(` + strconv.Itoa(objTypeWar) + `, "war", "War")
|
,(` + strconv.Itoa(objTypeWar) + `, "war", "War")
|
||||||
,(` + strconv.Itoa(objTypeWarReport) + `, "war_report", "War Report")
|
,(` + strconv.Itoa(objTypeWarReport) + `, "war_report", "War Report")
|
||||||
|
,(` + strconv.Itoa(objTypeJob) + `, "job", "Job")
|
||||||
;`)
|
;`)
|
||||||
failOnError(err, "initDB : populate table code_obj_type")
|
failOnError(err, "initDB : populate table code_obj_type")
|
||||||
|
|
||||||
_, err = db.Exec(`INSERT INTO code_obj_sub_type (id, intl_id, name, obj_type_id)
|
_, err = db.Exec(`INSERT INTO code_obj_sub_type (id, intl_id, name, obj_type_id)
|
||||||
VALUES (` + strconv.Itoa(objSubTypeMessageUnprocess) + `, "unprocessed", "Unprocessed", ` + strconv.Itoa(objTypeMessage) + `)
|
VALUES (` + strconv.Itoa(objSubTypeMessageUnknown) + `, "unknown", "Unknown", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
,(` + strconv.Itoa(objSubTypeMessageUnknown) + `, "unknown", "Unknown", ` + strconv.Itoa(objTypeMessage) + `)
|
|
||||||
,(` + strconv.Itoa(objSubTypeMessageWar) + `, "war", "War report", ` + strconv.Itoa(objTypeMessage) + `)
|
,(` + strconv.Itoa(objSubTypeMessageWar) + `, "war", "War report", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
,(` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "mini_war", "Mini war reprot", ` + strconv.Itoa(objTypeMessage) + `)
|
,(` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "mini_war", "Mini war reprot", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
,(` + strconv.Itoa(objSubTypeMessageGuildWar) + `, "guild_war", "Guilds war report", ` + strconv.Itoa(objTypeMessage) + `)
|
,(` + strconv.Itoa(objSubTypeMessageGuildWar) + `, "guild_war", "Guilds war report", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
@ -157,7 +169,11 @@ func initDB() {
|
|||||||
,(` + strconv.Itoa(objSubTypeMessageFight) + `, "fight", "Fight result", ` + strconv.Itoa(objTypeMessage) + `)
|
,(` + strconv.Itoa(objSubTypeMessageFight) + `, "fight", "Fight result", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
,(` + strconv.Itoa(objSubTypeMessageHero) + `, "hero", "Hero summary", ` + strconv.Itoa(objTypeMessage) + `)
|
,(` + strconv.Itoa(objSubTypeMessageHero) + `, "hero", "Hero summary", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
,(` + strconv.Itoa(objSubTypeMessageMe) + `, "me", "Hero short summary", ` + strconv.Itoa(objTypeMessage) + `)
|
,(` + strconv.Itoa(objSubTypeMessageMe) + `, "me", "Hero short summary", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
,(` + strconv.Itoa(objSubTypeMessageInventory) + `, "inv", "Inventory", ` + strconv.Itoa(objTypeMessage) + `);`)
|
,(` + strconv.Itoa(objSubTypeMessageInventory) + `, "inv", "Inventory", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
|
,(` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "pillage_inc", "Pillage incoming", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
|
,(` + strconv.Itoa(objSubTypeMessageTributeInc) + `, "tribute_inc", "Request incoming", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
|
,(` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "pillage_ack", "Pillage acknoledged", ` + strconv.Itoa(objTypeMessage) + `)
|
||||||
|
,(` + strconv.Itoa(objSubTypeMessageTributeInc) + `, "tribute_ack", "Request acknoledged", ` + strconv.Itoa(objTypeMessage) + `);`)
|
||||||
failOnError(err, "initDB : populate table code_obj_sub_type")
|
failOnError(err, "initDB : populate table code_obj_sub_type")
|
||||||
|
|
||||||
log.Println("Database set up")
|
log.Println("Database set up")
|
||||||
@ -228,7 +244,7 @@ func insertMsgReport(objId int64, war_date int32, atk int32, def int32, exp int3
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if objSubTypeId != objSubTypeMessageUnprocess {
|
if objSubTypeId != objSubTypeMessageUnknown {
|
||||||
return errors.New("Message is not of type Unknown")
|
return errors.New("Message is not of type Unknown")
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
11
workers.go
11
workers.go
@ -93,7 +93,6 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stock : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stock}"), objId)
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stock : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stock}"), objId)
|
||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stamina : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stamina}"), objId)
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stamina : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stamina}"), objId)
|
||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Crit : %s (%d)\n", r.ReplaceAllString(m.Text, "${Crit}"), objId)
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Crit : %s (%d)\n", r.ReplaceAllString(m.Text, "${Crit}"), objId)
|
||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Test : %s (%d)\n", r.ReplaceAllString(m.Text, "${Test}"), objId)
|
|
||||||
} else {
|
} else {
|
||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknown message type (%d)\n", objId)
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknown message type (%d)\n", objId)
|
||||||
}
|
}
|
||||||
@ -101,3 +100,13 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
}
|
}
|
||||||
log.Printf("SQLIdentifyMsgWorker[" + strconv.Itoa(id) + "] : Closing.")
|
log.Printf("SQLIdentifyMsgWorker[" + strconv.Itoa(id) + "] : Closing.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SQLJobWorker(id int) {
|
||||||
|
var tick time.Time
|
||||||
|
log.Printf("SQLJobWorker[" + strconv.Itoa(id) + "] : Starting.")
|
||||||
|
for true {
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
tick = time.Now()
|
||||||
|
}
|
||||||
|
log.Printf("SQLJobWorker[" + strconv.Itoa(id) + "] : Closing.")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user