Skip to content

Commit 92b45bd

Browse files
committed
Merge pull request #110 from d-Rickyy-b/dev
docker update
2 parents c68d84b + d86971e commit 92b45bd

File tree

5 files changed

+46
-28
lines changed

5 files changed

+46
-28
lines changed

.github/workflows/docker_build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check out code into the Go module directory
14+
uses: actions/checkout@v3
15+
16+
- name: Set build tag as env var
17+
run: echo "TAG=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
18+
19+
- name: Docker login
20+
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
21+
22+
- name: Build the Docker image
23+
run: docker build . --file Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/blackjackbot:latest --tag ${{ secrets.DOCKERHUB_USERNAME }}/blackjackbot:${{ env.TAG }}
24+
25+
- name: Push the Docker image
26+
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/blackjackbot --all-tags

.github/workflows/python-lint-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
18+
python-version: [ '3.9', '3.10', '3.11']
1919

2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
2222
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v4
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Install dependencies

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
21
[![Build Status](https://github.com/d-Rickyy-b/Python-BlackJackBot/actions/workflows/python-lint-test.yml/badge.svg)](https://github.com/d-Rickyy-b/Python-BlackJackBot/actions/workflows/python-lint-test.yml)
2+
[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/0rickyy0/blackjackbot?label=docker&sort=semver)](https://hub.docker.com/repository/docker/0rickyy0/blackjackbot)
33
[![Coverage Status](https://coveralls.io/repos/github/d-Rickyy-b/Python-BlackJackBot/badge.svg?branch=rebuild)](https://coveralls.io/github/d-Rickyy-b/Python-BlackJackBot?branch=rebuild)
44
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/12996d68fc0f436085221ac6b1f525f9)](https://www.codacy.com/manual/d-Rickyy-b/Python-BlackJackBot?utm_source=github.com&utm_medium=referral&utm_content=d-Rickyy-b/Python-BlackJackBot&utm_campaign=Badge_Grade)
55

database/database.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def load_banned_users(self):
8989
return
9090

9191
for row in result:
92-
print(int(row["user_id"]))
9392
self._banned_users.add(int(row["user_id"]))
9493

9594
def get_banned_users(self):
@@ -132,39 +131,32 @@ def get_recent_players(self):
132131

133132
def get_played_games(self, user_id):
134133
self.cursor.execute("SELECT games_played FROM users WHERE user_id=?;", [str(user_id)])
135-
136134
result = self.cursor.fetchone()
137135

138-
if not result:
139-
return 0
140-
141-
if len(result) > 0:
142-
return int(result[0])
143-
else:
136+
if not result or len(result) <= 0:
144137
return 0
145138

146-
def get_all_users(self):
147-
self.cursor.execute("SELECT rowid, * FROM users;")
148-
return self.cursor.fetchall()
139+
return int(result["games_played"])
149140

150141
@Cache(timeout=60)
151142
def get_admins(self):
152143
self.cursor.execute("SELECT user_id from admins;")
153144
admins = self.cursor.fetchall()
154145
admin_list = []
155146
for admin in admins:
156-
admin_list.append(admin[0])
147+
admin_list.append(admin["user_id"])
157148
return admin_list
158149

159150
@Cache(timeout=120)
160151
def get_lang_id(self, chat_id):
161152
self.cursor.execute("SELECT lang_id FROM chats WHERE chat_id=?;", [str(chat_id)])
162153
result = self.cursor.fetchone()
163-
if result:
164-
if result[0]:
165-
# Make sure that the database stored an actual value and not "None"
166-
return result[0]
167-
return "en"
154+
155+
if not result or not result["lang_id"]:
156+
# Make sure that the database stored an actual value and not "None"
157+
return "en"
158+
159+
return result["lang_id"]
168160

169161
def set_lang_id(self, chat_id, lang_id):
170162
if lang_id is None:
@@ -212,17 +204,17 @@ def is_user_saved(self, user_id):
212204

213205
def user_data_changed(self, user_id, first_name, last_name, username):
214206
self.cursor.execute("SELECT * FROM users WHERE user_id=?;", [str(user_id)])
215-
216207
result = self.cursor.fetchone()
217208

218209
# check if user is saved
219-
if result:
220-
if result[2] == first_name and result[3] == last_name and result[4] == username:
221-
return False
222-
return True
223-
else:
210+
if not result:
224211
return True
225212

213+
if result["first_name"] == first_name and result["last_name"] == last_name and result["username"] == username:
214+
return False
215+
216+
return True
217+
226218
def update_user_data(self, user_id, first_name, last_name, username):
227219
self.cursor.execute("UPDATE users SET first_name=?, last_name=?, username=? WHERE user_id=?;", [first_name, last_name, username, str(user_id)])
228220
self.connection.commit()

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-telegram-bot>=13.5
1+
python-telegram-bot>=13.5, <20

0 commit comments

Comments
 (0)