From 874b0079a3ce1d0ca0d5808b536598a6fc2f94a8 Mon Sep 17 00:00:00 2001 From: Miniers Date: Mon, 6 Dec 2021 17:42:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Dockerfile=20=E5=8E=BB?= =?UTF-8?q?=E9=99=A4TG=E5=A4=9A=E4=BD=99=E4=BB=BB=E5=8A=A1=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=83=A8=E5=88=86Log=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ lib/respond.go | 4 ++-- lib/tg.go | 2 -- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 Dockerfile 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)