Skip to content

Commit

Permalink
chaoxing: add ShowLoopMessage switch
Browse files Browse the repository at this point in the history
  • Loading branch information
naivekun committed Nov 23, 2020
1 parent 3c94e3a commit e382980
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,40 @@ Usage of sign-your-horse.exe:
},
"provider": [
{
"name": "teachermate_cloud_default",
"module": "teachermate_cloud",
"config": {}
},
{
"name": "chaoxing_default",
"module": "chaoxing",
"name": "chaoxing_cloud_default",
"module": "chaoxing_cloud",
"config": {
"cookie": "",
"useragent": "",
"uid": "",
"courseid": "",
"classid": "",
"interval": 5
"classid": ""
}
},
{
"name": "chaoxing_cloud_default",
"module": "chaoxing_cloud",
"name": "teachermate_cloud_default",
"module": "teachermate_cloud",
"config": {}
},
{
"name": "chaoxing_default",
"module": "chaoxing",
"config": {
"cookie": "",
"useragent": "",
"uid": "",
"courseid": "",
"classid": ""
"classid": "",
"interval": 5,
"verbose": true
}
}
],
"reporter": [
{
"name": "console",
"config": {}
},
{
"name": "wechat",
"config": {
Expand All @@ -91,10 +96,6 @@ Usage of sign-your-horse.exe:
"toparty": 0,
"agentid": 0
}
},
{
"name": "console",
"config": {}
}
]
}
Expand All @@ -119,7 +120,8 @@ useragent: "User-Agent",
uid: "超星的uid,从cookie里面扣",
courseid: "课程ID",
classid: "班级ID",
interval: 轮询间隔
interval: 轮询间隔,
verbose: 是否显示轮询结果
```

### chaoxing_cloud
Expand Down
21 changes: 12 additions & 9 deletions provider/chaoxing/chaoxing.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import (
)

type ChaoxingProvider struct {
Alias string `json:"-"`
Cookie string `json:"cookie"`
UserAgent string `json:"useragent"`
UserID string `json:"uid"`
CourseID string `json:"courseid"`
ClassID string `json:"classid"`
TaskInterval int `json:"interval"`
Alias string `json:"-"`
Cookie string `json:"cookie"`
UserAgent string `json:"useragent"`
UserID string `json:"uid"`
CourseID string `json:"courseid"`
ClassID string `json:"classid"`
TaskInterval int `json:"interval"`
ShowLoopMessage bool `json:"verbose"`

PushMessageCallback func(string, string) error `json:"-"`
}

Expand Down Expand Up @@ -61,7 +63,7 @@ func (c *ChaoxingProvider) Task() {
}
taskListString = taskListString[:finishedSepIndex]
tasksString := extractTasksRegex.FindAll([]byte(taskListString), -1)
if len(tasksString) == 0 {
if len(tasksString) == 0 && c.ShowLoopMessage {
log.Println("[" + c.Alias + "]" + " no task to do at " + time.Now().String())
} else {
for _, task := range tasksString {
Expand Down Expand Up @@ -95,6 +97,7 @@ func (c *ChaoxingProvider) Push(_ string) {}

func init() {
provider.RegisterProvider("chaoxing", &ChaoxingProvider{
TaskInterval: 5,
TaskInterval: 5,
ShowLoopMessage: true,
})
}

0 comments on commit e382980

Please sign in to comment.