尝试修复专项答题
This commit is contained in:
parent
621bdf09c7
commit
64b6ec4c8d
|
@ -2,7 +2,7 @@
|
||||||
# 1:只刷文章何视频
|
# 1:只刷文章何视频
|
||||||
# 2:只刷文章和视频和每日答题
|
# 2:只刷文章和视频和每日答题
|
||||||
# 3:刷文章和视频和每日答题每周答题和专项答题
|
# 3:刷文章和视频和每日答题每周答题和专项答题
|
||||||
model: 2
|
model: 3
|
||||||
|
|
||||||
# 日志等级
|
# 日志等级
|
||||||
# panic
|
# panic
|
||||||
|
|
28
lib/core.go
28
lib/core.go
|
@ -63,11 +63,7 @@ type checkQrCodeResp struct {
|
||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init
|
// 初始化
|
||||||
/**
|
|
||||||
* @Description:
|
|
||||||
* @receiver c
|
|
||||||
*/
|
|
||||||
func (c *Core) Init() {
|
func (c *Core) Init() {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
c.initWindows()
|
c.initWindows()
|
||||||
|
@ -76,6 +72,7 @@ func (c *Core) Init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取Token
|
||||||
func GetToken(code, sign, pushId string) (bool, error) {
|
func GetToken(code, sign, pushId string) (bool, error) {
|
||||||
client := utils.GetClient()
|
client := utils.GetClient()
|
||||||
response, err := client.R().SetQueryParams(map[string]string{
|
response, err := client.R().SetQueryParams(map[string]string{
|
||||||
|
@ -113,13 +110,7 @@ func GetToken(code, sign, pushId string) (bool, error) {
|
||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateCode
|
// 生成二维码
|
||||||
/* @Description: 生成二维码
|
|
||||||
* @receiver c
|
|
||||||
* @return string 二维码连接
|
|
||||||
* @return string 二维码回调查询的code
|
|
||||||
* @return error
|
|
||||||
*/
|
|
||||||
func (c *Core) GenerateCode(pushID string) (string, string, error) {
|
func (c *Core) GenerateCode(pushID string) (string, string, error) {
|
||||||
client := utils.GetClient()
|
client := utils.GetClient()
|
||||||
g := new(gennerateResp)
|
g := new(gennerateResp)
|
||||||
|
@ -136,6 +127,7 @@ func (c *Core) GenerateCode(pushID string) (string, string, error) {
|
||||||
return codeURL, g.Result, err
|
return codeURL, g.Result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查二维码状态
|
||||||
func (c *Core) CheckQrCode(code, pushID string) (*model.User, bool, error) {
|
func (c *Core) CheckQrCode(code, pushID string) (*model.User, bool, error) {
|
||||||
client := utils.GetClient()
|
client := utils.GetClient()
|
||||||
checkQrCode := func() (bool, string) {
|
checkQrCode := func() (bool, string) {
|
||||||
|
@ -191,13 +183,7 @@ func (c *Core) CheckQrCode(code, pushID string) (*model.User, bool, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// L
|
// 轮询
|
||||||
/**
|
|
||||||
* @Description:
|
|
||||||
* @receiver c
|
|
||||||
* @return *model.User
|
|
||||||
* @return error
|
|
||||||
*/
|
|
||||||
func (c *Core) L(retryTimes int, pushID string) (*model.User, error) {
|
func (c *Core) L(retryTimes int, pushID string) (*model.User, error) {
|
||||||
_, codeData, err := c.GenerateCode(pushID)
|
_, codeData, err := c.GenerateCode(pushID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -218,6 +204,7 @@ func (c *Core) L(retryTimes int, pushID string) (*model.User, error) {
|
||||||
return c.L(retryTimes-1, pushID)
|
return c.L(retryTimes-1, pushID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化Windows系统
|
||||||
func (c *Core) initWindows() {
|
func (c *Core) initWindows() {
|
||||||
_, err := os.Stat("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe")
|
_, err := os.Stat("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -297,6 +284,7 @@ func (c *Core) initWindows() {
|
||||||
c.browser = browser
|
c.browser = browser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化非Windows系统
|
||||||
func (c *Core) initNotWindows() {
|
func (c *Core) initNotWindows() {
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -369,6 +357,7 @@ func (c *Core) initNotWindows() {
|
||||||
c.browser = browser
|
c.browser = browser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 关闭浏览器
|
||||||
func (c *Core) Quit() {
|
func (c *Core) Quit() {
|
||||||
err := c.browser.Close()
|
err := c.browser.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -381,6 +370,7 @@ func (c *Core) Quit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查浏览器是否关闭
|
||||||
func (c *Core) IsQuit() bool {
|
func (c *Core) IsQuit() bool {
|
||||||
return !c.browser.IsConnected()
|
return !c.browser.IsConnected()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,11 @@ func Study(core2 *Core, u *model.User) {
|
||||||
|
|
||||||
core2.LearnArticle(u)
|
core2.LearnArticle(u)
|
||||||
|
|
||||||
core2.RadioStation(u)
|
|
||||||
|
|
||||||
core2.RadioStation(u)
|
core2.RadioStation(u)
|
||||||
if config.Model == 2 {
|
if config.Model == 2 {
|
||||||
core2.RespondDaily(u, "daily")
|
core2.RespondDaily(u, "daily")
|
||||||
} else if config.Model == 3 {
|
} else if config.Model == 3 {
|
||||||
core2.RespondDaily(u, "daily")
|
core2.RespondDaily(u, "daily")
|
||||||
core2.RespondDaily(u, "weekly")
|
|
||||||
core2.RespondDaily(u, "special")
|
core2.RespondDaily(u, "special")
|
||||||
}
|
}
|
||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
|
@ -41,7 +38,6 @@ func Study(core2 *Core, u *model.User) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
score, _ = GetUserScore(u.ToCookies())
|
|
||||||
message := fmt.Sprintf("%v 学习完成,用时%.1f分钟\n%v", u.Nick, endTime.Sub(startTime).Minutes(), FormatScoreShort(score))
|
message := fmt.Sprintf("%v 学习完成,用时%.1f分钟\n%v", u.Nick, endTime.Sub(startTime).Minutes(), FormatScoreShort(score))
|
||||||
core2.Push(u.PushId, "flush", message)
|
core2.Push(u.PushId, "flush", message)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,7 @@ const (
|
||||||
SPECIALBUTTON = `#app > div > div.layout-body > div > div.my-points-section > div.my-points-content > div:nth-child(6) > div.my-points-card-footer > div.buttonbox > div`
|
SPECIALBUTTON = `#app > div > div.layout-body > div > div.my-points-section > div.my-points-content > div:nth-child(6) > div.my-points-card-footer > div.buttonbox > div`
|
||||||
)
|
)
|
||||||
|
|
||||||
// RespondDaily
|
// 每日答题
|
||||||
/* @Description:
|
|
||||||
* @receiver c
|
|
||||||
* @param user
|
|
||||||
* @param model
|
|
||||||
*/
|
|
||||||
func (c *Core) RespondDaily(user *model.User, model string) {
|
func (c *Core) RespondDaily(user *model.User, model string) {
|
||||||
|
|
||||||
var title string
|
var title string
|
||||||
|
@ -157,19 +152,6 @@ func (c *Core) RespondDaily(user *model.User, model string) {
|
||||||
}
|
}
|
||||||
case "special":
|
case "special":
|
||||||
{
|
{
|
||||||
// 检测是否已经完成
|
|
||||||
if score.Content["special"].CurrentScore >= score.Content["special"].MaxScore {
|
|
||||||
log.Infoln("检测到特殊答题已经完成,即将退出答题")
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// err = page.Click(SPECIALBUTTON)
|
|
||||||
// if err != nil {
|
|
||||||
// log.Errorln("跳转到积分页面错误")
|
|
||||||
//
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
|
|
||||||
//获取专项答题ID
|
//获取专项答题ID
|
||||||
id, err = getSpecialID(user.ToCookies())
|
id, err = getSpecialID(user.ToCookies())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -452,7 +434,7 @@ func (c *Core) RespondDaily(user *model.User, model string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAnswerPage(page playwright.Page, model string) bool {
|
func GetAnswerPage(page playwright.Page, model string) bool {
|
||||||
selectPages, err := page.QuerySelectorAll(`#app .ant-pagination .ant-pagination-item`)
|
selectPages, err := page.QuerySelectorAll(`#app .ant-pagination .ant-pagination-item`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("获取到页码失败")
|
log.Errorln("获取到页码失败")
|
||||||
|
@ -562,6 +544,7 @@ func radioCheck(page playwright.Page, answer []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取选项
|
||||||
func getOptions(page playwright.Page) ([]string, error) {
|
func getOptions(page playwright.Page) ([]string, error) {
|
||||||
handles, err := page.QuerySelectorAll(`.q-answer.choosable`)
|
handles, err := page.QuerySelectorAll(`.q-answer.choosable`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -579,6 +562,7 @@ func getOptions(page playwright.Page) ([]string, error) {
|
||||||
return options, err
|
return options, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取问题提示
|
||||||
func getTips(data string) []string {
|
func getTips(data string) []string {
|
||||||
data = strings.ReplaceAll(data, " ", "")
|
data = strings.ReplaceAll(data, " ", "")
|
||||||
data = strings.ReplaceAll(data, "\n", "")
|
data = strings.ReplaceAll(data, "\n", "")
|
||||||
|
@ -594,6 +578,7 @@ func getTips(data string) []string {
|
||||||
return tips
|
return tips
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 填空题
|
||||||
func FillBlank(page playwright.Page, tips []string) error {
|
func FillBlank(page playwright.Page, tips []string) error {
|
||||||
video := false
|
video := false
|
||||||
var answer []string
|
var answer []string
|
||||||
|
@ -648,12 +633,13 @@ func FillBlank(page playwright.Page, tips []string) error {
|
||||||
r := rand2.Intn(4) + 1
|
r := rand2.Intn(4) + 1
|
||||||
time.Sleep(time.Duration(r) * time.Second)
|
time.Sleep(time.Duration(r) * time.Second)
|
||||||
}
|
}
|
||||||
r := rand2.Intn(1) + 1
|
r := rand2.Intn(2)
|
||||||
time.Sleep(time.Duration(r) * time.Second)
|
time.Sleep(time.Duration(r) * time.Second)
|
||||||
checkNextBotton(page)
|
checkNextBotton(page)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查下一题按钮
|
||||||
func checkNextBotton(page playwright.Page) {
|
func checkNextBotton(page playwright.Page) {
|
||||||
btns, err := page.QuerySelectorAll(`#app .action-row > button`)
|
btns, err := page.QuerySelectorAll(`#app .action-row > button`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -704,6 +690,7 @@ func RemoveRepByLoop(slc []string) []string {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取专项答题ID
|
||||||
func getSpecialID(cookies []*http.Cookie) (int, error) {
|
func getSpecialID(cookies []*http.Cookie) (int, error) {
|
||||||
c := req.C()
|
c := req.C()
|
||||||
c.SetCommonCookies(cookies...)
|
c.SetCommonCookies(cookies...)
|
||||||
|
@ -754,6 +741,7 @@ func getSpecialID(cookies []*http.Cookie) (int, error) {
|
||||||
return 0, errors.New("未找到专项答题")
|
return 0, errors.New("未找到专项答题")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取每周答题ID
|
||||||
func getweekID(cookies []*http.Cookie) (int, error) {
|
func getweekID(cookies []*http.Cookie) (int, error) {
|
||||||
c := req.C()
|
c := req.C()
|
||||||
c.SetCommonCookies(cookies...)
|
c.SetCommonCookies(cookies...)
|
||||||
|
@ -819,7 +807,8 @@ func GetSpecialContent(cookies []*http.Cookie, id int) *SpecialContent {
|
||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
func getweekIDs(cookies []*http.Cookie) []int {
|
// 获取每周答题ID列表
|
||||||
|
func GetweekIDs(cookies []*http.Cookie) []int {
|
||||||
c := req.C()
|
c := req.C()
|
||||||
c.SetCommonCookies(cookies...)
|
c.SetCommonCookies(cookies...)
|
||||||
repo, err := c.R().SetQueryParams(map[string]string{"pageSize": "500", "pageNo": "1"}).Get(queryWeekList)
|
repo, err := c.R().SetQueryParams(map[string]string{"pageSize": "500", "pageNo": "1"}).Get(queryWeekList)
|
||||||
|
@ -852,7 +841,9 @@ func getweekIDs(cookies []*http.Cookie) []int {
|
||||||
}
|
}
|
||||||
return ids
|
return ids
|
||||||
}
|
}
|
||||||
func getSpecialIDs(cookies []*http.Cookie) []int {
|
|
||||||
|
// 获取专项答题ID列表
|
||||||
|
func GetSpecialIDs(cookies []*http.Cookie) []int {
|
||||||
c := req.C()
|
c := req.C()
|
||||||
|
|
||||||
c.SetCommonCookies(cookies...)
|
c.SetCommonCookies(cookies...)
|
||||||
|
|
|
@ -22,6 +22,7 @@ type Data struct {
|
||||||
MaxScore int `json:"max_score"`
|
MaxScore int `json:"max_score"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取用户总分
|
||||||
func GetUserScore(cookies []*http.Cookie) (Score, error) {
|
func GetUserScore(cookies []*http.Cookie) (Score, error) {
|
||||||
var score Score
|
var score Score
|
||||||
var resp []byte
|
var resp []byte
|
||||||
|
@ -41,7 +42,7 @@ func GetUserScore(cookies []*http.Cookie) (Score, error) {
|
||||||
|
|
||||||
response, err = client.R().SetCookies(cookies...).SetHeaders(header).Get(userTodaytotalscoreUrl)
|
response, err = client.R().SetCookies(cookies...).SetHeaders(header).Get(userTodaytotalscoreUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("获取用户总分错误" + err.Error())
|
log.Errorln("获取用户今日得分错误" + err.Error())
|
||||||
return Score{}, err
|
return Score{}, err
|
||||||
}
|
}
|
||||||
resp = response.Bytes()
|
resp = response.Bytes()
|
||||||
|
@ -49,7 +50,7 @@ func GetUserScore(cookies []*http.Cookie) (Score, error) {
|
||||||
|
|
||||||
response, err = client.R().SetCookies(cookies...).SetHeaders(header).Get(userRatescoreUrl)
|
response, err = client.R().SetCookies(cookies...).SetHeaders(header).Get(userRatescoreUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("获取用户总分错误" + err.Error())
|
log.Errorln("获取用户详情得分错误" + err.Error())
|
||||||
return Score{}, err
|
return Score{}, err
|
||||||
}
|
}
|
||||||
resp = response.Bytes()
|
resp = response.Bytes()
|
||||||
|
@ -77,6 +78,7 @@ func GetUserScore(cookies []*http.Cookie) (Score, error) {
|
||||||
return score, err
|
return score, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 输出总分
|
||||||
func PrintScore(score Score) string {
|
func PrintScore(score Score) string {
|
||||||
result := ""
|
result := ""
|
||||||
result += fmt.Sprintf("当前学习总积分:%d\n今日得分:%d\n", score.TotalScore, score.TodayScore)
|
result += fmt.Sprintf("当前学习总积分:%d\n今日得分:%d\n", score.TotalScore, score.TodayScore)
|
||||||
|
@ -92,6 +94,7 @@ func PrintScore(score Score) string {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 格式化总分
|
||||||
func FormatScore(score Score) string {
|
func FormatScore(score Score) string {
|
||||||
result := ""
|
result := ""
|
||||||
result += fmt.Sprintf("当前学习总积分:%d\n今日得分:%d\n", score.TotalScore, score.TodayScore)
|
result += fmt.Sprintf("当前学习总积分:%d\n今日得分:%d\n", score.TotalScore, score.TodayScore)
|
||||||
|
@ -104,6 +107,7 @@ func FormatScore(score Score) string {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 格式化短格式总分
|
||||||
func FormatScoreShort(score Score) string {
|
func FormatScoreShort(score Score) string {
|
||||||
result := ""
|
result := ""
|
||||||
result += fmt.Sprintf("当前学习总积分:%d\n今日得分:%d\n", score.TotalScore, score.TodayScore)
|
result += fmt.Sprintf("当前学习总积分:%d\n今日得分:%d\n", score.TotalScore, score.TodayScore)
|
||||||
|
|
23
lib/study.go
23
lib/study.go
|
@ -36,6 +36,7 @@ var (
|
||||||
"https://www.xuexi.cn/lgdata/3o3ufqgl8rsn.json",
|
"https://www.xuexi.cn/lgdata/3o3ufqgl8rsn.json",
|
||||||
"https://www.xuexi.cn/lgdata/525pi8vcj24p.json",
|
"https://www.xuexi.cn/lgdata/525pi8vcj24p.json",
|
||||||
"https://www.xuexi.cn/lgdata/1742g60067k.json"}
|
"https://www.xuexi.cn/lgdata/1742g60067k.json"}
|
||||||
|
|
||||||
yp_url_list = []string{
|
yp_url_list = []string{
|
||||||
"https://www.xuexi.cn/lgdata/1ode6kjlu7m.json",
|
"https://www.xuexi.cn/lgdata/1ode6kjlu7m.json",
|
||||||
"https://www.xuexi.cn/lgdata/1ggb81u8f7m.json",
|
"https://www.xuexi.cn/lgdata/1ggb81u8f7m.json",
|
||||||
|
@ -66,6 +67,7 @@ type Link struct {
|
||||||
DataValid bool `json:"dataValid"`
|
DataValid bool `json:"dataValid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取学习链接列表
|
||||||
func getLinks(model string) ([]Link, error) {
|
func getLinks(model string) ([]Link, error) {
|
||||||
UID := rand.Intn(20000000) + 10000000
|
UID := rand.Intn(20000000) + 10000000
|
||||||
learnUrl := ""
|
learnUrl := ""
|
||||||
|
@ -98,12 +100,7 @@ func getLinks(model string) ([]Link, error) {
|
||||||
return links, err
|
return links, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// LearnArticle
|
// 文章学习
|
||||||
/**
|
|
||||||
* @Description: 文章学习
|
|
||||||
* @receiver c
|
|
||||||
* @param cookies
|
|
||||||
*/
|
|
||||||
func (c *Core) LearnArticle(user *model.User) {
|
func (c *Core) LearnArticle(user *model.User) {
|
||||||
defer func() {
|
defer func() {
|
||||||
err := recover()
|
err := recover()
|
||||||
|
@ -215,12 +212,7 @@ func (c *Core) LearnArticle(user *model.User) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LearnVideo
|
// 视频学习
|
||||||
/**
|
|
||||||
* @Description: 视频学习
|
|
||||||
* @receiver c
|
|
||||||
* @param cookies
|
|
||||||
*/
|
|
||||||
func (c *Core) LearnVideo(user *model.User) {
|
func (c *Core) LearnVideo(user *model.User) {
|
||||||
defer func() {
|
defer func() {
|
||||||
err := recover()
|
err := recover()
|
||||||
|
@ -326,9 +318,7 @@ func (c *Core) LearnVideo(user *model.User) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// 音频学习
|
||||||
* @Description: 音频
|
|
||||||
*/
|
|
||||||
func (c *Core) RadioStation(user *model.User) {
|
func (c *Core) RadioStation(user *model.User) {
|
||||||
defer func() {
|
defer func() {
|
||||||
err := recover()
|
err := recover()
|
||||||
|
@ -348,9 +338,6 @@ func (c *Core) RadioStation(user *model.User) {
|
||||||
links, _ := getLinks("yp")
|
links, _ := getLinks("yp")
|
||||||
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("开始加载音频学习模块")
|
||||||
// core := Core{}
|
|
||||||
// core.Init()
|
|
||||||
|
|
||||||
context, err := c.browser.NewContext(playwright.BrowserNewContextOptions{
|
context, err := c.browser.NewContext(playwright.BrowserNewContextOptions{
|
||||||
Viewport: &playwright.BrowserNewContextOptionsViewport{
|
Viewport: &playwright.BrowserNewContextOptionsViewport{
|
||||||
Width: playwright.Int(1920),
|
Width: playwright.Int(1920),
|
||||||
|
|
|
@ -11,6 +11,7 @@ const (
|
||||||
queryWeekList = "https://pc-proxy-api.xuexi.cn/api/exam/service/practice/pc/weekly/more"
|
queryWeekList = "https://pc-proxy-api.xuexi.cn/api/exam/service/practice/pc/weekly/more"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 专项答题JSON结构
|
||||||
type SpecialList struct {
|
type SpecialList struct {
|
||||||
PageNo int `json:"pageNo"`
|
PageNo int `json:"pageNo"`
|
||||||
PageSize int `json:"pageSize"`
|
PageSize int `json:"pageSize"`
|
||||||
|
|
16
lib/user.go
16
lib/user.go
|
@ -10,14 +10,7 @@ import (
|
||||||
"github.com/sjkhsl/study_xxqg/utils"
|
"github.com/sjkhsl/study_xxqg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetUserInfo
|
// 获取用户信息
|
||||||
/**
|
|
||||||
* @Description: 获取用户信息
|
|
||||||
* @param cookies
|
|
||||||
* @return string
|
|
||||||
* @return string
|
|
||||||
* @return error
|
|
||||||
*/
|
|
||||||
func GetUserInfo(cookies []*http.Cookie) (string, string, error) {
|
func GetUserInfo(cookies []*http.Cookie) (string, string, error) {
|
||||||
var resp []byte
|
var resp []byte
|
||||||
response, err := utils.GetClient().R().SetCookies(cookies...).SetHeader("Cache-Control", "no-cache").Get(userInfoUrl)
|
response, err := utils.GetClient().R().SetCookies(cookies...).SetHeader("Cache-Control", "no-cache").Get(userInfoUrl)
|
||||||
|
@ -33,12 +26,7 @@ func GetUserInfo(cookies []*http.Cookie) (string, string, error) {
|
||||||
return uid, nick, err
|
return uid, nick, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckUserCookie
|
// 获取用户成绩
|
||||||
/**
|
|
||||||
* @Description: 获取用户成绩
|
|
||||||
* @param user
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
func CheckUserCookie(user *model.User) bool {
|
func CheckUserCookie(user *model.User) bool {
|
||||||
_, err := GetUserScore(user.ToCookies())
|
_, err := GetUserScore(user.ToCookies())
|
||||||
if err != nil && err.Error() == "token check failed" {
|
if err != nil && err.Error() == "token check failed" {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/playwright-community/playwright-go"
|
"github.com/playwright-community/playwright-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
func cookieToJar(cookies []Cookie) []*http.Cookie {
|
func CookieToJar(cookies []Cookie) []*http.Cookie {
|
||||||
var (
|
var (
|
||||||
cooks []*http.Cookie
|
cooks []*http.Cookie
|
||||||
)
|
)
|
||||||
|
@ -28,7 +28,7 @@ func cookieToJar(cookies []Cookie) []*http.Cookie {
|
||||||
return cooks
|
return cooks
|
||||||
}
|
}
|
||||||
|
|
||||||
func cookieToParam(cookies []Cookie) []playwright.BrowserContextAddCookiesOptionsCookies {
|
func CookieToParam(cookies []Cookie) []playwright.BrowserContextAddCookiesOptionsCookies {
|
||||||
var (
|
var (
|
||||||
cooks []playwright.BrowserContextAddCookiesOptionsCookies
|
cooks []playwright.BrowserContextAddCookiesOptionsCookies
|
||||||
)
|
)
|
||||||
|
|
|
@ -119,7 +119,7 @@ func qqStudy(event *Event, args []string) {
|
||||||
if len(users) == 1 {
|
if len(users) == 1 {
|
||||||
user = users[0]
|
user = users[0]
|
||||||
} else {
|
} else {
|
||||||
if len(args) < 0 {
|
if len(args) <= 0 {
|
||||||
event.Send("缺少序号参数,请输入 .study 序号")
|
event.Send("缺少序号参数,请输入 .study 序号")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -92,11 +92,11 @@ type Mather struct {
|
||||||
handle func(bot *Telegram, from int64, args []string)
|
handle func(bot *Telegram, from int64, args []string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Mather) getCommand() string {
|
func (m Mather) GetCommand() string {
|
||||||
return m.command
|
return m.command
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Mather) execute(bot *Telegram, from int64, args []string) {
|
func (m Mather) Execute(bot *Telegram, from int64, args []string) {
|
||||||
m.handle(bot, from, args)
|
m.handle(bot, from, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ func studyAll(bot *Telegram, from int64, args []string) {
|
||||||
core.LearnArticle(user)
|
core.LearnArticle(user)
|
||||||
core.RadioStation(user)
|
core.RadioStation(user)
|
||||||
core.RespondDaily(user, "daily")
|
core.RespondDaily(user, "daily")
|
||||||
core.RespondDaily(user, "weekly")
|
// core.RespondDaily(user, "weekly")
|
||||||
core.RespondDaily(user, "special")
|
core.RespondDaily(user, "special")
|
||||||
c <- 1
|
c <- 1
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -103,8 +103,6 @@ func initWechat() {
|
||||||
log.Errorln("添加客服失败" + err.Error())
|
log.Errorln("添加客服失败" + err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
wx.HandleFunc("eventCLICK", func(wx *mp.WeiXin, w http.ResponseWriter, r *request.WeiXinRequest, timestamp, nonce string) {
|
wx.HandleFunc("eventCLICK", func(wx *mp.WeiXin, w http.ResponseWriter, r *request.WeiXinRequest, timestamp, nonce string) {
|
||||||
if lastNonce == nonce {
|
if lastNonce == nonce {
|
||||||
|
|
|
@ -316,7 +316,7 @@ func study() gin.HandlerFunc {
|
||||||
core.RespondDaily(user, "daily")
|
core.RespondDaily(user, "daily")
|
||||||
} else if config.Model == 3 {
|
} else if config.Model == 3 {
|
||||||
core.RespondDaily(user, "daily")
|
core.RespondDaily(user, "daily")
|
||||||
core.RespondDaily(user, "weekly")
|
// core.RespondDaily(user, "weekly")
|
||||||
core.RespondDaily(user, "special")
|
core.RespondDaily(user, "special")
|
||||||
}
|
}
|
||||||
state.Delete(uid)
|
state.Delete(uid)
|
||||||
|
|
Loading…
Reference in New Issue