Skip to content

Commit

Permalink
Add checks for None
Browse files Browse the repository at this point in the history
  • Loading branch information
ebellocchia committed Feb 3, 2022
1 parent 4a0e31d commit f777ab9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion telegram_payment_bot/message/message_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def __OnCreatedChat(self,
client,
message: pyrogram.types.Message,
**kwargs: Any) -> None:
if message.chat is None:
return

# Send the welcome message
MessageSender(client, self.logger).SendMessage(
message.chat,
Expand All @@ -103,14 +106,17 @@ def __OnLeftMember(self,
message: pyrogram.types.Message,
**kwargs: Any) -> None:
# If the member is the bot itself, remove the chat from the scheduler
if message.left_chat_member.is_self:
if message.left_chat_member is not None and message.left_chat_member.is_self:
kwargs["payments_check_scheduler"].ChatLeft(message.chat)

# Function called when a member joined the chat
def __OnJoinedMember(self,
client,
message: pyrogram.types.Message,
**kwargs: Any) -> None:
if message.new_chat_members is None or message.chat is None:
return

# If one of the members is the bot itself, send the welcome message
for member in message.new_chat_members:
if member.is_self:
Expand Down

0 comments on commit f777ab9

Please sign in to comment.