update shop main ack with link

This commit is contained in:
shoopea 2020-02-06 18:25:49 +08:00
parent 99a3d815d5
commit 07a990a7cd
4 changed files with 14 additions and 4 deletions

View File

@ -1890,7 +1890,7 @@
{
"prio": 5000,
"descn": "Shop main ack",
"rule": "^Welcome, to the (?P<Name>[a-zA-Z0-9 -]+) #(?P<Number>[0-9]+)\\.\\n(?P<User>.+) (?P<Mana>[0-9]+)\\/(?P<ManaTotal>[0-9]+)💧the (?P<Class>.+) from (?P<Castle>.+)\\n\\n(?P<Fees>.*)\\n\\n(the (?P<Guru>.*) Guru\\n\\n){0,1}.* is (?P<Open>(open|closed))\\.\\n(?s:.*)$",
"rule": "^Welcome, to the (?P<Name>[a-zA-Z0-9 -]+) #(?P<Number>[0-9]+)\\.\\n(?P<User>.+) (?P<Mana>[0-9]+)\\/(?P<ManaTotal>[0-9]+)💧the (?P<Class>.+) from (?P<Castle>.+)\\n\\n(?P<Fees>.*)\\n\\n(the (?P<Guru>.*) Guru\\n\\n){0,1}.* is (?P<Open>(open|closed))\\.\\n(?s:.*).*/ws_(?P<Link>[a-zA-Z0-9]+)$",
"msg_type": "msg_shop_main_ack",
"chat_id": 0,
"user_id": 0

1
def.go
View File

@ -370,6 +370,7 @@ type ChatWarsMessageTributesStatsAck struct {
type ChatWarsMessageShopMainAck struct {
Msg *ChatWarsMessage `json:"msg"`
Name string `json:"name"`
Link string `json:"link"`
ShopNumber int64 `json:"shop_number"`
User string `json:"user"`
Mana int64 `json:"mana"`

2
msg.go
View File

@ -304,6 +304,7 @@ func parseSubTypeMessageShopMainAck(m *ChatWarsMessage, r *regexp.Regexp) (*Chat
cwm.Name = r.ReplaceAllString(m.Text, "${Name}")
cwm.ShopNumber, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Number}"), 10, 64)
cwm.Link = r.ReplaceAllString(m.Text, "${Link}")
cwm.User = r.ReplaceAllString(m.Text, "${User}")
cwm.Mana, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Mana}"), 10, 64)
cwm.ManaTotal, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${ManaTotal}"), 10, 64)
@ -320,6 +321,7 @@ func parseSubTypeMessageShopMainAck(m *ChatWarsMessage, r *regexp.Regexp) (*Chat
/*
log.Printf("parseSubTypeMessageShopMainAck : Name : %s\n", cwm.Name)
log.Printf("parseSubTypeMessageShopMainAck : Number : %d\n", cwm.ShopNumber)
log.Printf("parseSubTypeMessageShopMainAck : Link : %s\n", cwm.Link)
log.Printf("parseSubTypeMessageShopMainAck : User : %s\n", cwm.User)
log.Printf("parseSubTypeMessageShopMainAck : Mana : %d\n", cwm.Mana)
log.Printf("parseSubTypeMessageShopMainAck : ManaTotal : %d\n", cwm.ManaTotal)

13
sql.go
View File

@ -330,6 +330,7 @@ func initDB() {
_, err = db.Exec(`CREATE TABLE obj_msg_shop_main (
obj_id BIGINT UNSIGNED NOT NULL
,name VARCHAR(80)
,link VARCHAR(80)
,number INT UNSIGNED NOT NULL
,user VARCHAR(80)
,mana INT UNSIGNED NOT NULL
@ -576,6 +577,12 @@ func initDBViews() {
failOnError(err, "initDBViews : create view obj_msg_callback_v")
log.Println("initDBViews : obj_msg_callback_v created ...")
_, err = db.Exec(`CREATE VIEW obj_shop_v AS
SELECT omsm.*
FROM obj_msg_shop_main omsm;`)
failOnError(err, "initDBViews : create view obj_shop_v")
log.Println("initDBViews : obj_shop_v created ...")
log.Println("initDBViews : Views set up")
}
@ -726,8 +733,8 @@ func insertMsgShopMainAck(m *ChatWarsMessageShopMainAck) error {
return errors.New("Message type mismatch")
}
stmt, err := db.Prepare(`INSERT INTO obj_msg_shop_main (obj_id, name, number, user, mana, mana_total, class, castle_id, fees, guru, open)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`)
stmt, err := db.Prepare(`INSERT INTO obj_msg_shop_main (obj_id, name, link, number, user, mana, mana_total, class, castle_id, fees, guru, open)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`)
logOnError(err, "insertMsgShopMainAck : Prepare")
if err != nil {
return err
@ -741,7 +748,7 @@ func insertMsgShopMainAck(m *ChatWarsMessageShopMainAck) error {
open = 0
}
_, err = stmt.Exec(m.Msg.ObjID64, m.Name, m.ShopNumber, m.User, m.Mana, m.ManaTotal, m.Class, m.CastleID64, m.Fees, m.Guru, open)
_, err = stmt.Exec(m.Msg.ObjID64, m.Name, m.Link, m.ShopNumber, m.User, m.Mana, m.ManaTotal, m.Class, m.CastleID64, m.Fees, m.Guru, open)
logOnError(err, "insertMsgShopMainAck Exec")
return nil