test shutdown

This commit is contained in:
shoopea 2020-02-14 11:08:19 +08:00
parent 7fcbf15d51
commit 5cbca6d44c
4 changed files with 22 additions and 0 deletions

5
bot.go
View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"log"
"os"
"regexp"
"strconv"
"time"
@ -1350,3 +1351,7 @@ func botGetItemId(m *tb.Message) {
return
}
func botShutdown() {
os.Exit(0)
}

View File

@ -24,6 +24,11 @@
"name": "Guild deposit chat",
"obj_type": "msg"
},
{
"intl_id": "msg_bot_shutdown",
"name": "Request shutdown",
"obj_type": "msg"
},
{
"intl_id": "msg_shop_main_req",
"name": "Shop main request",

View File

@ -30,6 +30,16 @@ func resetMsgParsingRules() error {
}
rules2 = append(rules2, r)
r = MessageParsingRule{
Priority: 9999,
Description: "Shutdown",
Rule: "^/shutdown$",
MsgTypeID64: cacheObjSubType[`msg_bot_shutdown`],
ChatID64: cfg.Bot.Admin,
SenderUserID64: 0,
}
rules2 = append(rules2, r)
chats := make([]int64, 0)
users := make([]int64, 0)
chats = append(chats, cfg.Bot.Mainchat)

View File

@ -548,6 +548,8 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
botUserConfigPillage(m, true)
case cacheObjSubType[`msg_bot_user_config_pillage_off`]:
botUserConfigPillage(m, false)
case cacheObjSubType[`msg_bot_shutdown`]:
botShutdown()
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)
}