update for shops
This commit is contained in:
parent
3de816f2c8
commit
7995fa3e01
26
bot.go
26
bot.go
@ -420,11 +420,29 @@ func botMsgRescanAll(m *tb.Message) {
|
|||||||
TGCmdQueue <- c
|
TGCmdQueue <- c
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p := JobPayloadRescanMsg{
|
|
||||||
Query: fmt.Sprintf("SELECT o.id FROM obj o WHERE o.obj_type_id = %d AND o.obj_sub_type_id = %d ORDER BY id ASC;", cacheObjType[`msg`], cacheObjSubType[`msg`]),
|
var p JobPayloadRescanMsg
|
||||||
MsgID64: int64(m.ID),
|
if len(m.Payload) > 0 {
|
||||||
ChatID64: m.Chat.ID,
|
r := regexp.MustCompile("^\"(?P<Filter>(.*))\"$")
|
||||||
|
if r.MatchString(m.Payload) {
|
||||||
|
p.Query = fmt.Sprintf("SELECT o.id FROM obj o, obj_msg om WHERE o.obj_type_id = %d AND o.obj_sub_type_id = %d AND om.obj_id = o.id AND om.text like '%s' ORDER BY o.id ASC;", cacheObjType[`msg`], cacheObjSubType[`msg`], r.ReplaceAllString(m.Text, "${Filter}"))
|
||||||
|
} else {
|
||||||
|
c := TGCommand{
|
||||||
|
Type: commandReplyMsg,
|
||||||
|
Text: "Wrong format",
|
||||||
|
FromMsgID64: int64(m.ID),
|
||||||
|
FromChatID64: m.Chat.ID,
|
||||||
|
}
|
||||||
|
TGCmdQueue <- c
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.Query = fmt.Sprintf("SELECT o.id FROM obj o WHERE o.obj_type_id = %d AND o.obj_sub_type_id = %d ORDER BY o.id ASC;", cacheObjType[`msg`], cacheObjSubType[`msg`])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.MsgID64 = int64(m.ID)
|
||||||
|
p.ChatID64 = m.Chat.ID
|
||||||
|
|
||||||
b, _ := json.Marshal(p)
|
b, _ := json.Marshal(p)
|
||||||
_, err := createJob(cacheObjSubType[`job_rescan_msg`], objJobPriorityRescanAllMsg, int64(m.Sender.ID), 0, time.Now().UTC(), b)
|
_, err := createJob(cacheObjSubType[`job_rescan_msg`], objJobPriorityRescanAllMsg, int64(m.Sender.ID), 0, time.Now().UTC(), b)
|
||||||
logOnError(err, "botMsgRescan : createJob(cacheObjSubType[`job_rescan_msg`])")
|
logOnError(err, "botMsgRescan : createJob(cacheObjSubType[`job_rescan_msg`])")
|
||||||
|
@ -24,6 +24,16 @@
|
|||||||
"name": "Guild deposit chat",
|
"name": "Guild deposit chat",
|
||||||
"obj_type": "msg"
|
"obj_type": "msg"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"intl_id": "msg_shop_main_req",
|
||||||
|
"name": "Shop main request",
|
||||||
|
"obj_type": "msg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"intl_id": "msg_shop_main_ack",
|
||||||
|
"name": "Shop main ack",
|
||||||
|
"obj_type": "msg"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"intl_id": "msg_job_gwithdraw_req",
|
"intl_id": "msg_job_gwithdraw_req",
|
||||||
"name": "Guild withdraw conf req",
|
"name": "Guild withdraw conf req",
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
"max_qty": 10000
|
"max_qty": 10000
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shops": [ {"type": "armor", "link": "/ws_abcd"},
|
"shops": [ "/ws_abcd",
|
||||||
{"type": "off_hand", "link": "/ws_0123"} ]
|
"/ws_0123" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1878,5 +1878,21 @@
|
|||||||
"msg_type": "msg_tributes_stats_ack",
|
"msg_type": "msg_tributes_stats_ack",
|
||||||
"chat_id": 0,
|
"chat_id": 0,
|
||||||
"user_id": 0
|
"user_id": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"prio": 5000,
|
||||||
|
"descn": "Shop main req",
|
||||||
|
"rule": "^/ws_(?P<Link>[a-zA-Z0-9]+)$",
|
||||||
|
"msg_type": "msg_shop_main_req",
|
||||||
|
"chat_id": 0,
|
||||||
|
"user_id": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"prio": 5000,
|
||||||
|
"descn": "Shop main ack",
|
||||||
|
"rule": "^Welcome, to the (?P<Name>[a-zA-Z0-9 ]+) #(?P<Number>[0-9]+)\\.\\n(?s:.*)$",
|
||||||
|
"msg_type": "msg_shop_main_ack",
|
||||||
|
"chat_id": 0,
|
||||||
|
"user_id": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
11
def.go
11
def.go
@ -45,10 +45,7 @@ type Config struct {
|
|||||||
Min int64 `json:"min_qty"`
|
Min int64 `json:"min_qty"`
|
||||||
Max int64 `json:"max_qty"`
|
Max int64 `json:"max_qty"`
|
||||||
} `json:"vault_limit"`
|
} `json:"vault_limit"`
|
||||||
Shops []struct {
|
Shops []string `json:"shops"`
|
||||||
Type string `json:"type"`
|
|
||||||
Link string `json:"link"`
|
|
||||||
} `json:"shops"`
|
|
||||||
} `json:"bot"`
|
} `json:"bot"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,6 +367,12 @@ type ChatWarsMessageTributesStatsAck struct {
|
|||||||
Tributes []ChatWarsTribute `json:"tributes"`
|
Tributes []ChatWarsTribute `json:"tributes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChatWarsMessageShopMainAck struct {
|
||||||
|
Msg *ChatWarsMessage `json:"msg"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Number string `json:"number"`
|
||||||
|
}
|
||||||
|
|
||||||
type MessageParsingRule struct {
|
type MessageParsingRule struct {
|
||||||
ID int32
|
ID int32
|
||||||
Priority int32 `json:"prio"`
|
Priority int32 `json:"prio"`
|
||||||
|
13
msg.go
13
msg.go
@ -298,6 +298,19 @@ func parseSubTypeMessageTributesStatsAck(m *ChatWarsMessage, r *regexp.Regexp) (
|
|||||||
return &cwm, nil
|
return &cwm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseSubTypeMessageShopMainAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageShopMainAck, error) {
|
||||||
|
cwm := ChatWarsMessageShopMainAck{}
|
||||||
|
cwm.Msg = m
|
||||||
|
|
||||||
|
cwm.Name = r.ReplaceAllString(m.Text, "${Name}")
|
||||||
|
cwm.Number = r.ReplaceAllString(m.Text, "${Number}")
|
||||||
|
|
||||||
|
log.Printf("parseSubTypeMessageShopMainAck : Name : %s\n", cwm.Name)
|
||||||
|
log.Printf("parseSubTypeMessageShopMainAck : Number : %s\n", cwm.Number)
|
||||||
|
|
||||||
|
return &cwm, nil
|
||||||
|
}
|
||||||
|
|
||||||
func parseSubTypeMessageMeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageMeAck, error) {
|
func parseSubTypeMessageMeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageMeAck, error) {
|
||||||
var i int64
|
var i int64
|
||||||
|
|
||||||
|
@ -523,6 +523,10 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_tributes_stats_ack`]")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_tributes_stats_ack`]")
|
||||||
err = insertMsgTributesStats(cwm)
|
err = insertMsgTributesStats(cwm)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgTributesStats")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgTributesStats")
|
||||||
|
case cacheObjSubType[`msg_shop_main_req`]:
|
||||||
|
case cacheObjSubType[`msg_shop_main_ack`]:
|
||||||
|
_, err := parseSubTypeMessageShopMainAck(m, rule.re)
|
||||||
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_shop_main_ack`]")
|
||||||
default:
|
default:
|
||||||
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID64, objId, m.Text)
|
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID64, objId, m.Text)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user