mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
✨ manager cron 完善
This commit is contained in:
parent
6f4c40f450
commit
c0327fe733
@ -11,6 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
@ -256,11 +257,11 @@ func init() { // 插件主体
|
|||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
dateStrs := ctx.State["regex_matched"].([]string)
|
dateStrs := ctx.State["regex_matched"].([]string)
|
||||||
ts := timer.GetFilledTimer(dateStrs, ctx.Event.SelfID, false)
|
ts := timer.GetFilledTimer(dateStrs, ctx.Event.SelfID, false)
|
||||||
if ts.Enable {
|
if ts.En() {
|
||||||
go clock.RegisterTimer(ts, ctx.Event.GroupID, true)
|
go clock.RegisterTimer(ts, ctx.Event.GroupID, true)
|
||||||
ctx.SendChain(message.Text("记住了~"))
|
ctx.SendChain(message.Text("记住了~"))
|
||||||
} else {
|
} else {
|
||||||
ctx.SendChain(message.Text("参数非法!"))
|
ctx.SendChain(message.Text("参数非法:" + ts.Alert))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 定时 cron 提醒
|
// 定时 cron 提醒
|
||||||
@ -268,17 +269,22 @@ func init() { // 插件主体
|
|||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
dateStrs := ctx.State["regex_matched"].([]string)
|
dateStrs := ctx.State["regex_matched"].([]string)
|
||||||
var url, alert string
|
var url, alert string
|
||||||
if len(dateStrs) == 3 {
|
switch len(dateStrs) {
|
||||||
url = dateStrs[1]
|
case 4:
|
||||||
|
url = dateStrs[2]
|
||||||
|
alert = dateStrs[3]
|
||||||
|
case 3:
|
||||||
alert = dateStrs[2]
|
alert = dateStrs[2]
|
||||||
} else {
|
default:
|
||||||
alert = dateStrs[1]
|
ctx.SendChain(message.Text("参数非法!"))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
ts := timer.GetFilledCronTimer(dateStrs[0], alert, url, ctx.Event.SelfID)
|
logrus.Debugln("[manager] cron:", dateStrs[1])
|
||||||
|
ts := timer.GetFilledCronTimer(dateStrs[1], alert, url, ctx.Event.SelfID)
|
||||||
if clock.RegisterTimer(ts, ctx.Event.GroupID, true) {
|
if clock.RegisterTimer(ts, ctx.Event.GroupID, true) {
|
||||||
ctx.SendChain(message.Text("记住了~"))
|
ctx.SendChain(message.Text("记住了~"))
|
||||||
} else {
|
} else {
|
||||||
ctx.SendChain(message.Text("参数非法!"))
|
ctx.SendChain(message.Text("参数非法:" + ts.Alert))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 取消定时
|
// 取消定时
|
||||||
@ -298,7 +304,7 @@ func init() { // 插件主体
|
|||||||
zero.OnRegex(`^取消在"(.*)"的提醒`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).SetPriority(40).
|
zero.OnRegex(`^取消在"(.*)"的提醒`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).SetPriority(40).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
dateStrs := ctx.State["regex_matched"].([]string)
|
dateStrs := ctx.State["regex_matched"].([]string)
|
||||||
ts := timer.Timer{Cron: dateStrs[0]}
|
ts := timer.Timer{Cron: dateStrs[1]}
|
||||||
ti := ts.GetTimerInfo(ctx.Event.GroupID)
|
ti := ts.GetTimerInfo(ctx.Event.GroupID)
|
||||||
ok := clock.CancelTimer(ti)
|
ok := clock.CancelTimer(ti)
|
||||||
if ok {
|
if ok {
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
io "io"
|
io "io"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/utils/file"
|
"github.com/FloatTech/ZeroBot-Plugin/utils/file"
|
||||||
)
|
)
|
||||||
@ -50,15 +51,17 @@ func main() {
|
|||||||
if loadTimers(os.Args[1]) {
|
if loadTimers(os.Args[1]) {
|
||||||
timersmapnew.Timers = make(map[string]*Timer)
|
timersmapnew.Timers = make(map[string]*Timer)
|
||||||
for s, t := range timersmap.Timers {
|
for s, t := range timersmap.Timers {
|
||||||
timersmapnew.Timers[s] = &Timer{
|
tm := &Timer{
|
||||||
Enable: t.Enable,
|
Alert: t.Alert,
|
||||||
Alert: t.Alert,
|
Url: t.Url,
|
||||||
Url: t.Url,
|
|
||||||
Month: t.Month,
|
|
||||||
Day: t.Day,
|
|
||||||
Hour: t.Hour,
|
|
||||||
Minute: t.Minute,
|
|
||||||
}
|
}
|
||||||
|
tm.SetMonth(time.Month(t.Month))
|
||||||
|
tm.SetDay(int(t.Day))
|
||||||
|
tm.SetHour(int(t.Hour))
|
||||||
|
tm.SetMinute(int(t.Minute))
|
||||||
|
tm.SetWeek(time.Weekday(t.Week))
|
||||||
|
tm.SetEn(t.Enable)
|
||||||
|
timersmapnew.Timers[s] = tm
|
||||||
}
|
}
|
||||||
saveTimers(os.Args[2])
|
saveTimers(os.Args[2])
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,19 +21,14 @@ var _ = math.Inf
|
|||||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
type Timer struct {
|
type Timer struct {
|
||||||
Enable bool `protobuf:"varint,1,opt,name=enable,proto3" json:"enable,omitempty"`
|
Alert string `protobuf:"bytes,1,opt,name=alert,proto3" json:"alert,omitempty"`
|
||||||
Alert string `protobuf:"bytes,2,opt,name=alert,proto3" json:"alert,omitempty"`
|
Cron string `protobuf:"bytes,2,opt,name=cron,proto3" json:"cron,omitempty"`
|
||||||
Url string `protobuf:"bytes,4,opt,name=url,proto3" json:"url,omitempty"`
|
En1Month4Day5Week3Hour5Min6 int32 `protobuf:"varint,4,opt,name=en1month4day5week3hour5min6,proto3" json:"en1month4day5week3hour5min6,omitempty"`
|
||||||
Month int32 `protobuf:"varint,8,opt,name=month,proto3" json:"month,omitempty"`
|
Selfid int64 `protobuf:"varint,8,opt,name=selfid,proto3" json:"selfid,omitempty"`
|
||||||
Day int32 `protobuf:"varint,16,opt,name=day,proto3" json:"day,omitempty"`
|
Url string `protobuf:"bytes,16,opt,name=url,proto3" json:"url,omitempty"`
|
||||||
Week int32 `protobuf:"varint,32,opt,name=week,proto3" json:"week,omitempty"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
Hour int32 `protobuf:"varint,64,opt,name=hour,proto3" json:"hour,omitempty"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
Minute int32 `protobuf:"varint,128,opt,name=minute,proto3" json:"minute,omitempty"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
Selfid int64 `protobuf:"varint,129,opt,name=selfid,proto3" json:"selfid,omitempty"`
|
|
||||||
Cron string `protobuf:"bytes,130,opt,name=cron,proto3" json:"cron,omitempty"`
|
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
||||||
XXX_unrecognized []byte `json:"-"`
|
|
||||||
XXX_sizecache int32 `json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) Reset() { *m = Timer{} }
|
func (m *Timer) Reset() { *m = Timer{} }
|
||||||
@ -69,13 +64,6 @@ func (m *Timer) XXX_DiscardUnknown() {
|
|||||||
|
|
||||||
var xxx_messageInfo_Timer proto.InternalMessageInfo
|
var xxx_messageInfo_Timer proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *Timer) GetEnable() bool {
|
|
||||||
if m != nil {
|
|
||||||
return m.Enable
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetAlert() string {
|
func (m *Timer) GetAlert() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Alert
|
return m.Alert
|
||||||
@ -83,44 +71,16 @@ func (m *Timer) GetAlert() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) GetUrl() string {
|
func (m *Timer) GetCron() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Url
|
return m.Cron
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) GetMonth() int32 {
|
func (m *Timer) GetEn1Month4Day5Week3Hour5Min6() int32 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Month
|
return m.En1Month4Day5Week3Hour5Min6
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetDay() int32 {
|
|
||||||
if m != nil {
|
|
||||||
return m.Day
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetWeek() int32 {
|
|
||||||
if m != nil {
|
|
||||||
return m.Week
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetHour() int32 {
|
|
||||||
if m != nil {
|
|
||||||
return m.Hour
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetMinute() int32 {
|
|
||||||
if m != nil {
|
|
||||||
return m.Minute
|
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -132,9 +92,9 @@ func (m *Timer) GetSelfid() int64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) GetCron() string {
|
func (m *Timer) GetUrl() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Cron
|
return m.Url
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -195,26 +155,23 @@ func init() {
|
|||||||
func init() { proto.RegisterFile("timer.proto", fileDescriptor_ad0307ee16b652d2) }
|
func init() { proto.RegisterFile("timer.proto", fileDescriptor_ad0307ee16b652d2) }
|
||||||
|
|
||||||
var fileDescriptor_ad0307ee16b652d2 = []byte{
|
var fileDescriptor_ad0307ee16b652d2 = []byte{
|
||||||
// 293 bytes of a gzipped FileDescriptorProto
|
// 256 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xcf, 0x4a, 0xc3, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2e, 0xc9, 0xcc, 0x4d,
|
||||||
0x10, 0xc6, 0x9d, 0xb6, 0x09, 0xed, 0xc4, 0x43, 0x58, 0x45, 0x07, 0x91, 0x10, 0x72, 0xca, 0xa9,
|
0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x73, 0x94, 0xe6, 0x32, 0x72, 0xb1,
|
||||||
0x87, 0xea, 0x41, 0x3c, 0x89, 0x20, 0x9e, 0xbc, 0x2c, 0xbe, 0x40, 0x6a, 0x57, 0x1a, 0x9a, 0x3f,
|
0x86, 0x80, 0x58, 0x42, 0x22, 0x5c, 0xac, 0x89, 0x39, 0xa9, 0x45, 0x25, 0x12, 0x8c, 0x0a, 0x8c,
|
||||||
0x65, 0xb3, 0x51, 0x72, 0x53, 0x8f, 0x3e, 0x81, 0x8f, 0xe4, 0xd1, 0x27, 0x10, 0x89, 0x2f, 0x22,
|
0x1a, 0x9c, 0x41, 0x10, 0x8e, 0x90, 0x10, 0x17, 0x4b, 0x72, 0x51, 0x7e, 0x9e, 0x04, 0x13, 0x58,
|
||||||
0x3b, 0x1b, 0xa4, 0xb7, 0xef, 0xf7, 0x9b, 0x8f, 0x24, 0x33, 0xc1, 0xc0, 0xe4, 0xa5, 0xd2, 0xf3,
|
0x10, 0xcc, 0x16, 0x72, 0xe0, 0x92, 0x4e, 0xcd, 0x33, 0xcc, 0xcd, 0xcf, 0x2b, 0xc9, 0x30, 0x49,
|
||||||
0xad, 0xae, 0x4d, 0x2d, 0x3c, 0x86, 0xe4, 0x1b, 0xd0, 0xbb, 0xb7, 0x49, 0x1c, 0xa1, 0xaf, 0xaa,
|
0x49, 0xac, 0x34, 0x2d, 0x4f, 0x4d, 0xcd, 0x36, 0xce, 0xc8, 0x2f, 0x2d, 0x32, 0xcd, 0xcd, 0xcc,
|
||||||
0x6c, 0x59, 0x28, 0x82, 0x18, 0xd2, 0xa9, 0x1c, 0x48, 0x1c, 0xa2, 0x97, 0x15, 0x4a, 0x1b, 0x1a,
|
0x33, 0x93, 0x60, 0x51, 0x60, 0xd4, 0x60, 0x0d, 0xc2, 0xa7, 0x44, 0x48, 0x8c, 0x8b, 0xad, 0x38,
|
||||||
0xc5, 0x90, 0xce, 0xa4, 0x03, 0x11, 0xe2, 0xb8, 0xd5, 0x05, 0x4d, 0xd8, 0xd9, 0x68, 0x7b, 0x65,
|
0x35, 0x27, 0x2d, 0x33, 0x45, 0x82, 0x43, 0x81, 0x51, 0x83, 0x39, 0x08, 0xca, 0x13, 0x12, 0xe0,
|
||||||
0x5d, 0x99, 0x35, 0x4d, 0x63, 0x48, 0x3d, 0xe9, 0xc0, 0xf6, 0x56, 0x59, 0x47, 0x21, 0x3b, 0x1b,
|
0x62, 0x2e, 0x2d, 0xca, 0x91, 0x10, 0x00, 0x5b, 0x06, 0x62, 0x2a, 0x75, 0x31, 0x72, 0x71, 0x82,
|
||||||
0x85, 0xc0, 0xc9, 0xb3, 0x52, 0x1b, 0x8a, 0x59, 0x71, 0xb6, 0x6e, 0x5d, 0xb7, 0x9a, 0xae, 0x9c,
|
0xdd, 0x57, 0xec, 0x9b, 0x58, 0x20, 0x64, 0xc2, 0xc5, 0x06, 0x76, 0x76, 0xb1, 0x04, 0xa3, 0x02,
|
||||||
0xb3, 0x59, 0x1c, 0xa3, 0x5f, 0xe6, 0x55, 0x6b, 0x14, 0xbd, 0x00, 0xeb, 0x01, 0xed, 0xa0, 0x51,
|
0xb3, 0x06, 0xb7, 0x91, 0x8c, 0x1e, 0xc4, 0x4b, 0x70, 0x15, 0x50, 0x96, 0x6b, 0x5e, 0x49, 0x51,
|
||||||
0xc5, 0x63, 0xbe, 0xa2, 0x57, 0x3b, 0x18, 0xcb, 0x01, 0xc5, 0x01, 0x4e, 0x1e, 0x74, 0x5d, 0xd1,
|
0x65, 0x10, 0x54, 0xad, 0x94, 0x3b, 0x17, 0x37, 0x92, 0x30, 0xc8, 0x92, 0xec, 0xd4, 0x4a, 0xa8,
|
||||||
0x1b, 0xf0, 0x57, 0x31, 0x24, 0xef, 0x80, 0x33, 0x5e, 0xb0, 0xb9, 0xcb, 0xb6, 0xe2, 0x1c, 0x7d,
|
0x37, 0x41, 0x4c, 0x21, 0x25, 0x2e, 0xd6, 0xb2, 0xc4, 0x9c, 0xd2, 0x54, 0xb0, 0x2f, 0xb9, 0x8d,
|
||||||
0xde, 0xbb, 0x21, 0x88, 0xc7, 0x69, 0xb0, 0x38, 0x9d, 0xbb, 0x9b, 0xfc, 0x37, 0x86, 0x74, 0x53,
|
0x78, 0x90, 0x4d, 0x0d, 0x82, 0x48, 0x59, 0x31, 0x59, 0x30, 0x3a, 0x09, 0x9c, 0x78, 0x24, 0xc7,
|
||||||
0x19, 0xdd, 0xc9, 0xa1, 0x7b, 0x72, 0x8b, 0xc1, 0x8e, 0xb6, 0x3b, 0x6d, 0x54, 0x47, 0xee, 0x2d,
|
0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x33, 0x1e, 0xcb, 0x31, 0x24, 0xb1, 0x81,
|
||||||
0x36, 0x8a, 0x04, 0xbd, 0xa7, 0xac, 0x68, 0x15, 0xdf, 0x28, 0x58, 0xec, 0xef, 0x3e, 0x55, 0xba,
|
0x03, 0xd3, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xf5, 0xc1, 0x9e, 0x44, 0x5b, 0x01, 0x00, 0x00,
|
||||||
0xd1, 0xe5, 0xe8, 0x02, 0xae, 0xc3, 0xcf, 0x3e, 0x82, 0xaf, 0x3e, 0x82, 0x9f, 0x3e, 0x82, 0x8f,
|
|
||||||
0xdf, 0x68, 0x6f, 0xe9, 0xf3, 0xdf, 0x38, 0xfb, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x04, 0x03, 0x99,
|
|
||||||
0x28, 0x9c, 0x01, 0x00, 0x00,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) Marshal() (dAtA []byte, err error) {
|
func (m *Timer) Marshal() (dAtA []byte, err error) {
|
||||||
@ -241,78 +198,38 @@ func (m *Timer) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
i -= len(m.XXX_unrecognized)
|
i -= len(m.XXX_unrecognized)
|
||||||
copy(dAtA[i:], m.XXX_unrecognized)
|
copy(dAtA[i:], m.XXX_unrecognized)
|
||||||
}
|
}
|
||||||
if len(m.Cron) > 0 {
|
|
||||||
i -= len(m.Cron)
|
|
||||||
copy(dAtA[i:], m.Cron)
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(len(m.Cron)))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x92
|
|
||||||
}
|
|
||||||
if m.Selfid != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Selfid))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x88
|
|
||||||
}
|
|
||||||
if m.Minute != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Minute))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x80
|
|
||||||
}
|
|
||||||
if m.Hour != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Hour))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x4
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x80
|
|
||||||
}
|
|
||||||
if m.Week != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Week))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x2
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x80
|
|
||||||
}
|
|
||||||
if m.Day != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Day))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x1
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x80
|
|
||||||
}
|
|
||||||
if m.Month != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Month))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x40
|
|
||||||
}
|
|
||||||
if len(m.Url) > 0 {
|
if len(m.Url) > 0 {
|
||||||
i -= len(m.Url)
|
i -= len(m.Url)
|
||||||
copy(dAtA[i:], m.Url)
|
copy(dAtA[i:], m.Url)
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(len(m.Url)))
|
i = encodeVarintTimer(dAtA, i, uint64(len(m.Url)))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x22
|
dAtA[i] = 0x1
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x82
|
||||||
|
}
|
||||||
|
if m.Selfid != 0 {
|
||||||
|
i = encodeVarintTimer(dAtA, i, uint64(m.Selfid))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x40
|
||||||
|
}
|
||||||
|
if m.En1Month4Day5Week3Hour5Min6 != 0 {
|
||||||
|
i = encodeVarintTimer(dAtA, i, uint64(m.En1Month4Day5Week3Hour5Min6))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x20
|
||||||
|
}
|
||||||
|
if len(m.Cron) > 0 {
|
||||||
|
i -= len(m.Cron)
|
||||||
|
copy(dAtA[i:], m.Cron)
|
||||||
|
i = encodeVarintTimer(dAtA, i, uint64(len(m.Cron)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
}
|
}
|
||||||
if len(m.Alert) > 0 {
|
if len(m.Alert) > 0 {
|
||||||
i -= len(m.Alert)
|
i -= len(m.Alert)
|
||||||
copy(dAtA[i:], m.Alert)
|
copy(dAtA[i:], m.Alert)
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(len(m.Alert)))
|
i = encodeVarintTimer(dAtA, i, uint64(len(m.Alert)))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x12
|
dAtA[i] = 0xa
|
||||||
}
|
|
||||||
if m.Enable {
|
|
||||||
i--
|
|
||||||
if m.Enable {
|
|
||||||
dAtA[i] = 1
|
|
||||||
} else {
|
|
||||||
dAtA[i] = 0
|
|
||||||
}
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
}
|
}
|
||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
@ -387,36 +304,21 @@ func (m *Timer) Size() (n int) {
|
|||||||
}
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if m.Enable {
|
|
||||||
n += 2
|
|
||||||
}
|
|
||||||
l = len(m.Alert)
|
l = len(m.Alert)
|
||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 1 + l + sovTimer(uint64(l))
|
n += 1 + l + sovTimer(uint64(l))
|
||||||
}
|
}
|
||||||
l = len(m.Url)
|
l = len(m.Cron)
|
||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 1 + l + sovTimer(uint64(l))
|
n += 1 + l + sovTimer(uint64(l))
|
||||||
}
|
}
|
||||||
if m.Month != 0 {
|
if m.En1Month4Day5Week3Hour5Min6 != 0 {
|
||||||
n += 1 + sovTimer(uint64(m.Month))
|
n += 1 + sovTimer(uint64(m.En1Month4Day5Week3Hour5Min6))
|
||||||
}
|
|
||||||
if m.Day != 0 {
|
|
||||||
n += 2 + sovTimer(uint64(m.Day))
|
|
||||||
}
|
|
||||||
if m.Week != 0 {
|
|
||||||
n += 2 + sovTimer(uint64(m.Week))
|
|
||||||
}
|
|
||||||
if m.Hour != 0 {
|
|
||||||
n += 2 + sovTimer(uint64(m.Hour))
|
|
||||||
}
|
|
||||||
if m.Minute != 0 {
|
|
||||||
n += 2 + sovTimer(uint64(m.Minute))
|
|
||||||
}
|
}
|
||||||
if m.Selfid != 0 {
|
if m.Selfid != 0 {
|
||||||
n += 2 + sovTimer(uint64(m.Selfid))
|
n += 1 + sovTimer(uint64(m.Selfid))
|
||||||
}
|
}
|
||||||
l = len(m.Cron)
|
l = len(m.Url)
|
||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 2 + l + sovTimer(uint64(l))
|
n += 2 + l + sovTimer(uint64(l))
|
||||||
}
|
}
|
||||||
@ -487,26 +389,6 @@ func (m *Timer) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
switch fieldNum {
|
switch fieldNum {
|
||||||
case 1:
|
case 1:
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Enable", wireType)
|
|
||||||
}
|
|
||||||
var v int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
v |= int(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m.Enable = bool(v != 0)
|
|
||||||
case 2:
|
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Alert", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field Alert", wireType)
|
||||||
}
|
}
|
||||||
@ -538,153 +420,7 @@ func (m *Timer) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
m.Alert = string(dAtA[iNdEx:postIndex])
|
m.Alert = string(dAtA[iNdEx:postIndex])
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
case 4:
|
case 2:
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType)
|
|
||||||
}
|
|
||||||
var stringLen uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
stringLen |= uint64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
intStringLen := int(stringLen)
|
|
||||||
if intStringLen < 0 {
|
|
||||||
return ErrInvalidLengthTimer
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + intStringLen
|
|
||||||
if postIndex < 0 {
|
|
||||||
return ErrInvalidLengthTimer
|
|
||||||
}
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
m.Url = string(dAtA[iNdEx:postIndex])
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 8:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Month", wireType)
|
|
||||||
}
|
|
||||||
m.Month = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Month |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 16:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Day", wireType)
|
|
||||||
}
|
|
||||||
m.Day = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Day |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 32:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Week", wireType)
|
|
||||||
}
|
|
||||||
m.Week = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Week |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 64:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Hour", wireType)
|
|
||||||
}
|
|
||||||
m.Hour = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Hour |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 128:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Minute", wireType)
|
|
||||||
}
|
|
||||||
m.Minute = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Minute |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 129:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Selfid", wireType)
|
|
||||||
}
|
|
||||||
m.Selfid = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Selfid |= int64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 130:
|
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Cron", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field Cron", wireType)
|
||||||
}
|
}
|
||||||
@ -716,6 +452,76 @@ func (m *Timer) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
m.Cron = string(dAtA[iNdEx:postIndex])
|
m.Cron = string(dAtA[iNdEx:postIndex])
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
|
case 4:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field En1Month4Day5Week3Hour5Min6", wireType)
|
||||||
|
}
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowTimer
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 |= int32(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Selfid", wireType)
|
||||||
|
}
|
||||||
|
m.Selfid = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowTimer
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.Selfid |= int64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 16:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowTimer
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthTimer
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthTimer
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Url = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipTimer(dAtA[iNdEx:])
|
skippy, err := skipTimer(dAtA[iNdEx:])
|
||||||
|
|||||||
75
plugin_manager/timer/migrate/wrap.go
Normal file
75
plugin_manager/timer/migrate/wrap.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
func (m *Timer) En() (en bool) {
|
||||||
|
return m.En1Month4Day5Week3Hour5Min6&0x800000 != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Month() (mon time.Month) {
|
||||||
|
mon = time.Month((m.En1Month4Day5Week3Hour5Min6 & 0x780000) >> 19)
|
||||||
|
if mon == 0b1111 {
|
||||||
|
mon = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Day() (d int) {
|
||||||
|
d = int((m.En1Month4Day5Week3Hour5Min6 & 0x07c000) >> 14)
|
||||||
|
if d == 0b11111 {
|
||||||
|
d = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Week() (w time.Weekday) {
|
||||||
|
w = time.Weekday((m.En1Month4Day5Week3Hour5Min6 & 0x003800) >> 11)
|
||||||
|
if w == 0b111 {
|
||||||
|
w = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Hour() (h int) {
|
||||||
|
h = int((m.En1Month4Day5Week3Hour5Min6 & 0x0007c0) >> 6)
|
||||||
|
if h == 0b11111 {
|
||||||
|
h = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Minute() (min int) {
|
||||||
|
min = int(m.En1Month4Day5Week3Hour5Min6 & 0x00003f)
|
||||||
|
if min == 0b111111 {
|
||||||
|
min = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetEn(en bool) {
|
||||||
|
if en {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 |= 0x800000
|
||||||
|
} else {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 &= 0x7fffff
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetMonth(mon time.Month) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = ((int32(mon) << 19) & 0x780000) | (m.En1Month4Day5Week3Hour5Min6 & 0x87ffff)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetDay(d int) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = ((int32(d) << 14) & 0x07c000) | (m.En1Month4Day5Week3Hour5Min6 & 0xf83fff)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetWeek(w time.Weekday) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = ((int32(w) << 11) & 0x003800) | (m.En1Month4Day5Week3Hour5Min6 & 0xffc7ff)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetHour(h int) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = ((int32(h) << 6) & 0x0007c0) | (m.En1Month4Day5Week3Hour5Min6 & 0xfff83f)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetMinute(min int) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = (int32(min) & 0x00003f) | (m.En1Month4Day5Week3Hour5Min6 & 0xffffc0)
|
||||||
|
}
|
||||||
@ -13,5 +13,4 @@ func (ts *Timer) sendmsg(grp int64, ctx *zero.Ctx) {
|
|||||||
} else {
|
} else {
|
||||||
ctx.SendChain(atall, message.Text(ts.Alert), message.Image(ts.Url).Add("cache", "0"))
|
ctx.SendChain(atall, message.Text(ts.Alert), message.Image(ts.Url).Add("cache", "0"))
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -14,7 +15,7 @@ func (ts *Timer) GetTimerInfo(grp int64) string {
|
|||||||
if ts.Cron != "" {
|
if ts.Cron != "" {
|
||||||
return fmt.Sprintf("[%d]%s", grp, ts.Cron)
|
return fmt.Sprintf("[%d]%s", grp, ts.Cron)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("[%d]%d月%d日%d周%d:%d", grp, ts.Month, ts.Day, ts.Week, ts.Hour, ts.Minute)
|
return fmt.Sprintf("[%d]%d月%d日%d周%d:%d", grp, ts.Month(), ts.Day(), ts.Week(), ts.Hour(), ts.Minute())
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFilledCronTimer 获得以cron填充好的ts
|
// GetFilledCronTimer 获得以cron填充好的ts
|
||||||
@ -35,55 +36,60 @@ func GetFilledTimer(dateStrs []string, botqq int64, matchDateOnly bool) *Timer {
|
|||||||
minuteStr := []rune(dateStrs[4])
|
minuteStr := []rune(dateStrs[4])
|
||||||
|
|
||||||
var ts Timer
|
var ts Timer
|
||||||
ts.Month = chineseNum2Int(monthStr)
|
mon := time.Month(chineseNum2Int(monthStr))
|
||||||
if (ts.Month != -1 && ts.Month <= 0) || ts.Month > 12 { // 月份非法
|
if (mon != -1 && mon <= 0) || mon > 12 { // 月份非法
|
||||||
logrus.Println("[群管]月份非法!")
|
ts.Alert = "月份非法!"
|
||||||
return &ts
|
return &ts
|
||||||
}
|
}
|
||||||
|
ts.SetMonth(mon)
|
||||||
lenOfDW := len(dayWeekStr)
|
lenOfDW := len(dayWeekStr)
|
||||||
if lenOfDW == 4 { // 包括末尾的"日"
|
if lenOfDW == 4 { // 包括末尾的"日"
|
||||||
dayWeekStr = []rune{dayWeekStr[0], dayWeekStr[2]} // 去除中间的十
|
dayWeekStr = []rune{dayWeekStr[0], dayWeekStr[2]} // 去除中间的十
|
||||||
ts.Day = chineseNum2Int(dayWeekStr)
|
d := chineseNum2Int(dayWeekStr)
|
||||||
if (ts.Day != -1 && ts.Day <= 0) || ts.Day > 31 { // 日期非法
|
if (d != -1 && d <= 0) || d > 31 { // 日期非法
|
||||||
logrus.Println("[群管]日期非法1!")
|
ts.Alert = "日期非法1!"
|
||||||
return &ts
|
return &ts
|
||||||
}
|
}
|
||||||
|
ts.SetDay(d)
|
||||||
} else if dayWeekStr[lenOfDW-1] == rune('日') { // xx日
|
} else if dayWeekStr[lenOfDW-1] == rune('日') { // xx日
|
||||||
dayWeekStr = dayWeekStr[:lenOfDW-1]
|
dayWeekStr = dayWeekStr[:lenOfDW-1]
|
||||||
ts.Day = chineseNum2Int(dayWeekStr)
|
d := chineseNum2Int(dayWeekStr)
|
||||||
if (ts.Day != -1 && ts.Day <= 0) || ts.Day > 31 { // 日期非法
|
if (d != -1 && d <= 0) || d > 31 { // 日期非法
|
||||||
logrus.Println("[群管]日期非法2!")
|
ts.Alert = "日期非法2!"
|
||||||
return &ts
|
return &ts
|
||||||
}
|
}
|
||||||
|
ts.SetDay(d)
|
||||||
} else if dayWeekStr[0] == rune('每') { // 每周
|
} else if dayWeekStr[0] == rune('每') { // 每周
|
||||||
ts.Week = -1
|
ts.SetWeek(-1)
|
||||||
} else { // 周x
|
} else { // 周x
|
||||||
ts.Week = chineseNum2Int(dayWeekStr[1:])
|
w := chineseNum2Int(dayWeekStr[1:])
|
||||||
if ts.Week == 7 { // 周天是0
|
if w == 7 { // 周天是0
|
||||||
ts.Week = 0
|
w = 0
|
||||||
}
|
}
|
||||||
if ts.Week < 0 || ts.Week > 6 { // 星期非法
|
if w < 0 || w > 6 { // 星期非法
|
||||||
ts.Week = -11
|
ts.Alert = "星期非法!"
|
||||||
logrus.Println("[群管]星期非法!")
|
|
||||||
return &ts
|
return &ts
|
||||||
}
|
}
|
||||||
|
ts.SetWeek(time.Weekday(w))
|
||||||
}
|
}
|
||||||
if len(hourStr) == 3 {
|
if len(hourStr) == 3 {
|
||||||
hourStr = []rune{hourStr[0], hourStr[2]} // 去除中间的十
|
hourStr = []rune{hourStr[0], hourStr[2]} // 去除中间的十
|
||||||
}
|
}
|
||||||
ts.Hour = chineseNum2Int(hourStr)
|
h := chineseNum2Int(hourStr)
|
||||||
if ts.Hour < -1 || ts.Hour > 23 { // 小时非法
|
if h < -1 || h > 23 { // 小时非法
|
||||||
logrus.Println("[群管]小时非法!")
|
ts.Alert = "小时非法!"
|
||||||
return &ts
|
return &ts
|
||||||
}
|
}
|
||||||
|
ts.SetHour(h)
|
||||||
if len(minuteStr) == 3 {
|
if len(minuteStr) == 3 {
|
||||||
minuteStr = []rune{minuteStr[0], minuteStr[2]} // 去除中间的十
|
minuteStr = []rune{minuteStr[0], minuteStr[2]} // 去除中间的十
|
||||||
}
|
}
|
||||||
ts.Minute = chineseNum2Int(minuteStr)
|
min := chineseNum2Int(minuteStr)
|
||||||
if ts.Minute < -1 || ts.Minute > 59 { // 分钟非法
|
if min < -1 || min > 59 { // 分钟非法
|
||||||
logrus.Println("[群管]分钟非法!")
|
ts.Alert = "分钟非法!"
|
||||||
return &ts
|
return &ts
|
||||||
}
|
}
|
||||||
|
ts.SetMinute(min)
|
||||||
if !matchDateOnly {
|
if !matchDateOnly {
|
||||||
urlStr := dateStrs[5]
|
urlStr := dateStrs[5]
|
||||||
if urlStr != "" { // 是图片url
|
if urlStr != "" { // 是图片url
|
||||||
@ -96,14 +102,14 @@ func GetFilledTimer(dateStrs []string, botqq int64, matchDateOnly bool) *Timer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ts.Alert = dateStrs[6]
|
ts.Alert = dateStrs[6]
|
||||||
ts.Enable = true
|
ts.SetEn(true)
|
||||||
}
|
}
|
||||||
ts.Selfid = botqq
|
ts.Selfid = botqq
|
||||||
return &ts
|
return &ts
|
||||||
}
|
}
|
||||||
|
|
||||||
// chineseNum2Int 汉字数字转int,仅支持-10~99,最多两位数,其中"每"解释为-1,"每二"为-2,以此类推
|
// chineseNum2Int 汉字数字转int,仅支持-10~99,最多两位数,其中"每"解释为-1,"每二"为-2,以此类推
|
||||||
func chineseNum2Int(rs []rune) int32 {
|
func chineseNum2Int(rs []rune) int {
|
||||||
r := -1
|
r := -1
|
||||||
l := len(rs)
|
l := len(rs)
|
||||||
mai := rune('每')
|
mai := rune('每')
|
||||||
@ -128,7 +134,7 @@ func chineseNum2Int(rs []rune) int32 {
|
|||||||
r = ten + ge
|
r = ten + ge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return int32(r)
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// chineseChar2Int 处理单个字符的映射0~10
|
// chineseChar2Int 处理单个字符的映射0~10
|
||||||
|
|||||||
@ -17,12 +17,12 @@ func firstWeek(date *time.Time, week time.Weekday) (d time.Time) {
|
|||||||
|
|
||||||
func (ts *Timer) nextWakeTime() (date time.Time) {
|
func (ts *Timer) nextWakeTime() (date time.Time) {
|
||||||
date = time.Now()
|
date = time.Now()
|
||||||
m := ts.Month
|
m := ts.Month()
|
||||||
d := ts.Day
|
d := ts.Day()
|
||||||
h := ts.Hour
|
h := ts.Hour()
|
||||||
mn := ts.Minute
|
mn := ts.Minute()
|
||||||
w := ts.Week
|
w := ts.Week()
|
||||||
unit := time.Duration(int(ts.Minute)-date.Minute()) * time.Minute
|
unit := time.Duration(ts.Minute()-date.Minute()) * time.Minute
|
||||||
logrus.Debugln("[timer] unit init:", unit)
|
logrus.Debugln("[timer] unit init:", unit)
|
||||||
if mn >= 0 {
|
if mn >= 0 {
|
||||||
switch {
|
switch {
|
||||||
@ -49,39 +49,39 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
|
|||||||
logrus.Debugln("[timer] unit:", unit)
|
logrus.Debugln("[timer] unit:", unit)
|
||||||
stable := 0
|
stable := 0
|
||||||
if mn < 0 {
|
if mn < 0 {
|
||||||
mn = int32(date.Minute())
|
mn = date.Minute()
|
||||||
}
|
}
|
||||||
if h < 0 {
|
if h < 0 {
|
||||||
h = int32(date.Hour())
|
h = date.Hour()
|
||||||
} else {
|
} else {
|
||||||
stable |= 0x8
|
stable |= 0x8
|
||||||
}
|
}
|
||||||
if d < 0 {
|
if d < 0 {
|
||||||
d = int32(date.Day())
|
d = date.Day()
|
||||||
} else if d > 0 {
|
} else if d > 0 {
|
||||||
stable |= 0x4
|
stable |= 0x4
|
||||||
} else {
|
} else {
|
||||||
d = int32(date.Day())
|
d = date.Day()
|
||||||
if w >= 0 {
|
if w >= 0 {
|
||||||
stable |= 0x2
|
stable |= 0x2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if m < 0 {
|
if m < 0 {
|
||||||
m = int32(date.Month())
|
m = date.Month()
|
||||||
} else {
|
} else {
|
||||||
stable |= 0x1
|
stable |= 0x1
|
||||||
}
|
}
|
||||||
switch stable {
|
switch stable {
|
||||||
case 0b0101:
|
case 0b0101:
|
||||||
if ts.Day != int32(time.Now().Day()) || ts.Month != int32(time.Now().Month()) {
|
if ts.Day() != time.Now().Day() || ts.Month() != time.Now().Month() {
|
||||||
h = 0
|
h = 0
|
||||||
}
|
}
|
||||||
case 0b1001:
|
case 0b1001:
|
||||||
if ts.Month != int32(time.Now().Month()) {
|
if ts.Month() != time.Now().Month() {
|
||||||
d = 0
|
d = 0
|
||||||
}
|
}
|
||||||
case 0b0001:
|
case 0b0001:
|
||||||
if ts.Month != int32(time.Now().Month()) {
|
if ts.Month() != time.Now().Month() {
|
||||||
d = 0
|
d = 0
|
||||||
h = 0
|
h = 0
|
||||||
}
|
}
|
||||||
@ -95,13 +95,13 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
|
|||||||
}
|
}
|
||||||
logrus.Debugln("[timer] date after add:", date)
|
logrus.Debugln("[timer] date after add:", date)
|
||||||
if time.Until(date) <= 0 {
|
if time.Until(date) <= 0 {
|
||||||
if ts.Month < 0 {
|
if ts.Month() < 0 {
|
||||||
if ts.Day > 0 || (ts.Day == 0 && ts.Week >= 0) {
|
if ts.Day() > 0 || (ts.Day() == 0 && ts.Week() >= 0) {
|
||||||
date = date.AddDate(0, 1, 0)
|
date = date.AddDate(0, 1, 0)
|
||||||
} else if ts.Day < 0 || ts.Week < 0 {
|
} else if ts.Day() < 0 || ts.Week() < 0 {
|
||||||
if ts.Hour > 0 {
|
if ts.Hour() > 0 {
|
||||||
date = date.AddDate(0, 0, 1)
|
date = date.AddDate(0, 0, 1)
|
||||||
} else if ts.Minute > 0 {
|
} else if ts.Minute() > 0 {
|
||||||
date = date.Add(time.Hour)
|
date = date.Add(time.Hour)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
logrus.Debugln("[timer] date after s4:", date)
|
logrus.Debugln("[timer] date after s4:", date)
|
||||||
if stable&0x2 != 0 && int32(date.Weekday()) != w {
|
if stable&0x2 != 0 && date.Weekday() != w {
|
||||||
switch {
|
switch {
|
||||||
case stable*0x1 == 0:
|
case stable*0x1 == 0:
|
||||||
date = date.AddDate(0, 1, 0)
|
date = date.AddDate(0, 1, 0)
|
||||||
@ -149,8 +149,8 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ts *Timer) judgeHM(grp int64) {
|
func (ts *Timer) judgeHM(grp int64) {
|
||||||
if ts.Hour < 0 || ts.Hour == int32(time.Now().Hour()) {
|
if ts.Hour() < 0 || ts.Hour() == time.Now().Hour() {
|
||||||
if ts.Minute < 0 || ts.Minute == int32(time.Now().Minute()) {
|
if ts.Minute() < 0 || ts.Minute() == time.Now().Minute() {
|
||||||
if ts.Selfid != 0 {
|
if ts.Selfid != 0 {
|
||||||
ts.sendmsg(grp, zero.GetBot(ts.Selfid))
|
ts.sendmsg(grp, zero.GetBot(ts.Selfid))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -48,6 +48,7 @@ func NewClock(pbfile string) (c Clock) {
|
|||||||
c.pbfile = &pbfile
|
c.pbfile = &pbfile
|
||||||
c.cron = cron.New()
|
c.cron = cron.New()
|
||||||
c.entries = make(map[string]cron.EntryID)
|
c.entries = make(map[string]cron.EntryID)
|
||||||
|
c.cron.Start()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,15 +57,12 @@ func (c *Clock) RegisterTimer(ts *Timer, grp int64, save bool) bool {
|
|||||||
key := ts.GetTimerInfo(grp)
|
key := ts.GetTimerInfo(grp)
|
||||||
t, ok := c.GetTimer(key)
|
t, ok := c.GetTimer(key)
|
||||||
if t != ts && ok { // 避免重复注册定时器
|
if t != ts && ok { // 避免重复注册定时器
|
||||||
t.Enable = false
|
t.SetEn(false)
|
||||||
}
|
}
|
||||||
c.timersmu.Lock()
|
c.timersmu.Lock()
|
||||||
(*c.timers)[key] = ts
|
(*c.timers)[key] = ts
|
||||||
c.timersmu.Unlock()
|
c.timersmu.Unlock()
|
||||||
if save {
|
logrus.Println("[群管]注册计时器", key)
|
||||||
c.SaveTimers()
|
|
||||||
}
|
|
||||||
logrus.Printf("[群管]注册计时器[%t]%s", ts.Enable, key)
|
|
||||||
if ts.Cron != "" {
|
if ts.Cron != "" {
|
||||||
var ctx *zero.Ctx
|
var ctx *zero.Ctx
|
||||||
if ts.Selfid != 0 {
|
if ts.Selfid != 0 {
|
||||||
@ -81,20 +79,27 @@ func (c *Clock) RegisterTimer(ts *Timer, grp int64, save bool) bool {
|
|||||||
c.entmu.Lock()
|
c.entmu.Lock()
|
||||||
c.entries[key] = eid
|
c.entries[key] = eid
|
||||||
c.entmu.Unlock()
|
c.entmu.Unlock()
|
||||||
|
if save {
|
||||||
|
c.SaveTimers()
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
ts.Alert = err.Error()
|
||||||
} else {
|
} else {
|
||||||
for ts.Enable {
|
if save {
|
||||||
|
c.SaveTimers()
|
||||||
|
}
|
||||||
|
for ts.En() {
|
||||||
nextdate := ts.nextWakeTime()
|
nextdate := ts.nextWakeTime()
|
||||||
sleepsec := time.Until(nextdate)
|
sleepsec := time.Until(nextdate)
|
||||||
logrus.Printf("[群管]计时器%s将睡眠%ds", key, sleepsec/time.Second)
|
logrus.Printf("[群管]计时器%s将睡眠%ds", key, sleepsec/time.Second)
|
||||||
time.Sleep(sleepsec)
|
time.Sleep(sleepsec)
|
||||||
if ts.Enable {
|
if ts.En() {
|
||||||
if ts.Month < 0 || ts.Month == int32(time.Now().Month()) {
|
if ts.Month() < 0 || ts.Month() == time.Now().Month() {
|
||||||
if ts.Day < 0 || ts.Day == int32(time.Now().Day()) {
|
if ts.Day() < 0 || ts.Day() == time.Now().Day() {
|
||||||
ts.judgeHM(grp)
|
ts.judgeHM(grp)
|
||||||
} else if ts.Day == 0 {
|
} else if ts.Day() == 0 {
|
||||||
if ts.Week < 0 || ts.Week == int32(time.Now().Weekday()) {
|
if ts.Week() < 0 || ts.Week() == time.Now().Weekday() {
|
||||||
ts.judgeHM(grp)
|
ts.judgeHM(grp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +121,7 @@ func (c *Clock) CancelTimer(key string) bool {
|
|||||||
delete(c.entries, key)
|
delete(c.entries, key)
|
||||||
c.entmu.Unlock()
|
c.entmu.Unlock()
|
||||||
} else {
|
} else {
|
||||||
t.Enable = false
|
t.SetEn(false)
|
||||||
}
|
}
|
||||||
c.timersmu.Lock()
|
c.timersmu.Lock()
|
||||||
delete(*c.timers, key) // 避免重复取消
|
delete(*c.timers, key) // 避免重复取消
|
||||||
|
|||||||
@ -23,19 +23,14 @@ var _ = math.Inf
|
|||||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
type Timer struct {
|
type Timer struct {
|
||||||
Enable bool `protobuf:"varint,1,opt,name=enable,proto3" json:"enable,omitempty"`
|
Alert string `protobuf:"bytes,1,opt,name=alert,proto3" json:"alert,omitempty"`
|
||||||
Alert string `protobuf:"bytes,2,opt,name=alert,proto3" json:"alert,omitempty"`
|
Cron string `protobuf:"bytes,2,opt,name=cron,proto3" json:"cron,omitempty"`
|
||||||
Url string `protobuf:"bytes,4,opt,name=url,proto3" json:"url,omitempty"`
|
En1Month4Day5Week3Hour5Min6 int32 `protobuf:"varint,4,opt,name=en1month4day5week3hour5min6,proto3" json:"en1month4day5week3hour5min6,omitempty"`
|
||||||
Month int32 `protobuf:"varint,8,opt,name=month,proto3" json:"month,omitempty"`
|
Selfid int64 `protobuf:"varint,8,opt,name=selfid,proto3" json:"selfid,omitempty"`
|
||||||
Day int32 `protobuf:"varint,16,opt,name=day,proto3" json:"day,omitempty"`
|
Url string `protobuf:"bytes,16,opt,name=url,proto3" json:"url,omitempty"`
|
||||||
Week int32 `protobuf:"varint,32,opt,name=week,proto3" json:"week,omitempty"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
Hour int32 `protobuf:"varint,64,opt,name=hour,proto3" json:"hour,omitempty"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
Minute int32 `protobuf:"varint,128,opt,name=minute,proto3" json:"minute,omitempty"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
Selfid int64 `protobuf:"varint,129,opt,name=selfid,proto3" json:"selfid,omitempty"`
|
|
||||||
Cron string `protobuf:"bytes,130,opt,name=cron,proto3" json:"cron,omitempty"`
|
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
|
||||||
XXX_unrecognized []byte `json:"-"`
|
|
||||||
XXX_sizecache int32 `json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) Reset() { *m = Timer{} }
|
func (m *Timer) Reset() { *m = Timer{} }
|
||||||
@ -71,13 +66,6 @@ func (m *Timer) XXX_DiscardUnknown() {
|
|||||||
|
|
||||||
var xxx_messageInfo_Timer proto.InternalMessageInfo
|
var xxx_messageInfo_Timer proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *Timer) GetEnable() bool {
|
|
||||||
if m != nil {
|
|
||||||
return m.Enable
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetAlert() string {
|
func (m *Timer) GetAlert() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Alert
|
return m.Alert
|
||||||
@ -85,44 +73,16 @@ func (m *Timer) GetAlert() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) GetUrl() string {
|
func (m *Timer) GetCron() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Url
|
return m.Cron
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) GetMonth() int32 {
|
func (m *Timer) GetEn1Month4Day5Week3Hour5Min6() int32 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Month
|
return m.En1Month4Day5Week3Hour5Min6
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetDay() int32 {
|
|
||||||
if m != nil {
|
|
||||||
return m.Day
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetWeek() int32 {
|
|
||||||
if m != nil {
|
|
||||||
return m.Week
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetHour() int32 {
|
|
||||||
if m != nil {
|
|
||||||
return m.Hour
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Timer) GetMinute() int32 {
|
|
||||||
if m != nil {
|
|
||||||
return m.Minute
|
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -134,9 +94,9 @@ func (m *Timer) GetSelfid() int64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) GetCron() string {
|
func (m *Timer) GetUrl() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Cron
|
return m.Url
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -197,26 +157,23 @@ func init() {
|
|||||||
func init() { proto.RegisterFile("timer.proto", fileDescriptor_ad0307ee16b652d2) }
|
func init() { proto.RegisterFile("timer.proto", fileDescriptor_ad0307ee16b652d2) }
|
||||||
|
|
||||||
var fileDescriptor_ad0307ee16b652d2 = []byte{
|
var fileDescriptor_ad0307ee16b652d2 = []byte{
|
||||||
// 293 bytes of a gzipped FileDescriptorProto
|
// 256 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xcf, 0x4a, 0xc3, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2e, 0xc9, 0xcc, 0x4d,
|
||||||
0x10, 0xc6, 0x9d, 0xb6, 0x09, 0xed, 0xc4, 0x43, 0x58, 0x45, 0x07, 0x91, 0x10, 0x72, 0xca, 0xa9,
|
0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x73, 0x94, 0xe6, 0x32, 0x72, 0xb1,
|
||||||
0x87, 0xea, 0x41, 0x3c, 0x89, 0x20, 0x9e, 0xbc, 0x2c, 0xbe, 0x40, 0x6a, 0x57, 0x1a, 0x9a, 0x3f,
|
0x86, 0x80, 0x58, 0x42, 0x22, 0x5c, 0xac, 0x89, 0x39, 0xa9, 0x45, 0x25, 0x12, 0x8c, 0x0a, 0x8c,
|
||||||
0x65, 0xb3, 0x51, 0x72, 0x53, 0x8f, 0x3e, 0x81, 0x8f, 0xe4, 0xd1, 0x27, 0x10, 0x89, 0x2f, 0x22,
|
0x1a, 0x9c, 0x41, 0x10, 0x8e, 0x90, 0x10, 0x17, 0x4b, 0x72, 0x51, 0x7e, 0x9e, 0x04, 0x13, 0x58,
|
||||||
0x3b, 0x1b, 0xa4, 0xb7, 0xef, 0xf7, 0x9b, 0x8f, 0x24, 0x33, 0xc1, 0xc0, 0xe4, 0xa5, 0xd2, 0xf3,
|
0x10, 0xcc, 0x16, 0x72, 0xe0, 0x92, 0x4e, 0xcd, 0x33, 0xcc, 0xcd, 0xcf, 0x2b, 0xc9, 0x30, 0x49,
|
||||||
0xad, 0xae, 0x4d, 0x2d, 0x3c, 0x86, 0xe4, 0x1b, 0xd0, 0xbb, 0xb7, 0x49, 0x1c, 0xa1, 0xaf, 0xaa,
|
0x49, 0xac, 0x34, 0x2d, 0x4f, 0x4d, 0xcd, 0x36, 0xce, 0xc8, 0x2f, 0x2d, 0x32, 0xcd, 0xcd, 0xcc,
|
||||||
0x6c, 0x59, 0x28, 0x82, 0x18, 0xd2, 0xa9, 0x1c, 0x48, 0x1c, 0xa2, 0x97, 0x15, 0x4a, 0x1b, 0x1a,
|
0x33, 0x93, 0x60, 0x51, 0x60, 0xd4, 0x60, 0x0d, 0xc2, 0xa7, 0x44, 0x48, 0x8c, 0x8b, 0xad, 0x38,
|
||||||
0xc5, 0x90, 0xce, 0xa4, 0x03, 0x11, 0xe2, 0xb8, 0xd5, 0x05, 0x4d, 0xd8, 0xd9, 0x68, 0x7b, 0x65,
|
0x35, 0x27, 0x2d, 0x33, 0x45, 0x82, 0x43, 0x81, 0x51, 0x83, 0x39, 0x08, 0xca, 0x13, 0x12, 0xe0,
|
||||||
0x5d, 0x99, 0x35, 0x4d, 0x63, 0x48, 0x3d, 0xe9, 0xc0, 0xf6, 0x56, 0x59, 0x47, 0x21, 0x3b, 0x1b,
|
0x62, 0x2e, 0x2d, 0xca, 0x91, 0x10, 0x00, 0x5b, 0x06, 0x62, 0x2a, 0x75, 0x31, 0x72, 0x71, 0x82,
|
||||||
0x85, 0xc0, 0xc9, 0xb3, 0x52, 0x1b, 0x8a, 0x59, 0x71, 0xb6, 0x6e, 0x5d, 0xb7, 0x9a, 0xae, 0x9c,
|
0xdd, 0x57, 0xec, 0x9b, 0x58, 0x20, 0x64, 0xc2, 0xc5, 0x06, 0x76, 0x76, 0xb1, 0x04, 0xa3, 0x02,
|
||||||
0xb3, 0x59, 0x1c, 0xa3, 0x5f, 0xe6, 0x55, 0x6b, 0x14, 0xbd, 0x00, 0xeb, 0x01, 0xed, 0xa0, 0x51,
|
0xb3, 0x06, 0xb7, 0x91, 0x8c, 0x1e, 0xc4, 0x4b, 0x70, 0x15, 0x50, 0x96, 0x6b, 0x5e, 0x49, 0x51,
|
||||||
0xc5, 0x63, 0xbe, 0xa2, 0x57, 0x3b, 0x18, 0xcb, 0x01, 0xc5, 0x01, 0x4e, 0x1e, 0x74, 0x5d, 0xd1,
|
0x65, 0x10, 0x54, 0xad, 0x94, 0x3b, 0x17, 0x37, 0x92, 0x30, 0xc8, 0x92, 0xec, 0xd4, 0x4a, 0xa8,
|
||||||
0x1b, 0xf0, 0x57, 0x31, 0x24, 0xef, 0x80, 0x33, 0x5e, 0xb0, 0xb9, 0xcb, 0xb6, 0xe2, 0x1c, 0x7d,
|
0x37, 0x41, 0x4c, 0x21, 0x25, 0x2e, 0xd6, 0xb2, 0xc4, 0x9c, 0xd2, 0x54, 0xb0, 0x2f, 0xb9, 0x8d,
|
||||||
0xde, 0xbb, 0x21, 0x88, 0xc7, 0x69, 0xb0, 0x38, 0x9d, 0xbb, 0x9b, 0xfc, 0x37, 0x86, 0x74, 0x53,
|
0x78, 0x90, 0x4d, 0x0d, 0x82, 0x48, 0x59, 0x31, 0x59, 0x30, 0x3a, 0x09, 0x9c, 0x78, 0x24, 0xc7,
|
||||||
0x19, 0xdd, 0xc9, 0xa1, 0x7b, 0x72, 0x8b, 0xc1, 0x8e, 0xb6, 0x3b, 0x6d, 0x54, 0x47, 0xee, 0x2d,
|
0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x33, 0x1e, 0xcb, 0x31, 0x24, 0xb1, 0x81,
|
||||||
0x36, 0x8a, 0x04, 0xbd, 0xa7, 0xac, 0x68, 0x15, 0xdf, 0x28, 0x58, 0xec, 0xef, 0x3e, 0x55, 0xba,
|
0x03, 0xd3, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xf5, 0xc1, 0x9e, 0x44, 0x5b, 0x01, 0x00, 0x00,
|
||||||
0xd1, 0xe5, 0xe8, 0x02, 0xae, 0xc3, 0xcf, 0x3e, 0x82, 0xaf, 0x3e, 0x82, 0x9f, 0x3e, 0x82, 0x8f,
|
|
||||||
0xdf, 0x68, 0x6f, 0xe9, 0xf3, 0xdf, 0x38, 0xfb, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x04, 0x03, 0x99,
|
|
||||||
0x28, 0x9c, 0x01, 0x00, 0x00,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Timer) Marshal() (dAtA []byte, err error) {
|
func (m *Timer) Marshal() (dAtA []byte, err error) {
|
||||||
@ -243,78 +200,38 @@ func (m *Timer) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
i -= len(m.XXX_unrecognized)
|
i -= len(m.XXX_unrecognized)
|
||||||
copy(dAtA[i:], m.XXX_unrecognized)
|
copy(dAtA[i:], m.XXX_unrecognized)
|
||||||
}
|
}
|
||||||
if len(m.Cron) > 0 {
|
|
||||||
i -= len(m.Cron)
|
|
||||||
copy(dAtA[i:], m.Cron)
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(len(m.Cron)))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x92
|
|
||||||
}
|
|
||||||
if m.Selfid != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Selfid))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x88
|
|
||||||
}
|
|
||||||
if m.Minute != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Minute))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x80
|
|
||||||
}
|
|
||||||
if m.Hour != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Hour))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x4
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x80
|
|
||||||
}
|
|
||||||
if m.Week != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Week))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x2
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x80
|
|
||||||
}
|
|
||||||
if m.Day != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Day))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x1
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x80
|
|
||||||
}
|
|
||||||
if m.Month != 0 {
|
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(m.Month))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x40
|
|
||||||
}
|
|
||||||
if len(m.Url) > 0 {
|
if len(m.Url) > 0 {
|
||||||
i -= len(m.Url)
|
i -= len(m.Url)
|
||||||
copy(dAtA[i:], m.Url)
|
copy(dAtA[i:], m.Url)
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(len(m.Url)))
|
i = encodeVarintTimer(dAtA, i, uint64(len(m.Url)))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x22
|
dAtA[i] = 0x1
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x82
|
||||||
|
}
|
||||||
|
if m.Selfid != 0 {
|
||||||
|
i = encodeVarintTimer(dAtA, i, uint64(m.Selfid))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x40
|
||||||
|
}
|
||||||
|
if m.En1Month4Day5Week3Hour5Min6 != 0 {
|
||||||
|
i = encodeVarintTimer(dAtA, i, uint64(m.En1Month4Day5Week3Hour5Min6))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x20
|
||||||
|
}
|
||||||
|
if len(m.Cron) > 0 {
|
||||||
|
i -= len(m.Cron)
|
||||||
|
copy(dAtA[i:], m.Cron)
|
||||||
|
i = encodeVarintTimer(dAtA, i, uint64(len(m.Cron)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
}
|
}
|
||||||
if len(m.Alert) > 0 {
|
if len(m.Alert) > 0 {
|
||||||
i -= len(m.Alert)
|
i -= len(m.Alert)
|
||||||
copy(dAtA[i:], m.Alert)
|
copy(dAtA[i:], m.Alert)
|
||||||
i = encodeVarintTimer(dAtA, i, uint64(len(m.Alert)))
|
i = encodeVarintTimer(dAtA, i, uint64(len(m.Alert)))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x12
|
dAtA[i] = 0xa
|
||||||
}
|
|
||||||
if m.Enable {
|
|
||||||
i--
|
|
||||||
if m.Enable {
|
|
||||||
dAtA[i] = 1
|
|
||||||
} else {
|
|
||||||
dAtA[i] = 0
|
|
||||||
}
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
}
|
}
|
||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
@ -389,36 +306,21 @@ func (m *Timer) Size() (n int) {
|
|||||||
}
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if m.Enable {
|
|
||||||
n += 2
|
|
||||||
}
|
|
||||||
l = len(m.Alert)
|
l = len(m.Alert)
|
||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 1 + l + sovTimer(uint64(l))
|
n += 1 + l + sovTimer(uint64(l))
|
||||||
}
|
}
|
||||||
l = len(m.Url)
|
l = len(m.Cron)
|
||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 1 + l + sovTimer(uint64(l))
|
n += 1 + l + sovTimer(uint64(l))
|
||||||
}
|
}
|
||||||
if m.Month != 0 {
|
if m.En1Month4Day5Week3Hour5Min6 != 0 {
|
||||||
n += 1 + sovTimer(uint64(m.Month))
|
n += 1 + sovTimer(uint64(m.En1Month4Day5Week3Hour5Min6))
|
||||||
}
|
|
||||||
if m.Day != 0 {
|
|
||||||
n += 2 + sovTimer(uint64(m.Day))
|
|
||||||
}
|
|
||||||
if m.Week != 0 {
|
|
||||||
n += 2 + sovTimer(uint64(m.Week))
|
|
||||||
}
|
|
||||||
if m.Hour != 0 {
|
|
||||||
n += 2 + sovTimer(uint64(m.Hour))
|
|
||||||
}
|
|
||||||
if m.Minute != 0 {
|
|
||||||
n += 2 + sovTimer(uint64(m.Minute))
|
|
||||||
}
|
}
|
||||||
if m.Selfid != 0 {
|
if m.Selfid != 0 {
|
||||||
n += 2 + sovTimer(uint64(m.Selfid))
|
n += 1 + sovTimer(uint64(m.Selfid))
|
||||||
}
|
}
|
||||||
l = len(m.Cron)
|
l = len(m.Url)
|
||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 2 + l + sovTimer(uint64(l))
|
n += 2 + l + sovTimer(uint64(l))
|
||||||
}
|
}
|
||||||
@ -489,26 +391,6 @@ func (m *Timer) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
switch fieldNum {
|
switch fieldNum {
|
||||||
case 1:
|
case 1:
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Enable", wireType)
|
|
||||||
}
|
|
||||||
var v int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
v |= int(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m.Enable = bool(v != 0)
|
|
||||||
case 2:
|
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Alert", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field Alert", wireType)
|
||||||
}
|
}
|
||||||
@ -540,153 +422,7 @@ func (m *Timer) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
m.Alert = string(dAtA[iNdEx:postIndex])
|
m.Alert = string(dAtA[iNdEx:postIndex])
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
case 4:
|
case 2:
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType)
|
|
||||||
}
|
|
||||||
var stringLen uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
stringLen |= uint64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
intStringLen := int(stringLen)
|
|
||||||
if intStringLen < 0 {
|
|
||||||
return ErrInvalidLengthTimer
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + intStringLen
|
|
||||||
if postIndex < 0 {
|
|
||||||
return ErrInvalidLengthTimer
|
|
||||||
}
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
m.Url = string(dAtA[iNdEx:postIndex])
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 8:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Month", wireType)
|
|
||||||
}
|
|
||||||
m.Month = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Month |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 16:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Day", wireType)
|
|
||||||
}
|
|
||||||
m.Day = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Day |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 32:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Week", wireType)
|
|
||||||
}
|
|
||||||
m.Week = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Week |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 64:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Hour", wireType)
|
|
||||||
}
|
|
||||||
m.Hour = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Hour |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 128:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Minute", wireType)
|
|
||||||
}
|
|
||||||
m.Minute = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Minute |= int32(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 129:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Selfid", wireType)
|
|
||||||
}
|
|
||||||
m.Selfid = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTimer
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Selfid |= int64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 130:
|
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Cron", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field Cron", wireType)
|
||||||
}
|
}
|
||||||
@ -718,6 +454,76 @@ func (m *Timer) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
m.Cron = string(dAtA[iNdEx:postIndex])
|
m.Cron = string(dAtA[iNdEx:postIndex])
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
|
case 4:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field En1Month4Day5Week3Hour5Min6", wireType)
|
||||||
|
}
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowTimer
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 |= int32(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Selfid", wireType)
|
||||||
|
}
|
||||||
|
m.Selfid = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowTimer
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.Selfid |= int64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 16:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowTimer
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthTimer
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthTimer
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Url = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipTimer(dAtA[iNdEx:])
|
skippy, err := skipTimer(dAtA[iNdEx:])
|
||||||
|
|||||||
@ -2,16 +2,11 @@ syntax = "proto3";
|
|||||||
package timer;
|
package timer;
|
||||||
|
|
||||||
message Timer {
|
message Timer {
|
||||||
bool enable = 1;
|
string alert = 1;
|
||||||
string alert = 2;
|
string cron = 2;
|
||||||
string url = 4;
|
int32 en1month4day5week3hour5min6 = 4;
|
||||||
int32 month = 8;
|
int64 selfid = 8;
|
||||||
int32 day = 16;
|
string url = 16;
|
||||||
int32 week = 32;
|
|
||||||
int32 hour = 64;
|
|
||||||
int32 minute = 128;
|
|
||||||
int64 selfid = 129;
|
|
||||||
string cron = 130;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message TimersMap {
|
message TimersMap {
|
||||||
|
|||||||
@ -10,11 +10,7 @@ import (
|
|||||||
func TestNextWakeTime(t *testing.T) {
|
func TestNextWakeTime(t *testing.T) {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
ts := &Timer{
|
ts := &Timer{
|
||||||
Month: 10,
|
En1Month4Day5Week3Hour5Min6: 0xffffff,
|
||||||
Day: -1,
|
|
||||||
Week: 0,
|
|
||||||
Hour: -1,
|
|
||||||
Minute: 6,
|
|
||||||
}
|
}
|
||||||
t1 := time.Until(ts.nextWakeTime())
|
t1 := time.Until(ts.nextWakeTime())
|
||||||
if t1 < 0 {
|
if t1 < 0 {
|
||||||
|
|||||||
75
plugin_manager/timer/wrap.go
Normal file
75
plugin_manager/timer/wrap.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package timer
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
func (m *Timer) En() (en bool) {
|
||||||
|
return m.En1Month4Day5Week3Hour5Min6&0x800000 != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Month() (mon time.Month) {
|
||||||
|
mon = time.Month((m.En1Month4Day5Week3Hour5Min6 & 0x780000) >> 19)
|
||||||
|
if mon == 0b1111 {
|
||||||
|
mon = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Day() (d int) {
|
||||||
|
d = int((m.En1Month4Day5Week3Hour5Min6 & 0x07c000) >> 14)
|
||||||
|
if d == 0b11111 {
|
||||||
|
d = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Week() (w time.Weekday) {
|
||||||
|
w = time.Weekday((m.En1Month4Day5Week3Hour5Min6 & 0x003800) >> 11)
|
||||||
|
if w == 0b111 {
|
||||||
|
w = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Hour() (h int) {
|
||||||
|
h = int((m.En1Month4Day5Week3Hour5Min6 & 0x0007c0) >> 6)
|
||||||
|
if h == 0b11111 {
|
||||||
|
h = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) Minute() (min int) {
|
||||||
|
min = int(m.En1Month4Day5Week3Hour5Min6 & 0x00003f)
|
||||||
|
if min == 0b111111 {
|
||||||
|
min = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetEn(en bool) {
|
||||||
|
if en {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 |= 0x800000
|
||||||
|
} else {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 &= 0x7fffff
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetMonth(mon time.Month) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = ((int32(mon) << 19) & 0x780000) | (m.En1Month4Day5Week3Hour5Min6 & 0x87ffff)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetDay(d int) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = ((int32(d) << 14) & 0x07c000) | (m.En1Month4Day5Week3Hour5Min6 & 0xf83fff)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetWeek(w time.Weekday) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = ((int32(w) << 11) & 0x003800) | (m.En1Month4Day5Week3Hour5Min6 & 0xffc7ff)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetHour(h int) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = ((int32(h) << 6) & 0x0007c0) | (m.En1Month4Day5Week3Hour5Min6 & 0xfff83f)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Timer) SetMinute(min int) {
|
||||||
|
m.En1Month4Day5Week3Hour5Min6 = (int32(min) & 0x00003f) | (m.En1Month4Day5Week3Hour5Min6 & 0xffffc0)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user