This commit is contained in:
shoopea 2019-05-08 23:18:17 +08:00
parent 2af99e3236
commit 05cd98ef36
3 changed files with 54 additions and 0 deletions

18
def.go
View File

@ -57,3 +57,21 @@ const (
SQLIdentifyMsgWorkers = 6
SQLJobWorkers = 3
)
func fromChatWarsDate(d string) (t time.Time, err error) {
r := regexp.MustCompile(`(?P<Day>[0-9]{2}) (?P<Month>(Wintar|Hornung|Lenzin|Ōstar|Winni|Brāh|Hewi|Aran|Witu|Wīndume|Herbist|Hailag)) (?P<Year>[0-9]{4})( (?P<Hour>[0-9]{2}):(?P<Minute>[0-9]{2})){0,1}`)
if r.FindStringSubmatch(d) != nil {
log.Printf("fromChatWarsDate : Day : %s\n", r.ReplaceAllString(m.Text, "${Day}"), objId)
log.Printf("fromChatWarsDate : Month : %s\n", r.ReplaceAllString(m.Text, "${Month}"), objId)
log.Printf("fromChatWarsDate : Year : %s\n", r.ReplaceAllString(m.Text, "${Year}"), objId)
log.Printf("fromChatWarsDate : Hour : %s\n", r.ReplaceAllString(m.Text, "${Hour}"), objId)
log.Printf("fromChatWarsDate : Minute : %s\n", r.ReplaceAllString(m.Text, "${Minute}"), objId)
return time.Now(), nil
} else {
return nil, errors.New("Wrong format")
}
}
func toChatWarsDate(t time.Time) (s string, err error) {
return "test", nil
}

34
sql.go
View File

@ -296,6 +296,40 @@ func insertMsgReport(objId int64, war_date int32, atk int32, def int32, exp int3
return nil
}
func insertMsgReport(objId int64, war_date int32, atk int32, def int32, exp int32, gold int32, stock int32, crit bool, stamina bool) error {
objSubTypeId, err := getObjSubTypeId(objId)
if err != nil {
return err
}
if objSubTypeId != objSubTypeMessageUnknown {
return errors.New("Message is not of type Unknown")
}
/*
obj_id BIGINT UNSIGNED NOT NULL
,war_date TIMESTAMP NOT NULL
,attack SMALLINT UNSIGNED NOT NULL
,defense SMALLINT UNSIGNED NOT NULL
,gold SMALLINT UNSIGNED NOT NULL
,stock MALLINT UNSIGNED NOT NULL
,exp SMALLINT UNSIGNED NOT NULL
,stamina TINYINT NOT NULL
,crit TINYINT NOT NULL
stmt, err := db.Prepare(`INSERT INTO obj_msg_report (obj_id, war_date, attack, defense, gold, stock, exp, stamina, crit)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?FROM_UNIXTIME(?), ?);`)
if err != nil {
return err
}
defer stmt.Close()
_, err = stmt.Exec(objId, m.ID64, m.ChatID64, m.UserID64, m.SenderUserID64, m.Date, m.Text)
if err != nil {
return err
}
*/
return nil
}
func loadMsgParsingRules() (m map[int]MessageParsingRule, err error) {
var (
id int32

View File

@ -108,6 +108,8 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Price : %s (%d)\n", r.ReplaceAllString(m.Text, "${Price}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Status : %s (%d)\n", r.ReplaceAllString(m.Text, "${Status}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : End : %s (%d)\n", r.ReplaceAllString(m.Text, "${End}"), objId)
_, err := fromChatWarsDate(r.ReplaceAllString(m.Text, "${End}"))
logOnFail(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : AuctionAnnounce : end")
default:
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID, objId)
}