test user config

This commit is contained in:
shoopea 2020-02-10 10:56:05 +08:00
parent 8c67f19066
commit 140b420652
4 changed files with 29 additions and 1 deletions

11
bot.go
View File

@ -891,6 +891,17 @@ func botCraftItem(m *ChatWarsMessage, r *regexp.Regexp) {
return
}
func botUserConfig(m *ChatWarsMessage) {
c := TGCommand{
Type: commandReplyMsg,
Text: "Config:",
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
}
TGCmdQueue <- c
return
}
func botCraftAll(m *ChatWarsMessage, r *regexp.Regexp) {
clt, err := getLockedIdleClient()
if err != nil {

View File

@ -654,6 +654,11 @@
"name": "Get Stock",
"obj_type": "msg"
},
{
"intl_id": "msg_bot_user_config",
"name": "Get User Config in Bot",
"obj_type": "msg"
},
{
"intl_id": "job_pillage",
"name": "Pillage job",

View File

@ -40,6 +40,16 @@ func resetMsgParsingRules() error {
if c.Active {
chats = append(chats, id)
users = append(users, id)
r = MessageParsingRule{
Priority: 9999,
Description: "Config",
Rule: "^/config$",
MsgTypeID64: cacheObjSubType[`msg_bot_user_config`],
ChatID64: id,
SenderUserID64: id,
}
rules2 = append(rules2, r)
}
}
muxClients.RUnlock()

View File

@ -244,7 +244,7 @@ func MQKeepAliveWorker() {
log.Printf("New client, reloading rules ..\n")
resetMsgParsingRules()
msgParsingRules, err = loadMsgParsingRules()
logOnError(err, "initCache : message parsing rules")
logOnError(err, "MQKeepAliveWorker : message parsing rules")
}
}
}
@ -542,6 +542,8 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_shop_main_ack`]")
err = insertMsgShopMainAck(cwm)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgShopMainAck")
case cacheObjSubType[`msg_bot_user_config`]:
botUserConfig(m)
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)
}