采用视频和文章同步学习
This commit is contained in:
parent
c544a99f40
commit
567f26c2c0
16
lib/core.go
16
lib/core.go
|
@ -306,6 +306,22 @@ func Clip(in io.Reader, out io.Writer, wi, hi, x0, y0, x1, y1, quality int) (err
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WaitStudy(user *User) {
|
||||||
|
i := 0
|
||||||
|
for i <= 180 {
|
||||||
|
score, err := GetUserScore(user.Cookies)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (score.Content["video"].CurrentScore >= score.Content["video"].MaxScore && score.Content["video_time"].CurrentScore >= score.Content["video_time"].MaxScore) &&
|
||||||
|
score.Content["article"].CurrentScore >= score.Content["article"].MaxScore {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(10 * time.Second)
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func GetPaymentStr(fi io.Reader) (paymentCodeUrl *gozxing.Result) {
|
func GetPaymentStr(fi io.Reader) (paymentCodeUrl *gozxing.Result) {
|
||||||
img, _, err := image.Decode(fi)
|
img, _, err := image.Decode(fi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -250,6 +250,9 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) {
|
||||||
// 填空题
|
// 填空题
|
||||||
switch {
|
switch {
|
||||||
case strings.Contains(categoryText, "填空题"):
|
case strings.Contains(categoryText, "填空题"):
|
||||||
|
if len(tips) < 1 {
|
||||||
|
tips = append(tips, "不知道")
|
||||||
|
}
|
||||||
err := FillBlank(page, tips)
|
err := FillBlank(page, tips)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("填空题答题失败" + err.Error())
|
log.Errorln("填空题答题失败" + err.Error())
|
||||||
|
|
|
@ -159,12 +159,12 @@ func (c *Core) LearnArticle(cookies []Cookie) {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
score, _ = GetUserScore(cookies)
|
||||||
if score.Content["article"].CurrentScore >= score.Content["article"].MaxScore {
|
if score.Content["article"].CurrentScore >= score.Content["article"].MaxScore {
|
||||||
log.Infoln("检测到本次阅读学习分数已满,退出学习")
|
log.Infoln("检测到本次阅读学习分数已满,退出学习")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
score, _ = GetUserScore(cookies)
|
|
||||||
tryCount++
|
tryCount++
|
||||||
} else {
|
} else {
|
||||||
log.Errorln("阅读学习出现异常,稍后可重新学习")
|
log.Errorln("阅读学习出现异常,稍后可重新学习")
|
||||||
|
@ -262,11 +262,12 @@ func (c *Core) LearnVideo(cookies []Cookie) {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
score, _ = GetUserScore(cookies)
|
||||||
if score.Content["video"].CurrentScore >= score.Content["video"].MaxScore && score.Content["video_time"].CurrentScore >= score.Content["video_time"].MaxScore {
|
if score.Content["video"].CurrentScore >= score.Content["video"].MaxScore && score.Content["video_time"].CurrentScore >= score.Content["video_time"].MaxScore {
|
||||||
log.Infoln("检测到本次视频学习分数已满,退出学习")
|
log.Infoln("检测到本次视频学习分数已满,退出学习")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
score, _ = GetUserScore(cookies)
|
|
||||||
tryCount++
|
tryCount++
|
||||||
} else {
|
} else {
|
||||||
log.Errorln("视频学习出现异常,稍后可重新学习")
|
log.Errorln("视频学习出现异常,稍后可重新学习")
|
||||||
|
|
|
@ -264,13 +264,14 @@ func study(bot *Telegram, args []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var cookies []Cookie
|
var cookies []Cookie
|
||||||
if len(users) == 1 {
|
switch {
|
||||||
|
case len(users) == 1:
|
||||||
bot.SendMsg("仅存在一名用户信息,自动进行学习")
|
bot.SendMsg("仅存在一名用户信息,自动进行学习")
|
||||||
cookies = users[0].Cookies
|
cookies = users[0].Cookies
|
||||||
} else if len(users) == 0 {
|
case len(users) == 0:
|
||||||
bot.SendMsg("未发现用户信息,请输入/login进行用户登录")
|
bot.SendMsg("未发现用户信息,请输入/login进行用户登录")
|
||||||
return
|
return
|
||||||
} else {
|
default:
|
||||||
if 0 <= len(args) {
|
if 0 <= len(args) {
|
||||||
i, err := strconv.Atoi(args[0])
|
i, err := strconv.Atoi(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -314,6 +315,7 @@ func study(bot *Telegram, args []string) {
|
||||||
defer core.Quit()
|
defer core.Quit()
|
||||||
core.LearnArticle(cookies)
|
core.LearnArticle(cookies)
|
||||||
core.LearnVideo(cookies)
|
core.LearnVideo(cookies)
|
||||||
|
WaitStudy(&User{Cookies: cookies})
|
||||||
core.RespondDaily(cookies, "daily")
|
core.RespondDaily(cookies, "daily")
|
||||||
core.RespondDaily(cookies, "weekly")
|
core.RespondDaily(cookies, "weekly")
|
||||||
core.RespondDaily(cookies, "special")
|
core.RespondDaily(cookies, "special")
|
||||||
|
|
6
main.go
6
main.go
|
@ -118,8 +118,9 @@ func do() {
|
||||||
log.Infoln("已选择用户: ", users[i-1].Nick)
|
log.Infoln("已选择用户: ", users[i-1].Nick)
|
||||||
}
|
}
|
||||||
|
|
||||||
//core.LearnArticle(cookies)
|
go core.LearnArticle(cookies)
|
||||||
core.LearnVideo(cookies)
|
go core.LearnVideo(cookies)
|
||||||
|
lib.WaitStudy(&lib.User{Cookies: cookies})
|
||||||
if config.Model == 2 {
|
if config.Model == 2 {
|
||||||
core.RespondDaily(cookies, "daily")
|
core.RespondDaily(cookies, "daily")
|
||||||
} else if config.Model == 3 {
|
} else if config.Model == 3 {
|
||||||
|
@ -127,6 +128,7 @@ func do() {
|
||||||
core.RespondDaily(cookies, "weekly")
|
core.RespondDaily(cookies, "weekly")
|
||||||
core.RespondDaily(cookies, "special")
|
core.RespondDaily(cookies, "special")
|
||||||
}
|
}
|
||||||
|
|
||||||
score, err := lib.GetUserScore(cookies)
|
score, err := lib.GetUserScore(cookies)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("获取成绩失败")
|
log.Errorln("获取成绩失败")
|
||||||
|
|
Loading…
Reference in New Issue