parent
8b9beba670
commit
466ffc2a42
81
lib/tg.go
81
lib/tg.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -220,19 +221,36 @@ func studyAll(bot *Telegram, args []string) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
u := uuid.New().String()
|
timer := time.After(time.Minute * 30)
|
||||||
bot.SendMsg("已创建运行实例:" + u)
|
c := make(chan int, 1)
|
||||||
datas.Store(u, &core)
|
go func() {
|
||||||
defer datas.Delete(u)
|
u := uuid.New().String()
|
||||||
core.Init()
|
bot.SendMsg("已创建运行实例:" + u)
|
||||||
defer core.Quit()
|
datas.Store(u, &core)
|
||||||
core.LearnArticle(user.Cookies)
|
defer datas.Delete(u)
|
||||||
core.LearnVideo(user.Cookies)
|
core.Init()
|
||||||
core.RespondDaily(user.Cookies, "daily")
|
defer core.Quit()
|
||||||
core.RespondDaily(user.Cookies, "weekly")
|
core.LearnArticle(user.Cookies)
|
||||||
core.RespondDaily(user.Cookies, "special")
|
core.LearnVideo(user.Cookies)
|
||||||
|
core.RespondDaily(user.Cookies, "daily")
|
||||||
|
core.RespondDaily(user.Cookies, "weekly")
|
||||||
|
core.RespondDaily(user.Cookies, "special")
|
||||||
|
c <- 1
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-timer:
|
||||||
|
{
|
||||||
|
bot.SendMsg("学习超时,请重新登录或检查日志")
|
||||||
|
log.Errorln("学习超时,已自动退出")
|
||||||
|
core.Quit()
|
||||||
|
}
|
||||||
|
case <-c:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
score, _ := GetUserScore(user.Cookies)
|
score, _ := GetUserScore(user.Cookies)
|
||||||
bot.SendMsg(fmt.Sprintf("%v当前学习总积分:%v,今日得分:%v", user.Nick, score.TotalScore, score.TodayScore))
|
bot.SendMsg(fmt.Sprintf("当前学习总积分:%v,今日得分:%v", score.TotalScore, score.TodayScore))
|
||||||
}
|
}
|
||||||
s()
|
s()
|
||||||
}
|
}
|
||||||
|
@ -285,18 +303,35 @@ func study(bot *Telegram, args []string) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
timer := time.After(time.Minute * 1)
|
||||||
|
c := make(chan int, 1)
|
||||||
|
go func() {
|
||||||
|
u := uuid.New().String()
|
||||||
|
bot.SendMsg("已创建运行实例:" + u)
|
||||||
|
datas.Store(u, &core)
|
||||||
|
defer datas.Delete(u)
|
||||||
|
core.Init()
|
||||||
|
defer core.Quit()
|
||||||
|
core.LearnArticle(cookies)
|
||||||
|
core.LearnVideo(cookies)
|
||||||
|
core.RespondDaily(cookies, "daily")
|
||||||
|
core.RespondDaily(cookies, "weekly")
|
||||||
|
core.RespondDaily(cookies, "special")
|
||||||
|
c <- 1
|
||||||
|
}()
|
||||||
|
|
||||||
u := uuid.New().String()
|
select {
|
||||||
bot.SendMsg("已创建运行实例:" + u)
|
case <-timer:
|
||||||
datas.Store(u, &core)
|
{
|
||||||
defer datas.Delete(u)
|
log.Errorln("学习超时,已自动退出")
|
||||||
core.Init()
|
bot.SendMsg("学习超时,请重新登录或检查日志")
|
||||||
defer core.Quit()
|
core.Quit()
|
||||||
core.LearnArticle(cookies)
|
}
|
||||||
core.LearnVideo(cookies)
|
case <-c:
|
||||||
core.RespondDaily(cookies, "daily")
|
{
|
||||||
core.RespondDaily(cookies, "weekly")
|
|
||||||
core.RespondDaily(cookies, "special")
|
}
|
||||||
|
}
|
||||||
score, _ := GetUserScore(cookies)
|
score, _ := GetUserScore(cookies)
|
||||||
bot.SendMsg(fmt.Sprintf("当前学习总积分:%v,今日得分:%v", score.TotalScore, score.TodayScore))
|
bot.SendMsg(fmt.Sprintf("当前学习总积分:%v,今日得分:%v", score.TotalScore, score.TodayScore))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue