test pillage set

This commit is contained in:
shoopea 2020-02-10 12:28:16 +08:00
parent 2bd918a431
commit 74bfb46217
4 changed files with 42 additions and 0 deletions

8
bot.go
View File

@ -891,6 +891,14 @@ func botCraftItem(m *ChatWarsMessage, r *regexp.Regexp) {
return
}
func botUserConfigPillage(m *ChatWarsMessage, set bool) {
clt, _ := getLockedClient(m.TGUserID64, false)
clt.Config.InterceptPillage = set
clt.Mux.Unlock()
botUserConfig(m)
return
}
func botUserConfig(m *ChatWarsMessage) {
clt, _ := getLockedClient(m.TGUserID64, false)
clt.Mux.Unlock()

View File

@ -659,6 +659,16 @@
"name": "Get User Config in Bot",
"obj_type": "msg"
},
{
"intl_id": "msg_bot_user_config_pillage_on",
"name": "Set User Config Pillage ON",
"obj_type": "msg"
},
{
"intl_id": "msg_bot_user_config_pillage_off",
"name": "Set User Config Pillage OFF",
"obj_type": "msg"
},
{
"intl_id": "job_pillage",
"name": "Pillage job",

View File

@ -50,6 +50,26 @@ func resetMsgParsingRules() error {
SenderUserID64: id,
}
rules2 = append(rules2, r)
r = MessageParsingRule{
Priority: 9999,
Description: "Config",
Rule: "^/config_pillage_on$",
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_pillage_on`],
ChatID64: id,
SenderUserID64: id,
}
rules2 = append(rules2, r)
r = MessageParsingRule{
Priority: 9999,
Description: "Config",
Rule: "^/config_pillage_off$",
MsgTypeID64: cacheObjSubType[`msg_bot_user_config_pillage_off`],
ChatID64: id,
SenderUserID64: id,
}
rules2 = append(rules2, r)
}
}
muxClients.RUnlock()

View File

@ -544,6 +544,10 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgShopMainAck")
case cacheObjSubType[`msg_bot_user_config`]:
botUserConfig(m)
case cacheObjSubType[`msg_bot_user_config_pillage_on`]:
botUserConfigPillage(m, true)
case cacheObjSubType[`msg_bot_user_config_pillage_off`]:
botUserConfigPillage(m, false)
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)
}