-
Notifications
You must be signed in to change notification settings - Fork 146
/
Copy pathmain.go
72 lines (63 loc) · 1.5 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"fmt"
"io"
"os"
"path"
"time"
rotates "github.com/lestrrat-go/file-rotatelogs"
log "github.com/sirupsen/logrus"
easy "github.com/t-tomalak/logrus-easy-formatter"
"github.com/huoxue1/study_xxqg/lib"
)
func init() {
config = lib.GetConfig()
logFormatter := &easy.Formatter{
TimestampFormat: "2006-01-02 15:04:05",
LogFormat: "[%time%] [%lvl%]: %msg% \n",
}
w, err := rotates.New(path.Join("logs", "%Y-%m-%d.log"), rotates.WithRotationTime(time.Hour*24))
if err != nil {
log.Errorf("rotates init err: %v", err)
panic(err)
}
log.SetOutput(io.MultiWriter(w, os.Stdout))
log.SetFormatter(logFormatter)
level, err := log.ParseLevel(config.LogLevel)
log.SetLevel(level)
log.Info(config)
}
var (
config lib.Config
)
func init() {
_, err := os.Stat(`./config/`)
if err != nil {
os.Mkdir("./config/", 0666)
return
}
}
func main() {
log.Infoln(`// 刷课模式,默认为1,
1:只刷文章何视频
2:只刷文章和视频和每日答题
3:刷文章和视频和每日答题每周答题和专项答题`)
log.Infoln("检测到模式", config.Model)
core := lib.Core{ShowBrowser: config.ShowBrowser}
defer core.Quit()
core.Init()
login, err := core.Login()
if err != nil {
return
}
fmt.Println(config)
core.LearnArticle(login)
core.LearnVideo(login)
if config.Model == 2 {
core.RespondDaily(login, "daily")
} else if config.Model == 3 {
core.RespondDaily(login, "daily")
core.RespondDaily(login, "weekly")
core.RespondDaily(login, "special")
}
}