Skip to content

Commit

Permalink
Merge bd96695 into 2b5b847
Browse files Browse the repository at this point in the history
  • Loading branch information
d-Rickyy-b committed May 6, 2023
2 parents 2b5b847 + bd96695 commit 740dfc1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 28 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Docker Image CI

on:
push:
tags:
- "v*.*.*"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Set build tag as env var
run: echo "TAG=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV

- name: Docker login
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build the Docker image
run: docker build . --file Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/blackjackbot:latest --tag ${{ secrets.DOCKERHUB_USERNAME }}/blackjackbot:${{ env.TAG }}

- name: Push the Docker image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/blackjackbot --all-tags
6 changes: 3 additions & 3 deletions .github/workflows/python-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
python-version: [ '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[![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)
[![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)
[![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)
[![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)

Expand Down
38 changes: 15 additions & 23 deletions database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def load_banned_users(self):
return

for row in result:
print(int(row["user_id"]))
self._banned_users.add(int(row["user_id"]))

def get_banned_users(self):
Expand Down Expand Up @@ -132,39 +131,32 @@ def get_recent_players(self):

def get_played_games(self, user_id):
self.cursor.execute("SELECT games_played FROM users WHERE user_id=?;", [str(user_id)])

result = self.cursor.fetchone()

if not result:
return 0

if len(result) > 0:
return int(result[0])
else:
if not result or len(result) <= 0:
return 0

def get_all_users(self):
self.cursor.execute("SELECT rowid, * FROM users;")
return self.cursor.fetchall()
return int(result["games_played"])

@Cache(timeout=60)
def get_admins(self):
self.cursor.execute("SELECT user_id from admins;")
admins = self.cursor.fetchall()
admin_list = []
for admin in admins:
admin_list.append(admin[0])
admin_list.append(admin["user_id"])
return admin_list

@Cache(timeout=120)
def get_lang_id(self, chat_id):
self.cursor.execute("SELECT lang_id FROM chats WHERE chat_id=?;", [str(chat_id)])
result = self.cursor.fetchone()
if result:
if result[0]:
# Make sure that the database stored an actual value and not "None"
return result[0]
return "en"

if not result or not result["lang_id"]:
# Make sure that the database stored an actual value and not "None"
return "en"

return result["lang_id"]

def set_lang_id(self, chat_id, lang_id):
if lang_id is None:
Expand Down Expand Up @@ -212,17 +204,17 @@ def is_user_saved(self, user_id):

def user_data_changed(self, user_id, first_name, last_name, username):
self.cursor.execute("SELECT * FROM users WHERE user_id=?;", [str(user_id)])

result = self.cursor.fetchone()

# check if user is saved
if result:
if result[2] == first_name and result[3] == last_name and result[4] == username:
return False
return True
else:
if not result:
return True

if result["first_name"] == first_name and result["last_name"] == last_name and result["username"] == username:
return False

return True

def update_user_data(self, user_id, first_name, last_name, username):
self.cursor.execute("UPDATE users SET first_name=?, last_name=?, username=? WHERE user_id=?;", [first_name, last_name, username, str(user_id)])
self.connection.commit()
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-telegram-bot>=13.5
python-telegram-bot>=13.5, <20

0 comments on commit 740dfc1

Please sign in to comment.