/shops skeleton
This commit is contained in:
parent
4878e6205e
commit
ac74074f59
55
bot.go
55
bot.go
@ -772,6 +772,61 @@ func botGStock(m *ChatWarsMessage) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func botShops(m *ChatWarsMessage) {
|
||||||
|
// fan out to all active and non idle clients
|
||||||
|
/*
|
||||||
|
clts, err := getLockedAllIdleClient()
|
||||||
|
if err != nil {
|
||||||
|
c := TGCommand{
|
||||||
|
Type: commandReplyMsg,
|
||||||
|
Text: "Busy, please retry later.",
|
||||||
|
FromMsgID64: m.ID64,
|
||||||
|
FromChatID64: m.ChatID64,
|
||||||
|
}
|
||||||
|
TGCmdQueue <- c
|
||||||
|
return
|
||||||
|
}
|
||||||
|
userID64 := clt.TGUserID64
|
||||||
|
clt.Mux.Unlock()
|
||||||
|
|
||||||
|
p := JobPayloadGStock{
|
||||||
|
MsgID64: m.ID64,
|
||||||
|
ChatID64: m.ChatID64,
|
||||||
|
Status: 0,
|
||||||
|
}
|
||||||
|
b, _ := json.Marshal(p)
|
||||||
|
t := time.Now().UTC().Add(1 * time.Second)
|
||||||
|
_, err = createJob(cacheObjSubType[`job_gstock`], objJobPriority, userID64, 0, t, b)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
c := TGCommand{
|
||||||
|
Type: commandReplyMsg,
|
||||||
|
Text: fmt.Sprintf("%s", err),
|
||||||
|
FromMsgID64: m.ID64,
|
||||||
|
FromChatID64: m.ChatID64,
|
||||||
|
}
|
||||||
|
TGCmdQueue <- c
|
||||||
|
} else {
|
||||||
|
c := TGCommand{
|
||||||
|
Type: commandReplyMsg,
|
||||||
|
Text: "Stock requested",
|
||||||
|
FromMsgID64: m.ID64,
|
||||||
|
FromChatID64: m.ChatID64,
|
||||||
|
}
|
||||||
|
TGCmdQueue <- c
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
c := TGCommand{
|
||||||
|
Type: commandReplyMsg,
|
||||||
|
Text: "Not implemented",
|
||||||
|
FromMsgID64: m.ID64,
|
||||||
|
FromChatID64: m.ChatID64,
|
||||||
|
}
|
||||||
|
TGCmdQueue <- c
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func botCraftItem(m *ChatWarsMessage, r *regexp.Regexp) {
|
func botCraftItem(m *ChatWarsMessage, r *regexp.Regexp) {
|
||||||
clt, err := getLockedIdleClient()
|
clt, err := getLockedIdleClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -644,6 +644,11 @@
|
|||||||
"name": "Craft check for all items",
|
"name": "Craft check for all items",
|
||||||
"obj_type": "msg"
|
"obj_type": "msg"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"intl_id": "msg_bot_shops",
|
||||||
|
"name": "Check all shops",
|
||||||
|
"obj_type": "msg"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"intl_id": "msg_bot_g_stock",
|
"intl_id": "msg_bot_g_stock",
|
||||||
"name": "Get Stock",
|
"name": "Get Stock",
|
||||||
@ -759,6 +764,11 @@
|
|||||||
"name": "Craft all items summary job",
|
"name": "Craft all items summary job",
|
||||||
"obj_type": "job"
|
"obj_type": "job"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"intl_id": "job_shops",
|
||||||
|
"name": "Shops summary job",
|
||||||
|
"obj_type": "job"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"intl_id": "job_check_vault_limit",
|
"intl_id": "job_check_vault_limit",
|
||||||
"name": "Check vault resource limit",
|
"name": "Check vault resource limit",
|
||||||
|
20
rules.go
20
rules.go
@ -105,6 +105,26 @@ func resetMsgParsingRules() error {
|
|||||||
}
|
}
|
||||||
rules2 = append(rules2, r)
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
|
r = MessageParsingRule{
|
||||||
|
Priority: 9999,
|
||||||
|
Description: "Get Shops list",
|
||||||
|
Rule: "^/shops$",
|
||||||
|
MsgTypeID64: cacheObjSubType[`msg_bot_shops`],
|
||||||
|
ChatID64: cfg.Bot.Mainchat,
|
||||||
|
SenderUserID64: 0,
|
||||||
|
}
|
||||||
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
|
r = MessageParsingRule{
|
||||||
|
Priority: 9999,
|
||||||
|
Description: "Get Shops list",
|
||||||
|
Rule: "^/shops$",
|
||||||
|
MsgTypeID64: cacheObjSubType[`msg_bot_shops`],
|
||||||
|
ChatID64: cfg.Bot.Admin,
|
||||||
|
SenderUserID64: cfg.Bot.Admin,
|
||||||
|
}
|
||||||
|
rules2 = append(rules2, r)
|
||||||
|
|
||||||
r = MessageParsingRule{
|
r = MessageParsingRule{
|
||||||
Priority: 1,
|
Priority: 1,
|
||||||
Description: "Default Main chat",
|
Description: "Default Main chat",
|
||||||
|
24
sql.go
24
sql.go
@ -577,11 +577,25 @@ func initDBViews() {
|
|||||||
failOnError(err, "initDBViews : create view obj_msg_callback_v")
|
failOnError(err, "initDBViews : create view obj_msg_callback_v")
|
||||||
log.Println("initDBViews : obj_msg_callback_v created ...")
|
log.Println("initDBViews : obj_msg_callback_v created ...")
|
||||||
|
|
||||||
_, err = db.Exec(`CREATE VIEW obj_shop_v AS
|
_, err = db.Exec(`CREATE VIEW obj_shop_main_v AS
|
||||||
SELECT omsm.*
|
SELECT omsm.obj_id
|
||||||
FROM obj_msg_shop_main omsm;`)
|
,omsm.name COLLATE utf8mb4_unicode_ci AS name
|
||||||
failOnError(err, "initDBViews : create view obj_shop_v")
|
,omsm.link COLLATE utf8mb4_unicode_ci AS link
|
||||||
log.Println("initDBViews : obj_shop_v created ...")
|
,omsm.number
|
||||||
|
,omsm.user COLLATE utf8mb4_unicode_ci AS user
|
||||||
|
,omsm.mana
|
||||||
|
,omsm.mana_total
|
||||||
|
,omsm.class COLLATE utf8mb4_unicode_ci AS class
|
||||||
|
,obn.name COLLATE utf8mb4_unicode_ci AS castle
|
||||||
|
,omsm.fees COLLATE utf8mb4_unicode_ci AS fees
|
||||||
|
,omsm.guru COLLATE utf8mb4_unicode_ci AS guru
|
||||||
|
,omsm.open
|
||||||
|
FROM obj_msg_shop_main omsm
|
||||||
|
,obj_name obn;
|
||||||
|
WHERE obn.obj_id = omsm.castle_id
|
||||||
|
AND obn.priority = 0;`)
|
||||||
|
failOnError(err, "initDBViews : create view obj_shop_main_v")
|
||||||
|
log.Println("initDBViews : obj_shop_main_v created ...")
|
||||||
|
|
||||||
log.Println("initDBViews : Views set up")
|
log.Println("initDBViews : Views set up")
|
||||||
}
|
}
|
||||||
|
@ -513,6 +513,8 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res`]")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_quest_res`]")
|
||||||
case cacheObjSubType[`msg_bot_g_stock`]:
|
case cacheObjSubType[`msg_bot_g_stock`]:
|
||||||
botGStock(m)
|
botGStock(m)
|
||||||
|
case cacheObjSubType[`msg_bot_shops`]:
|
||||||
|
botShops(m)
|
||||||
case cacheObjSubType[`msg_bot_craft_item`]:
|
case cacheObjSubType[`msg_bot_craft_item`]:
|
||||||
botCraftItem(m, rule.re)
|
botCraftItem(m, rule.re)
|
||||||
case cacheObjSubType[`msg_bot_craft_all`]:
|
case cacheObjSubType[`msg_bot_craft_all`]:
|
||||||
|
Loading…
Reference in New Issue
Block a user