From 4b4e2fd4f067c853bc0a001265fb806e0ddf26dc Mon Sep 17 00:00:00 2001 From: Alphyron Date: Sun, 9 Aug 2020 10:07:16 +0200 Subject: [PATCH] :sparkles: Add some small logs and optimze Dockerfile --- Dockerfile | 6 +++++- channels/verifiychecker.go | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9e2de83..dacbe57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,12 @@ # build stage FROM golang:1.13-stretch AS build-env -COPY . /src WORKDIR /src +COPY go.mod /src/go.mod +RUN go mod download + +COPY . /src + #ENV GOPROXY=http://192.168.0.143:3000 ENV GO113MODULE=on diff --git a/channels/verifiychecker.go b/channels/verifiychecker.go index 8b3dc34..6f26850 100644 --- a/channels/verifiychecker.go +++ b/channels/verifiychecker.go @@ -1,6 +1,7 @@ package channels import ( + "fmt" "git.dragon-labs.de/alphyron/group_helper/logic" "git.dragon-labs.de/alphyron/group_helper/message" "git.dragon-labs.de/alphyron/group_helper/models" @@ -16,13 +17,14 @@ func CheckUnverifiedUser(ticker *time.Ticker, quitChannel <-chan struct{}, group select { case <-ticker.C: - delete := make([]*obj.VerifyUser, 0) + deleteVerifyUser := make([]*obj.VerifyUser, 0) groups := make(map[int64]*models.Group, 0) users := make(map[int]*models.User, 0) for _, user := range data.Users { user.LeftTime -= 1 + log.Println(fmt.Sprintf("Verify checker: (%d/%d/%d)", user.GroupID, user.UserID, user.LeftTime)) if user.LeftTime <= 0 { log.Println(len(data.Users)) @@ -57,7 +59,7 @@ func CheckUnverifiedUser(ticker *time.Ticker, quitChannel <-chan struct{}, group } member, _ := bot.GetChatMember(userconfig) - delete = append(delete, user) + deleteVerifyUser = append(deleteVerifyUser, user) _, err := groupHelperService.UserLeaveGroup(users[user.UserID], groups[user.GroupID]) if err != nil { @@ -115,7 +117,7 @@ func CheckUnverifiedUser(ticker *time.Ticker, quitChannel <-chan struct{}, group } } - for _, user := range delete { + for _, user := range deleteVerifyUser { data.RemoveUser(user.UserID, user.GroupID) }