Merge remote-tracking branch 'origin/main'

This commit is contained in:
johlanse 2021-12-06 19:26:45 +08:00
commit 8b9beba670
3 changed files with 41 additions and 4 deletions

39
Dockerfile Normal file
View File

@ -0,0 +1,39 @@
FROM golang:bullseye AS build_study_xxqg
ARG TARGETARCH
ARG BUILDARCH
ENV CGO_ENABLED="0"
ENV GOOS="linux"
ARG UPX_VERSION="3.96"
RUN apt update && apt install -y xz-utils git gcc curl
COPY / /study_xxqg
RUN cd /study_xxqg && \
version=$(git describe --tags --long --always) && \
echo "${version}" && \
GOARCH=${TARGETARCH} go build -ldflags "-s -w -X main.version=${version}" -trimpath -o study_xxqg
RUN target="${BUILDARCH}" && \
curl -sSL https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-${target}_linux.tar.xz | tar xvJf - -C / && \
cp -f /upx-${UPX_VERSION}-${target}_linux/upx /usr/bin/ && \
/usr/bin/upx -9 -v /study_xxqg/study_xxqg
FROM debian:bullseye-slim
ARG TARGETARCH
ENV TIMEZONE="Asia/Shanghai"
RUN apt update \
&& apt install -y --no-install-recommends ca-certificates tzdata libglib2.0-0 libnss3 libatk1.0-0 libcups2 libatk-bridge2.0-0 libdrm2 libxcb1 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 libxshmfence1 \
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
&& echo "${TIMEZONE}" > /etc/timezone \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install study_xxqg
COPY --from=build_study_xxqg /study_xxqg/study_xxqg /study_xxqg
VOLUME ["/config"]
ENTRYPOINT ["/study_xxqg"]

View File

@ -214,7 +214,7 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) {
openTips, err := page.QuerySelector( openTips, err := page.QuerySelector(
`#app > div > div.layout-body > div > div.detail-body > div.question > div.q-footer > span`) `#app > div > div.layout-body > div > div.detail-body > div.question > div.q-footer > span`)
if err != nil { if err != nil {
log.Errorln("获取到题目提示信息" + err.Error()) log.Errorln("获取到题目提示信息" + err.Error())
return return
} }
@ -494,7 +494,7 @@ func checkNextBotton(page playwright.Page) {
if len(btns) <= 1 { if len(btns) <= 1 {
err := btns[0].Check() err := btns[0].Check()
if err != nil { if err != nil {
log.Errorln("点击一题按钮失败") log.Errorln("点击一题按钮失败")
return return
} }

View File

@ -229,7 +229,6 @@ func studyAll(bot *Telegram, args []string) {
core.LearnArticle(user.Cookies) core.LearnArticle(user.Cookies)
core.LearnVideo(user.Cookies) core.LearnVideo(user.Cookies)
core.RespondDaily(user.Cookies, "daily") core.RespondDaily(user.Cookies, "daily")
core.RespondDaily(user.Cookies, "daily")
core.RespondDaily(user.Cookies, "weekly") core.RespondDaily(user.Cookies, "weekly")
core.RespondDaily(user.Cookies, "special") core.RespondDaily(user.Cookies, "special")
score, _ := GetUserScore(user.Cookies) score, _ := GetUserScore(user.Cookies)
@ -296,7 +295,6 @@ func study(bot *Telegram, args []string) {
core.LearnArticle(cookies) core.LearnArticle(cookies)
core.LearnVideo(cookies) core.LearnVideo(cookies)
core.RespondDaily(cookies, "daily") core.RespondDaily(cookies, "daily")
core.RespondDaily(cookies, "daily")
core.RespondDaily(cookies, "weekly") core.RespondDaily(cookies, "weekly")
core.RespondDaily(cookies, "special") core.RespondDaily(cookies, "special")
score, _ := GetUserScore(cookies) score, _ := GetUserScore(cookies)