Skip to content

Commit

Permalink
chaoxing: improve tasktime
Browse files Browse the repository at this point in the history
  • Loading branch information
naivekun committed Dec 11, 2020
1 parent 978dafb commit 35fd7e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ Push方法在cloudscan收到消息后会被依次调用,模块会处理从clou

超星签到模块,各个参数说明如下

tasktime模块用于指定轮询签到时间,防止老师在非上课时间钓鱼执法
tasktime列表用于指定轮询签到时间,防止老师在非上课时间钓鱼执法,如果不需要此功能可以移除tasktime列表,模块将一直轮询签到。

若需要全天签到事件,可以填写duration为0

```
alias: "别名,用于推送消息时区分各个任务",
Expand All @@ -163,11 +165,11 @@ uid: "超星的uid,从cookie里面扣",
courseid: "课程ID",
classid: "班级ID",
interval: 轮询间隔,
tasktime: [ // 一个列表,成员如下
tasktime: [ // 一个列表,成员如下,不填可以一直轮询
{
weekday: 4, //周四,周日是0
time: "07:45", //任务开始时间,格式为HH:MM
duration: 20 //签到活动持续时间,单位是分钟
duration: 20 //签到活动持续时间,单位是分钟,填0或不填会默认全天事件
},
{
//支持多个时间段签到
Expand Down
4 changes: 4 additions & 0 deletions provider/chaoxing/chaoxing.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func (c *ChaoxingProvider) Run(pushMessage func(string, string) error) {
isAtTaskTime := false
for _, activeTime := range c.TaskTime {
if int(time.Now().Weekday()) == activeTime.Weekday {
if activeTime.Duration == 0 {
isAtTaskTime = true
break
}
t := parseActiveTime(&activeTime)
if t.Before(time.Now()) && t.Add(time.Minute*time.Duration(activeTime.Duration)).After(time.Now()) {
isAtTaskTime = true
Expand Down

0 comments on commit 35fd7e9

Please sign in to comment.