From 004f7dec172c8fc0854d54f39880b6f6c1b18aca Mon Sep 17 00:00:00 2001 From: Zaid _ Date: Thu, 27 Jun 2024 14:27:10 +0300 Subject: [PATCH] fix comparing types --- telebot/__init__.py | 10 +++++----- telebot/async_telebot.py | 10 +++++----- telebot/custom_filters.py | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index d2bcdc307..408a11902 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -4723,7 +4723,7 @@ def edit_message_text( parse_mode=parse_mode, entities=entities, reply_markup=reply_markup, link_preview_options=link_preview_options, business_connection_id=business_connection_id, timeout=timeout) - if type(result) == bool: # if edit inline message return is bool not Message. + if isinstance(result, bool): # if edit inline message return is bool not Message. return result return types.Message.de_json(result) @@ -4770,7 +4770,7 @@ def edit_message_media( self.token, media, chat_id=chat_id, message_id=message_id, inline_message_id=inline_message_id, reply_markup=reply_markup, business_connection_id=business_connection_id, timeout=timeout) - if type(result) == bool: # if edit inline message return is bool not Message. + if isinstance(result, bool): # if edit inline message return is bool not Message. return result return types.Message.de_json(result) @@ -4812,7 +4812,7 @@ def edit_message_reply_markup( self.token, chat_id=chat_id, message_id=message_id, inline_message_id=inline_message_id, reply_markup=reply_markup, business_connection_id=business_connection_id, timeout=timeout) - if type(result) == bool: + if isinstance(result, bool): return result return types.Message.de_json(result) @@ -4946,7 +4946,7 @@ def set_game_score( self.token, user_id, score, force=force, disable_edit_message=disable_edit_message, chat_id=chat_id, message_id=message_id, inline_message_id=inline_message_id) - if type(result) == bool: + if isinstance(result, bool): return result return types.Message.de_json(result) @@ -5610,7 +5610,7 @@ def edit_message_caption( show_caption_above_media=show_caption_above_media, business_connection_id=business_connection_id, timeout=timeout) - if type(result) == bool: + if isinstance(result, bool): return result return types.Message.de_json(result) diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 224856416..4ad59c4da 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -6087,7 +6087,7 @@ async def edit_message_text( result = await asyncio_helper.edit_message_text( self.token, text, chat_id, message_id, inline_message_id, parse_mode, entities, reply_markup, link_preview_options, business_connection_id, timeout) - if type(result) == bool: # if edit inline message return is bool not Message. + if isinstance(result, bool): # if edit inline message return is bool not Message. return result return types.Message.de_json(result) @@ -6131,7 +6131,7 @@ async def edit_message_media( """ result = await asyncio_helper.edit_message_media( self.token, media, chat_id, message_id, inline_message_id, reply_markup, business_connection_id, timeout) - if type(result) == bool: # if edit inline message return is bool not Message. + if isinstance(result, bool): # if edit inline message return is bool not Message. return result return types.Message.de_json(result) @@ -6170,7 +6170,7 @@ async def edit_message_reply_markup( """ result = await asyncio_helper.edit_message_reply_markup( self.token, chat_id, message_id, inline_message_id, reply_markup, business_connection_id, timeout) - if type(result) == bool: + if isinstance(result, bool): return result return types.Message.de_json(result) @@ -6298,7 +6298,7 @@ async def set_game_score( """ result = await asyncio_helper.set_game_score(self.token, user_id, score, force, disable_edit_message, chat_id, message_id, inline_message_id) - if type(result) == bool: + if isinstance(result, bool): return result return types.Message.de_json(result) @@ -6942,7 +6942,7 @@ async def edit_message_caption( self.token, caption, chat_id, message_id, inline_message_id, parse_mode, caption_entities, reply_markup, show_caption_above_media=show_caption_above_media, business_connection_id=business_connection_id, timeout=timeout) - if type(result) == bool: + if isinstance(result, bool): return result return types.Message.de_json(result) diff --git a/telebot/custom_filters.py b/telebot/custom_filters.py index d4d4ffeca..0c4ca614e 100644 --- a/telebot/custom_filters.py +++ b/telebot/custom_filters.py @@ -215,7 +215,7 @@ def check(self, message, text): """ if isinstance(text, TextFilter): return text.check(message) - elif type(text) is list: + elif isinstance(text, list): return message.text in text else: return text == message.text @@ -353,7 +353,7 @@ def check(self, message, text): """ :meta private: """ - if type(text) is list: + if isinstance(text, list): return message.from_user.language_code in text else: return message.from_user.language_code == text @@ -433,7 +433,7 @@ def check(self, message, text): group_state = self.bot.current_states.get_state(chat_id, user_id) if group_state == text: return True - elif type(text) is list and group_state in text: + elif isinstance(text, list) and group_state in text: return True @@ -441,7 +441,7 @@ def check(self, message, text): user_state = self.bot.current_states.get_state(chat_id, user_id) if user_state == text: return True - elif type(text) is list and user_state in text: + elif isinstance(text, list) and user_state in text: return True