test
This commit is contained in:
parent
99bda82986
commit
8f451118cb
1
def.go
1
def.go
@ -375,6 +375,7 @@ type ChatWarsMessageUnionWar struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ChatWarsMessageTimeAck struct {
|
type ChatWarsMessageTimeAck struct {
|
||||||
|
ObjID64 int64 `json:"obj_id"`
|
||||||
RealTime time.Time `json:"real_time"`
|
RealTime time.Time `json:"real_time"`
|
||||||
TimeOfDay string `json:"time_of_day"`
|
TimeOfDay string `json:"time_of_day"`
|
||||||
Hour int64 `json:"hour"`
|
Hour int64 `json:"hour"`
|
||||||
|
2
msg.go
2
msg.go
@ -619,6 +619,7 @@ func parseSubTypeMessageDuelFight(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWa
|
|||||||
|
|
||||||
func parseSubTypeMessageTimeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageTimeAck, error) {
|
func parseSubTypeMessageTimeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageTimeAck, error) {
|
||||||
cwm := ChatWarsMessageTimeAck{}
|
cwm := ChatWarsMessageTimeAck{}
|
||||||
|
cwm.ObjID64 = m.ObjID64
|
||||||
t, err := fromChatWarsDate(r.ReplaceAllString(m.Text, "${Day}") + " " + r.ReplaceAllString(m.Text, "${Month}") + " " + r.ReplaceAllString(m.Text, "${Year}") + " " + r.ReplaceAllString(m.Text, "${Hour}") + ":" + r.ReplaceAllString(m.Text, "${Minute}"))
|
t, err := fromChatWarsDate(r.ReplaceAllString(m.Text, "${Day}") + " " + r.ReplaceAllString(m.Text, "${Month}") + " " + r.ReplaceAllString(m.Text, "${Year}") + " " + r.ReplaceAllString(m.Text, "${Hour}") + ":" + r.ReplaceAllString(m.Text, "${Minute}"))
|
||||||
logOnError(err, "parseSubTypeMessageTimeAck : fromChatWarsDate")
|
logOnError(err, "parseSubTypeMessageTimeAck : fromChatWarsDate")
|
||||||
cwm.RealTime = t
|
cwm.RealTime = t
|
||||||
@ -630,7 +631,6 @@ func parseSubTypeMessageTimeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWars
|
|||||||
cwm.Year, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Year}"), 10, 64)
|
cwm.Year, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Year}"), 10, 64)
|
||||||
cwm.Weather = r.ReplaceAllString(m.Text, "${Weather}")
|
cwm.Weather = r.ReplaceAllString(m.Text, "${Weather}")
|
||||||
cwm.WeatherNext = r.ReplaceAllString(m.Text, "${WeatherNext}")
|
cwm.WeatherNext = r.ReplaceAllString(m.Text, "${WeatherNext}")
|
||||||
log.Printf("parseSubTypeMessageTimeAck : drift %v", m.Date.Sub(cwm.RealTime))
|
|
||||||
return &cwm, nil
|
return &cwm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
sql.go
32
sql.go
@ -383,6 +383,14 @@ func initDB() {
|
|||||||
failOnError(err, "initDB : create table obj_msg_shop_main")
|
failOnError(err, "initDB : create table obj_msg_shop_main")
|
||||||
log.Println("initDB : obj_msg_shop_main created ...")
|
log.Println("initDB : obj_msg_shop_main created ...")
|
||||||
|
|
||||||
|
_, err = db.Exec(`CREATE TABLE obj_msg_time (
|
||||||
|
obj_id BIGINT UNSIGNED NOT NULL
|
||||||
|
,date DATETIME NOT NULL
|
||||||
|
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
|
||||||
|
failOnError(err, "initDB : create table obj_msg_time")
|
||||||
|
log.Println("initDB : obj_msg_time created ...")
|
||||||
|
|
||||||
_, err = db.Exec(`CREATE TABLE obj_tribute (
|
_, err = db.Exec(`CREATE TABLE obj_tribute (
|
||||||
tg_user_id BIGINT UNSIGNED NOT NULL
|
tg_user_id BIGINT UNSIGNED NOT NULL
|
||||||
,item_id BIGINT UNSIGNED NOT NULL
|
,item_id BIGINT UNSIGNED NOT NULL
|
||||||
@ -879,6 +887,30 @@ func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func insertMsgTimeAck(m *ChatWarsMessageTimeAck) error {
|
||||||
|
objSubTypeId, err := getObjSubTypeId(m.ObjID64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if objSubTypeId != cacheObjSubType[`msg`] && objSubTypeId != cacheObjSubType[`msg_time_ack`] {
|
||||||
|
return errors.New("Message type mismatch")
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt, err := db.Prepare(`INSERT INTO obj_msg_time (obj_id, date)
|
||||||
|
VALUES (?, ?);`)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer stmt.Close()
|
||||||
|
|
||||||
|
_, err = stmt.Exec(m.ObjID64, m.RealTime)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func insertMsgPillageInc(m *ChatWarsMessagePillageInc) error {
|
func insertMsgPillageInc(m *ChatWarsMessagePillageInc) error {
|
||||||
objSubTypeId, err := getObjSubTypeId(m.ObjID64)
|
objSubTypeId, err := getObjSubTypeId(m.ObjID64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -497,8 +497,9 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
case cacheObjSubType[`msg_time_ack`]:
|
case cacheObjSubType[`msg_time_ack`]:
|
||||||
_, err := parseSubTypeMessageTimeAck(m, rule.re)
|
cwm, err := parseSubTypeMessageTimeAck(m, rule.re)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_time_ack`]")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_time_ack`]")
|
||||||
|
err = insertMsgTimeAck(cwm)
|
||||||
case cacheObjSubType[`msg_orderbook_acl`]:
|
case cacheObjSubType[`msg_orderbook_acl`]:
|
||||||
_, err := parseSubTypeMessageOrderbookAck(m, rule.re)
|
_, err := parseSubTypeMessageOrderbookAck(m, rule.re)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_orderbook_acl`]")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_orderbook_acl`]")
|
||||||
|
Loading…
Reference in New Issue
Block a user