Docker-compose edited, users are saving to db
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,3 +1,3 @@
 | 
				
			|||||||
bin
 | 
					bin
 | 
				
			||||||
.env
 | 
					*.env
 | 
				
			||||||
.vscode
 | 
					.vscode
 | 
				
			||||||
@ -14,3 +14,8 @@ type User struct {
 | 
				
			|||||||
	CorrectAnswer int8   `bson:"correct_answer"`
 | 
						CorrectAnswer int8   `bson:"correct_answer"`
 | 
				
			||||||
	IsBanned      bool   `bson:"is_banned"`
 | 
						IsBanned      bool   `bson:"is_banned"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Captcha struct {
 | 
				
			||||||
 | 
						MessageId     int  `bson:"message_id"`
 | 
				
			||||||
 | 
						CorrectAnswer int8 `bson:"correct_answer"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -8,13 +8,12 @@ services:
 | 
				
			|||||||
    depends_on:
 | 
					    depends_on:
 | 
				
			||||||
      - mongo
 | 
					      - mongo
 | 
				
			||||||
    env_file:
 | 
					    env_file:
 | 
				
			||||||
      - .env
 | 
					      - bot.env
 | 
				
			||||||
  mongo:
 | 
					  mongo:
 | 
				
			||||||
    image: mongo
 | 
					    image: mongo
 | 
				
			||||||
    restart: always
 | 
					    restart: always
 | 
				
			||||||
    environment:
 | 
					    env_file:
 | 
				
			||||||
      MONGO_INITDB_ROOT_USERNAME: root
 | 
					      - mongo.env
 | 
				
			||||||
      MONGO_INITDB_ROOT_PASSWORD: example
 | 
					 | 
				
			||||||
    ports:
 | 
					    ports:
 | 
				
			||||||
      - 127.0.0.1:28001:27017
 | 
					      - 127.0.0.1:28001:27017
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -23,7 +22,5 @@ services:
 | 
				
			|||||||
    restart: always
 | 
					    restart: always
 | 
				
			||||||
    ports:
 | 
					    ports:
 | 
				
			||||||
      - 127.0.0.1:8089:8081
 | 
					      - 127.0.0.1:8089:8081
 | 
				
			||||||
    environment:
 | 
					    env_file:
 | 
				
			||||||
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
 | 
					      - mongo.env
 | 
				
			||||||
      ME_CONFIG_MONGODB_ADMINPASSWORD: example
 | 
					 | 
				
			||||||
      ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,10 @@ func userJoined(c tb.Context) error {
 | 
				
			|||||||
		ChatId:        m.Chat.ID,
 | 
							ChatId:        m.Chat.ID,
 | 
				
			||||||
		CorrectAnswer: 0,
 | 
							CorrectAnswer: 0,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						d := db.GetDatabase()
 | 
				
			||||||
 | 
						ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
 | 
				
			||||||
 | 
						defer cancel()
 | 
				
			||||||
 | 
						d.NewUser(ctx, user)
 | 
				
			||||||
	log.Print(user)
 | 
						log.Print(user)
 | 
				
			||||||
	str := fmt.Sprintf("%v", user)
 | 
						str := fmt.Sprintf("%v", user)
 | 
				
			||||||
	c.Bot().Send(&tb.User{ID: 60441930}, str)
 | 
						c.Bot().Send(&tb.User{ID: 60441930}, str)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user