diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7452a08 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/lib/respond.go b/lib/respond.go index f174b32..ec73562 100644 --- a/lib/respond.go +++ b/lib/respond.go @@ -214,7 +214,7 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) { openTips, err := page.QuerySelector( `#app > div > div.layout-body > div > div.detail-body > div.question > div.q-footer > span`) if err != nil { - log.Errorln("为获取到题目提示信息" + err.Error()) + log.Errorln("未获取到题目提示信息" + err.Error()) return } @@ -494,7 +494,7 @@ func checkNextBotton(page playwright.Page) { if len(btns) <= 1 { err := btns[0].Check() if err != nil { - log.Errorln("点击吓一题按钮失败") + log.Errorln("点击下一题按钮失败") return } diff --git a/lib/tg.go b/lib/tg.go index 2b4f5ac..905c84d 100644 --- a/lib/tg.go +++ b/lib/tg.go @@ -229,7 +229,6 @@ func studyAll(bot *Telegram, args []string) { core.LearnArticle(user.Cookies) core.LearnVideo(user.Cookies) core.RespondDaily(user.Cookies, "daily") - core.RespondDaily(user.Cookies, "daily") core.RespondDaily(user.Cookies, "weekly") core.RespondDaily(user.Cookies, "special") score, _ := GetUserScore(user.Cookies) @@ -296,7 +295,6 @@ func study(bot *Telegram, args []string) { core.LearnArticle(cookies) core.LearnVideo(cookies) core.RespondDaily(cookies, "daily") - core.RespondDaily(cookies, "daily") core.RespondDaily(cookies, "weekly") core.RespondDaily(cookies, "special") score, _ := GetUserScore(cookies)