diff --git a/bot.go b/bot.go index a7be46d..5c010ff 100644 --- a/bot.go +++ b/bot.go @@ -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() diff --git a/data/code_obj_sub_type.json b/data/code_obj_sub_type.json index 721b11c..48fd677 100644 --- a/data/code_obj_sub_type.json +++ b/data/code_obj_sub_type.json @@ -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", diff --git a/rules.go b/rules.go index 19edddc..40c50ac 100644 --- a/rules.go +++ b/rules.go @@ -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() diff --git a/workers.go b/workers.go index 5690cf3..8eb1355 100644 --- a/workers.go +++ b/workers.go @@ -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) }