Skip to content

Commit

Permalink
fix comparisons to is None
Browse files Browse the repository at this point in the history
  • Loading branch information
da-maltsev committed Jul 6, 2023
1 parent 27e2f89 commit 4705399
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
async def log_message(message: Message | None, action: str | None = ''):
"""Create a log entry for telegram message"""

if message is None or not DB_ENABLED() or not message.from_user:
if message is None or not DB_ENABLED() or message.from_user is None:
return
from models import LogEntry

Expand All @@ -34,7 +34,7 @@ async def log_message(message: Message | None, action: str | None = ''):
async def delete(update: Update, context: ContextTypes.DEFAULT_TYPE):
message = update.message or update.edited_message

if message:
if message is not None:
await log_message(message, action='delete')
await message.delete()

Expand Down
2 changes: 1 addition & 1 deletion filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HasNoValidPreviousMessages(MessageFilter):
MIN_PREVIOUS_MESSAGES_COUNT = 3

def filter(self, message: Message) -> bool:
if not DB_ENABLED() or not message.from_user:
if not DB_ENABLED() or message.from_user is None:
return True

return self.has_no_valid_previous_messages(user_id=message.from_user.id, chat_id=message.chat_id)
Expand Down

0 comments on commit 4705399

Please sign in to comment.