Skip to content

Commit

Permalink
Merge pull request #2325 from 2ei/dev
Browse files Browse the repository at this point in the history
fix comparing types
  • Loading branch information
coder2020official authored Jun 27, 2024
2 parents e69e6fe + 004f7de commit f653a72
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions telebot/custom_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -433,15 +433,15 @@ 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


else:
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


Expand Down

0 comments on commit f653a72

Please sign in to comment.