test
This commit is contained in:
parent
d92c408f42
commit
f7ef018ae8
6
def.go
6
def.go
@ -36,9 +36,9 @@ type ChatWarsMessageMiniWar struct {
|
|||||||
type ChatWarsMessageMiniWarCastle struct {
|
type ChatWarsMessageMiniWarCastle struct {
|
||||||
Gardian string `json:"gardian"`
|
Gardian string `json:"gardian"`
|
||||||
Result string `json:"result"`
|
Result string `json:"result"`
|
||||||
Gold int32 `json:"gold"`
|
Gold int64 `json:"gold"`
|
||||||
Stock int32 `json:"stock"`
|
Stock int64 `json:"stock"`
|
||||||
Points int32 `json:"points"`
|
Points int64 `json:"points"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageParsingRule struct {
|
type MessageParsingRule struct {
|
||||||
|
6
sql.go
6
sql.go
@ -1344,8 +1344,8 @@ func putUnprocessedMsg(m ChatWarsMessage) (int64, error) {
|
|||||||
return objId, nil
|
return objId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMsg(objId int64) (ChatWarsMessage, error) {
|
func getMsg(objId int64) (*ChatWarsMessage, error) {
|
||||||
var m ChatWarsMessage
|
var m *ChatWarsMessage
|
||||||
|
|
||||||
stmt, err := db.Prepare(`SELECT om.msg_id, om.chat_id, om.sender_user_id, om.date, om.text FROM obj_msg om WHERE om.obj_id = ?`)
|
stmt, err := db.Prepare(`SELECT om.msg_id, om.chat_id, om.sender_user_id, om.date, om.text FROM obj_msg om WHERE om.obj_id = ?`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1353,6 +1353,8 @@ func getMsg(objId int64) (ChatWarsMessage, error) {
|
|||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
|
m = new(ChatWarsMessage)
|
||||||
|
|
||||||
err = stmt.QueryRow(objId).Scan(&m.ID64, &m.ChatID64, &m.SenderUserID64, &m.Date, &m.Text)
|
err = stmt.QueryRow(objId).Scan(&m.ID64, &m.ChatID64, &m.SenderUserID64, &m.Date, &m.Text)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return m, err
|
return m, err
|
||||||
|
125
workers.go
125
workers.go
@ -99,128 +99,9 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
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)
|
||||||
case objSubTypeMessageMiniWar:
|
case objSubTypeMessageMiniWar:
|
||||||
t, err := time.Parse("02/01/06 15:04", r.ReplaceAllString(m.Text, "${Time}"))
|
cwm, err := parseSubTypeMessageMiniWar(m, r)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : objSubTypeMessageMiniWar parsing time : "+r.ReplaceAllString(m.Text, "${Time}"))
|
b, err := json.Marshal(cwm)
|
||||||
cwm := ChatWarsMessageMiniWar{
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : %s\n%s\n", m.Text, string(b))
|
||||||
Time: t,
|
|
||||||
Report: make(map[string]*ChatWarsMessageMiniWarCastle),
|
|
||||||
}
|
|
||||||
g, err := strconv.Atoi(r.ReplaceAllString(m.Text, "${Gold1}"))
|
|
||||||
s, err := strconv.Atoi(r.ReplaceAllString(m.Text, "${Stock1}"))
|
|
||||||
rep := ChatWarsMessageMiniWarCastle{
|
|
||||||
Gardian: r.ReplaceAllString(m.Text, "${Gardian1}"),
|
|
||||||
Result: r.ReplaceAllString(m.Text, "${Result1}"),
|
|
||||||
Gold: int32(g),
|
|
||||||
Stock: int32(s),
|
|
||||||
}
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Loot1}")] = &rep
|
|
||||||
g, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Gold2}"))
|
|
||||||
s, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Stock2}"))
|
|
||||||
rep = ChatWarsMessageMiniWarCastle{
|
|
||||||
Gardian: r.ReplaceAllString(m.Text, "${Gardian2}"),
|
|
||||||
Result: r.ReplaceAllString(m.Text, "${Result2}"),
|
|
||||||
Gold: int32(g),
|
|
||||||
Stock: int32(s),
|
|
||||||
}
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Loot2}")] = &rep
|
|
||||||
g, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Gold3}"))
|
|
||||||
s, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Stock3}"))
|
|
||||||
rep = ChatWarsMessageMiniWarCastle{
|
|
||||||
Gardian: r.ReplaceAllString(m.Text, "${Gardian3}"),
|
|
||||||
Result: r.ReplaceAllString(m.Text, "${Result3}"),
|
|
||||||
Gold: int32(g),
|
|
||||||
Stock: int32(s),
|
|
||||||
}
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Loot3}")] = &rep
|
|
||||||
g, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Gold4}"))
|
|
||||||
s, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Stock4}"))
|
|
||||||
rep = ChatWarsMessageMiniWarCastle{
|
|
||||||
Gardian: r.ReplaceAllString(m.Text, "${Gardian4}"),
|
|
||||||
Result: r.ReplaceAllString(m.Text, "${Result4}"),
|
|
||||||
Gold: int32(g),
|
|
||||||
Stock: int32(s),
|
|
||||||
}
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Loot4}")] = &rep
|
|
||||||
g, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Gold5}"))
|
|
||||||
s, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Stock5}"))
|
|
||||||
rep = ChatWarsMessageMiniWarCastle{
|
|
||||||
Gardian: r.ReplaceAllString(m.Text, "${Gardian5}"),
|
|
||||||
Result: r.ReplaceAllString(m.Text, "${Result5}"),
|
|
||||||
Gold: int32(g),
|
|
||||||
Stock: int32(s),
|
|
||||||
}
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Loot5}")] = &rep
|
|
||||||
g, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Gold6}"))
|
|
||||||
s, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Stock6}"))
|
|
||||||
rep = ChatWarsMessageMiniWarCastle{
|
|
||||||
Gardian: r.ReplaceAllString(m.Text, "${Gardian6}"),
|
|
||||||
Result: r.ReplaceAllString(m.Text, "${Result6}"),
|
|
||||||
Gold: int32(g),
|
|
||||||
Stock: int32(s),
|
|
||||||
}
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Loot6}")] = &rep
|
|
||||||
g, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Gold7}"))
|
|
||||||
s, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Stock7}"))
|
|
||||||
rep = ChatWarsMessageMiniWarCastle{
|
|
||||||
Gardian: r.ReplaceAllString(m.Text, "${Gardian7}"),
|
|
||||||
Result: r.ReplaceAllString(m.Text, "${Result7}"),
|
|
||||||
Gold: int32(g),
|
|
||||||
Stock: int32(s),
|
|
||||||
}
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Loot7}")] = &rep
|
|
||||||
|
|
||||||
p, err := strconv.Atoi(r.ReplaceAllString(m.Text, "${Points1}"))
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : convert Points1 : "+r.ReplaceAllString(m.Text, "$(Points1)"))
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Score1}")].Points = int32(p)
|
|
||||||
|
|
||||||
p, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Points2}"))
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : convert Points2 : "+r.ReplaceAllString(m.Text, "$(Points2)"))
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Score2}")].Points = int32(p)
|
|
||||||
|
|
||||||
p, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Points3}"))
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : convert Points3 : "+r.ReplaceAllString(m.Text, "$(Points3)"))
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Score3}")].Points = int32(p)
|
|
||||||
|
|
||||||
p, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Points4}"))
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : convert Points4 : "+r.ReplaceAllString(m.Text, "$(Points4)"))
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Score4}")].Points = int32(p)
|
|
||||||
|
|
||||||
p, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Points5}"))
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : convert Points5 : "+r.ReplaceAllString(m.Text, "$(Points5)"))
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Score5}")].Points = int32(p)
|
|
||||||
|
|
||||||
p, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Points6}"))
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : convert Points6 : "+r.ReplaceAllString(m.Text, "$(Points6)"))
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Score6}")].Points = int32(p)
|
|
||||||
|
|
||||||
p, err = strconv.Atoi(r.ReplaceAllString(m.Text, "${Points7}"))
|
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : convert Points7 : "+r.ReplaceAllString(m.Text, "$(Points7)"))
|
|
||||||
cwm.Report[r.ReplaceAllString(m.Text, "${Score7}")].Points = int32(p)
|
|
||||||
|
|
||||||
//b, err := json.Marshal(cwm)
|
|
||||||
/*
|
|
||||||
if len(r.ReplaceAllString(m.Text, "${Loot1}")) < 6 || len(r.ReplaceAllString(m.Text, "${Loot1}")) > 11 {
|
|
||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : NOT MATCHED \nLoot1: %s\n%s\n", r.ReplaceAllString(m.Text, "${Loot1}"), m.Text)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : MATCHED!\nLoot1: %s\n%s\n", r.ReplaceAllString(m.Text, "${Loot1}"), m.Text)
|
|
||||||
if (len(r.ReplaceAllString(m.Text, "${Loot1}")) < 6 || len(r.ReplaceAllString(m.Text, "${Loot1}")) > 11) ||
|
|
||||||
(len(r.ReplaceAllString(m.Text, "${Loot2}")) < 6 || len(r.ReplaceAllString(m.Text, "${Loot2}")) > 11) ||
|
|
||||||
(len(r.ReplaceAllString(m.Text, "${Loot3}")) < 6 || len(r.ReplaceAllString(m.Text, "${Loot3}")) > 11) ||
|
|
||||||
(len(r.ReplaceAllString(m.Text, "${Loot4}")) < 6 || len(r.ReplaceAllString(m.Text, "${Loot4}")) > 11) ||
|
|
||||||
(len(r.ReplaceAllString(m.Text, "${Loot5}")) < 6 || len(r.ReplaceAllString(m.Text, "${Loot5}")) > 11) ||
|
|
||||||
(len(r.ReplaceAllString(m.Text, "${Loot6}")) < 6 || len(r.ReplaceAllString(m.Text, "${Loot6}")) > 11) ||
|
|
||||||
(len(r.ReplaceAllString(m.Text, "${Loot7}")) < 6 || len(r.ReplaceAllString(m.Text, "${Loot7}")) > 11) {
|
|
||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : NOT MATCHED \nLoot1: %s\nLoot2: %s\nLoot3: %s\nLoot4: %s\nLoot5: %s\nLoot6: %s\nLoot7: %s\n%s\n", r.ReplaceAllString(m.Text, "${Loot1}"), r.ReplaceAllString(m.Text, "${Loot2}"), r.ReplaceAllString(m.Text, "${Loot3}"), r.ReplaceAllString(m.Text, "${Loot4}"), r.ReplaceAllString(m.Text, "${Loot5}"), r.ReplaceAllString(m.Text, "${Loot6}"), r.ReplaceAllString(m.Text, "${Loot7}"), m.Text)
|
|
||||||
} else {
|
|
||||||
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : MATCHED! \nLoot1: %s | Result1: %s | Gold1: %s | Stock1: %s\nLoot2: %s | Result2: %s | Gold2: %s | Stock2: %s\nLoot3: %s | Result3: %s | Gold3: %s | Stock3: %s\nLoot4: %s | Result4: %s | Gold4: %s | Stock4: %s\nLoot5: %s | Result5: %s | Gold5: %s | Stock5: %s\nLoot6: %s | Result6: %s | Gold6: %s | Stock6: %s\nLoot7: %s | Result7: %s | Gold7: %s | Stock7: %s\n%s\n", r.ReplaceAllString(m.Text, "${Loot1}"), r.ReplaceAllString(m.Text, "${Result1}"), r.ReplaceAllString(m.Text, "${Gold1}"), r.ReplaceAllString(m.Text, "${Stock1}"), r.ReplaceAllString(m.Text, "${Loot2}"), r.ReplaceAllString(m.Text, "${Result2}"), r.ReplaceAllString(m.Text, "${Gold2}"), r.ReplaceAllString(m.Text, "${Stock2}"), r.ReplaceAllString(m.Text, "${Loot3}"), r.ReplaceAllString(m.Text, "${Result3}"), r.ReplaceAllString(m.Text, "${Gold3}"), r.ReplaceAllString(m.Text, "${Stock3}"), r.ReplaceAllString(m.Text, "${Loot4}"), r.ReplaceAllString(m.Text, "${Result4}"), r.ReplaceAllString(m.Text, "${Gold4}"), r.ReplaceAllString(m.Text, "${Stock4}"), r.ReplaceAllString(m.Text, "${Loot5}"), r.ReplaceAllString(m.Text, "${Result5}"), r.ReplaceAllString(m.Text, "${Gold5}"), r.ReplaceAllString(m.Text, "${Stock5}"), r.ReplaceAllString(m.Text, "${Loot6}"), r.ReplaceAllString(m.Text, "${Result6}"), r.ReplaceAllString(m.Text, "${Gold6}"), r.ReplaceAllString(m.Text, "${Stock6}"), r.ReplaceAllString(m.Text, "${Loot7}"), r.ReplaceAllString(m.Text, "${Result7}"), r.ReplaceAllString(m.Text, "${Gold7}"), r.ReplaceAllString(m.Text, "${Stock7}"), m.Text)
|
|
||||||
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : objSubTypeMessageMiniWar\nScore1 : %s | Points1 : %s\nScore2 : %s | Points2 : %s\nScore3 : %s | Points3 : %s\nScore4 : %s | Points4 : %s\nScore5 : %s | Points5 : %s\nScore6 : %s | Points6 : %s\nScore7 : %s | Points8 : %s\n%s\n%s\n", r.ReplaceAllString(m.Text, "${Score1}"), r.ReplaceAllString(m.Text, "${Points1}"), r.ReplaceAllString(m.Text, "${Score2}"), r.ReplaceAllString(m.Text, "${Points2}"), r.ReplaceAllString(m.Text, "${Score3}"), r.ReplaceAllString(m.Text, "${Points3}"), r.ReplaceAllString(m.Text, "${Score4}"), r.ReplaceAllString(m.Text, "${Points4}"), r.ReplaceAllString(m.Text, "${Score5}"), r.ReplaceAllString(m.Text, "${Points5}"), r.ReplaceAllString(m.Text, "${Score6}"), r.ReplaceAllString(m.Text, "${Points6}"), r.ReplaceAllString(m.Text, "${Score7}"), r.ReplaceAllString(m.Text, "${Points7}"), m.Text, string(b))
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
if err == nil {
|
|
||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : War time : %s (%d)\n", r.ReplaceAllString(m.Text, "${Time}"), objId)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
case objSubTypeMessageAuctionAnnounce:
|
case objSubTypeMessageAuctionAnnounce:
|
||||||
cwm := ChatWarsMessageAuctionAnnounce{
|
cwm := ChatWarsMessageAuctionAnnounce{
|
||||||
|
Loading…
Reference in New Issue
Block a user