Add some small logs and optimze Dockerfile

This commit is contained in:
Alphyron 2020-08-09 10:07:16 +02:00
parent 7690ecb52e
commit 4b4e2fd4f0
2 changed files with 10 additions and 4 deletions

View File

@ -1,8 +1,12 @@
# build stage # build stage
FROM golang:1.13-stretch AS build-env FROM golang:1.13-stretch AS build-env
COPY . /src
WORKDIR /src WORKDIR /src
COPY go.mod /src/go.mod
RUN go mod download
COPY . /src
#ENV GOPROXY=http://192.168.0.143:3000 #ENV GOPROXY=http://192.168.0.143:3000
ENV GO113MODULE=on ENV GO113MODULE=on

View File

@ -1,6 +1,7 @@
package channels package channels
import ( import (
"fmt"
"git.dragon-labs.de/alphyron/group_helper/logic" "git.dragon-labs.de/alphyron/group_helper/logic"
"git.dragon-labs.de/alphyron/group_helper/message" "git.dragon-labs.de/alphyron/group_helper/message"
"git.dragon-labs.de/alphyron/group_helper/models" "git.dragon-labs.de/alphyron/group_helper/models"
@ -16,13 +17,14 @@ func CheckUnverifiedUser(ticker *time.Ticker, quitChannel <-chan struct{}, group
select { select {
case <-ticker.C: case <-ticker.C:
delete := make([]*obj.VerifyUser, 0) deleteVerifyUser := make([]*obj.VerifyUser, 0)
groups := make(map[int64]*models.Group, 0) groups := make(map[int64]*models.Group, 0)
users := make(map[int]*models.User, 0) users := make(map[int]*models.User, 0)
for _, user := range data.Users { for _, user := range data.Users {
user.LeftTime -= 1 user.LeftTime -= 1
log.Println(fmt.Sprintf("Verify checker: (%d/%d/%d)", user.GroupID, user.UserID, user.LeftTime))
if user.LeftTime <= 0 { if user.LeftTime <= 0 {
log.Println(len(data.Users)) log.Println(len(data.Users))
@ -57,7 +59,7 @@ func CheckUnverifiedUser(ticker *time.Ticker, quitChannel <-chan struct{}, group
} }
member, _ := bot.GetChatMember(userconfig) member, _ := bot.GetChatMember(userconfig)
delete = append(delete, user) deleteVerifyUser = append(deleteVerifyUser, user)
_, err := groupHelperService.UserLeaveGroup(users[user.UserID], groups[user.GroupID]) _, err := groupHelperService.UserLeaveGroup(users[user.UserID], groups[user.GroupID])
if err != nil { 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) data.RemoveUser(user.UserID, user.GroupID)
} }