Skip to content

Commit

Permalink
fix: check if user object is None
Browse files Browse the repository at this point in the history
  • Loading branch information
d-Rickyy-b committed May 3, 2021
1 parent 4be8076 commit 07c6a39
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion util/banneduserhandler.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# -*- coding: utf-8 -*-
import logging

from telegram.ext import TypeHandler

import database


class BannedUserHandler(TypeHandler):
logger = logging.getLogger()

def check_update(self, update):
db = database.Database()
if db.is_user_banned(update.effective_user.id):
user = update.effective_user

if user is None:
self.logger.warning(f"User is None! Update: {update}")
return False

if db.is_user_banned(user.id):
return True

return False

0 comments on commit 07c6a39

Please sign in to comment.