parent
fb8a0f5dad
commit
77373577fa
|
@ -3,6 +3,7 @@ package lib
|
|||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
@ -58,5 +59,8 @@ func GetConfig() Config {
|
|||
log.Errorln(err.Error())
|
||||
return Config{}
|
||||
}
|
||||
if runtime.GOOS == "linux" {
|
||||
config.ShowBrowser = false
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ func (c *Core) Init() {
|
|||
return
|
||||
}
|
||||
c.pw = pwt
|
||||
browser, err := pwt.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
|
||||
browser, err := pwt.WebKit.Launch(playwright.BrowserTypeLaunchOptions{
|
||||
Args: []string{
|
||||
"--disable-extensions",
|
||||
"--disable-gpu",
|
||||
|
|
|
@ -266,8 +266,8 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) {
|
|||
}
|
||||
}
|
||||
}
|
||||
log.Infoln("根据提示分别选择了", answer)
|
||||
}
|
||||
log.Infoln("根据提示分别选择了", RemoveRepByLoop(answer))
|
||||
err = radioCheck(page, answer)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -509,3 +509,21 @@ func checkNextBotton(page playwright.Page) {
|
|||
log.Infoln("已成功提交试卷")
|
||||
}
|
||||
}
|
||||
|
||||
// RemoveRepByLoop 通过两重循环过滤重复元素
|
||||
func RemoveRepByLoop(slc []string) []string {
|
||||
var result []string // 存放结果
|
||||
for i := range slc {
|
||||
flag := true
|
||||
for j := range result {
|
||||
if slc[i] == result[j] {
|
||||
flag = false // 存在重复元素,标识为false
|
||||
break
|
||||
}
|
||||
}
|
||||
if flag { // 标识为false,不添加进结果
|
||||
result = append(result, slc[i])
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ func (c *Core) LearnArticle(cookies []Cookie) {
|
|||
c.Push("text", "正在学习文章:"+links[n].Title)
|
||||
log.Infoln("文章发布时间:" + links[n].PublishTime)
|
||||
log.Infoln("文章学习链接:" + links[n].Url)
|
||||
learnTime := 50 + rand.Intn(5) + 10
|
||||
learnTime := 70 + rand.Intn(30) + 10
|
||||
for i := 0; i < learnTime; i++ {
|
||||
if c.IsQuit() {
|
||||
return
|
||||
|
@ -230,7 +230,7 @@ func (c *Core) LearnVideo(cookies []Cookie) {
|
|||
c.Push("text", "正在观看视频:"+links[n].Title)
|
||||
log.Infoln("视频发布时间:" + links[n].PublishTime)
|
||||
log.Infoln("视频学习链接:" + links[n].Url)
|
||||
learnTime := 50 + rand.Intn(5) + 10
|
||||
learnTime := 70 + rand.Intn(30) + 10
|
||||
for i := 0; i < learnTime; i++ {
|
||||
if c.IsQuit() {
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue