test msg refresh

This commit is contained in:
shoopea 2020-06-26 11:45:56 +02:00
parent c7811f5e35
commit 82c50651ac
4 changed files with 49 additions and 0 deletions

31
bot.go
View File

@ -981,6 +981,37 @@ func botUserConfig(m *ChatWarsMessage) {
return
}
func botRefreshMsg(m *ChatWarsMessage, r *regexp.Regexp) {
p := JobPayloadMsgRefresh{}
p.ObjID64, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${MsgID}"), 10, 64)
b, _ := json.Marshal(p)
t := time.Now().UTC().Add(1 * time.Second)
_, err := createJob(cacheObjSubType[`job_msg_refresh`], objJobPriority, m.TGSenderUserID64, 0, t, b)
if err != nil {
c := TGCommand{
Type: commandReplyMsg,
Text: fmt.Sprintf("%s", err),
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
}
TGCmdQueue <- c
} else {
c := TGCommand{
Type: commandReplyMsg,
Text: "Refresh scheduled",
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
}
TGCmdQueue <- c
}
return
}
func botAlchAll(m *ChatWarsMessage) {
p := JobPayloadAlchAll{

View File

@ -699,6 +699,11 @@
"name": "Set User Config DEPOSIT OFF",
"obj_type": "msg"
},
{
"intl_id": "msg_refresh_cmd",
"name": "Refresh msg command",
"obj_type": "msg"
},
{
"intl_id": "msg_unknown_action",
"name": "Set Unknown Action",

View File

@ -42,6 +42,17 @@ func resetMsgParsingRules() error {
}
rules2 = append(rules2, r)
r = MessageParsingRule{
Priority: 9999,
Description: "Shutdown",
Rule: "^/msg_refresh (?P<MsgID>[0-9]*)$",
MsgTypeID64: cacheObjSubType[`msg_refresh_cmd`],
ChatID64: cfg.Bot.Admin,
SenderUserID64: 0,
BotCommand: true,
}
rules2 = append(rules2, r)
chats := make([]int64, 0)
users := make([]int64, 0)
chats = append(chats, cfg.Bot.Mainchat)

View File

@ -572,6 +572,8 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
_, err := parseSubTypeMessageAlchStockAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_alch_stock_ack`]")
case cacheObjSubType[`msg_skill_too_low`]:
case cacheObjSubType[`msg_refresh_cmd`]:
botRefreshMsg(m, rule.re)
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)
}