updatefix failure

This commit is contained in:
shoopea 2020-07-19 16:55:55 +02:00
parent 7dd7b1aff9
commit 912b6ae75e

53
bot.go
View File

@ -1592,6 +1592,59 @@ func botTimer(m *tb.Message) {
} }
r := regexp.MustCompile("^(?P<User>([0-9]+)(?P<Duration>([0-9]*(s|m|h))+) \"(?P<Msg>(.*))\"$")
if r.MatchString(m.Payload) {
if clt.TGUserID64 != cfg.Bot.Admin {
c := TGCommand{
Type: commandReplyMsg,
Text: "Admin only",
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
return
}
d, err := time.ParseDuration(r.ReplaceAllString(m.Payload, "${Duration}"))
if err != nil {
c := TGCommand{
Type: commandReplyMsg,
Text: fmt.Sprintf("%s", err),
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
} else {
userID, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${User}"), 10, 64)
p := JobPayloadMsgClient{
Text: r.ReplaceAllString(m.Payload, "${Msg}"),
MsgID64: int64(m.ID),
ChatID64: m.Chat.ID,
}
b, _ := json.Marshal(p)
t := time.Now().UTC().Add(d)
objID64, err := createJob(cacheObjSubType[`job_msg_client`], objJobPriority, userID, 0, t, b)
logOnError(err, "botTimer : createJob")
if err != nil {
c := TGCommand{
Type: commandReplyMsg,
Text: fmt.Sprintf("%s", err),
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
} else {
c := TGCommand{
Type: commandReplyMsg,
Text: fmt.Sprintf("Job #%d scheduled at %s", objID64, t.Format(time.RFC850)),
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
}
}
}
return return
} }