From 2bd796712221e0850a976590e73f3b6c717830db Mon Sep 17 00:00:00 2001 From: shoopea Date: Wed, 17 Jun 2020 12:15:54 +0200 Subject: [PATCH] test --- bot.go | 8 ++++++++ data/code_obj_sub_type.json | 10 ++++++++++ rules.go | 20 ++++++++++++++++++++ workers.go | 4 ++++ 4 files changed, 42 insertions(+) diff --git a/bot.go b/bot.go index f4ff979..bcc3513 100644 --- a/bot.go +++ b/bot.go @@ -916,6 +916,14 @@ func botUserConfigPillage(m *ChatWarsMessage, set bool) { return } +func botUserConfigDeposit(m *ChatWarsMessage, set bool) { + clt, _ := getLockedClient(m.TGUserID64, false) + clt.Config.AutoDeposit = set + clt.Mux.Unlock() + botUserConfig(m) + return +} + func botUserConfigWartime(m *ChatWarsMessage, set string) { clt, _ := getLockedClient(m.TGUserID64, false) clt.Config.Wartime = set diff --git a/data/code_obj_sub_type.json b/data/code_obj_sub_type.json index f11a07a..ccc9b8c 100644 --- a/data/code_obj_sub_type.json +++ b/data/code_obj_sub_type.json @@ -684,6 +684,16 @@ "name": "Set User Config DEF CASTLE", "obj_type": "msg" }, + { + "intl_id": "msg_bot_user_config_deposit_on", + "name": "Set User Config DEPOSIT ON", + "obj_type": "msg" + }, + { + "intl_id": "msg_bot_user_config_deposit_off", + "name": "Set User Config DEPOSIT OFF", + "obj_type": "msg" + }, { "intl_id": "msg_unknown_action", "name": "Set Unknown Action", diff --git a/rules.go b/rules.go index 9b90fef..6961114 100644 --- a/rules.go +++ b/rules.go @@ -110,6 +110,26 @@ func resetMsgParsingRules() error { SenderUserID64: id, } rules2 = append(rules2, r) + + r = MessageParsingRule{ + Priority: 9999, + Description: "Turn auto deposit on", + Rule: "^/config_deposit_on$", + MsgTypeID64: cacheObjSubType[`msg_bot_user_config_deposit_on`], + ChatID64: id, + SenderUserID64: id, + } + rules2 = append(rules2, r) + + r = MessageParsingRule{ + Priority: 9999, + Description: "Turn auto deposit off", + Rule: "^/config_deposit_on$", + MsgTypeID64: cacheObjSubType[`msg_bot_user_config_deposit_off`], + ChatID64: id, + SenderUserID64: id, + } + rules2 = append(rules2, r) } } muxClients.RUnlock() diff --git a/workers.go b/workers.go index a6eca6b..3095680 100644 --- a/workers.go +++ b/workers.go @@ -552,6 +552,10 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) { botUserConfigWartime(m, `/g_def`) case cacheObjSubType[`msg_bot_user_config_def_castle`]: botUserConfigWartime(m, `🛡Defend`) + case cacheObjSubType[`msg_bot_user_config_deposit_on`]: + botUserConfigDeposit(m, true) + case cacheObjSubType[`msg_bot_user_config_deposit_off`]: + botUserConfigDeposit(m, false) case cacheObjSubType[`msg_bot_shutdown`]: botShutdown() case cacheObjSubType[`msg_bot_rage_up`]: