Skip to content

Commit c0dab89

Browse files
committed
refactor(types): add __slots__ in str subclasses
1 parent f069c48 commit c0dab89

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

hydrogram/types/messages_and_media/message.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141

4242
class Str(str):
43+
__slots__ = ("entities",)
44+
4345
def __init__(self, *args):
4446
super().__init__()
4547

@@ -657,13 +659,12 @@ async def _parse(
657659
elif action.closed:
658660
forum_topic_closed = types.ForumTopicClosed()
659661
service_type = enums.MessageServiceType.FORUM_TOPIC_CLOSED
662+
elif hasattr(action, "hidden"):
663+
general_topic_unhidden = types.GeneralTopicUnhidden()
664+
service_type = enums.MessageServiceType.GENERAL_TOPIC_UNHIDDEN
660665
else:
661-
if hasattr(action, "hidden"):
662-
general_topic_unhidden = types.GeneralTopicUnhidden()
663-
service_type = enums.MessageServiceType.GENERAL_TOPIC_UNHIDDEN
664-
else:
665-
forum_topic_reopened = types.ForumTopicReopened()
666-
service_type = enums.MessageServiceType.FORUM_TOPIC_REOPENED
666+
forum_topic_reopened = types.ForumTopicReopened()
667+
service_type = enums.MessageServiceType.FORUM_TOPIC_REOPENED
667668
elif isinstance(action, raw.types.MessageActionGroupCallScheduled):
668669
video_chat_scheduled = types.VideoChatScheduled._parse(action)
669670
service_type = enums.MessageServiceType.VIDEO_CHAT_SCHEDULED

hydrogram/types/user_and_chats/user.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434

3535
class Link(str):
36+
__slots__ = ("style", "text", "url")
37+
3638
HTML = "<a href={url}>{text}</a>"
3739
MARKDOWN = "[{text}]({url})"
3840

0 commit comments

Comments
 (0)