botapi-py 1.5.4__tar.gz → 1.5.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {botapi_py-1.5.4 → botapi_py-1.5.5}/PKG-INFO +1 -1
- {botapi_py-1.5.4 → botapi_py-1.5.5}/pyproject.toml +1 -1
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/types.py +94 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/__init__.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/__init__.pyi +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/bot.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/core.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/dispatchers/__init__.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/dispatchers/__init__.pyi +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/dispatchers/common.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/dispatchers/get_updates_handler.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/dispatchers/redis_pubsub_handler.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/enums.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/errors.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/internals.py +0 -0
- {botapi_py-1.5.4 → botapi_py-1.5.5}/src/botapi/methods.py +0 -0
|
@@ -634,6 +634,100 @@ BackgroundTypeAdapter = TypeAdapter[_BackgroundType](_BackgroundType)
|
|
|
634
634
|
class ChatMember(BaseModel):
|
|
635
635
|
status: Literal['creator', 'administrator', 'member', 'restricted', 'left', 'kicked']
|
|
636
636
|
user: User
|
|
637
|
+
|
|
638
|
+
# @property
|
|
639
|
+
async def is_participant(self) -> bool:
|
|
640
|
+
'''
|
|
641
|
+
Returns a boolean indicating if the user is currently part of of the chat (i.e. not left/banned).
|
|
642
|
+
|
|
643
|
+
This function handles special cases, like `ChatMemberRestricted` with the `is_member` flag.
|
|
644
|
+
'''
|
|
645
|
+
if isinstance(self, ChatMemberRestricted):
|
|
646
|
+
return self.is_member # this `ChatMemberRestricted` flag indicates whether it's a member or it has left
|
|
647
|
+
|
|
648
|
+
if isinstance(self, (
|
|
649
|
+
ChatMemberLeft,
|
|
650
|
+
ChatMemberBanned
|
|
651
|
+
)):
|
|
652
|
+
return False
|
|
653
|
+
|
|
654
|
+
return True
|
|
655
|
+
|
|
656
|
+
async def ban(
|
|
657
|
+
self,
|
|
658
|
+
bot: bot.Bot,
|
|
659
|
+
chat_id: Union[int, str],
|
|
660
|
+
until_date: Optional[int] = None
|
|
661
|
+
) -> bool:
|
|
662
|
+
'''
|
|
663
|
+
Bans this chat member.
|
|
664
|
+
'''
|
|
665
|
+
return await bot.ban_chat_member(
|
|
666
|
+
chat_id=chat_id,
|
|
667
|
+
user_id=self.user.id,
|
|
668
|
+
until_date=until_date,
|
|
669
|
+
# revoke_messages=revoke_messages
|
|
670
|
+
)
|
|
671
|
+
|
|
672
|
+
async def unban(
|
|
673
|
+
self,
|
|
674
|
+
bot: bot.Bot,
|
|
675
|
+
chat_id: Union[int, str],
|
|
676
|
+
only_if_banned: Optional[bool] = None
|
|
677
|
+
) -> bool:
|
|
678
|
+
'''
|
|
679
|
+
Unbans this chat member.
|
|
680
|
+
'''
|
|
681
|
+
return await bot.unban_chat_member(
|
|
682
|
+
chat_id=chat_id,
|
|
683
|
+
user_id=self.user.id,
|
|
684
|
+
only_if_banned=only_if_banned
|
|
685
|
+
)
|
|
686
|
+
|
|
687
|
+
async def kick(
|
|
688
|
+
self,
|
|
689
|
+
bot: bot.Bot,
|
|
690
|
+
chat_id: Union[int, str]
|
|
691
|
+
) -> bool:
|
|
692
|
+
'''
|
|
693
|
+
Kicks this chat member (bans and immediately unbans).
|
|
694
|
+
'''
|
|
695
|
+
return await bot.unban_chat_member(
|
|
696
|
+
chat_id=chat_id,
|
|
697
|
+
user_id=self.user.id,
|
|
698
|
+
only_if_banned=False # ... "guarantees that after the call the user is not a member of the chat, but will be able to join it"
|
|
699
|
+
)
|
|
700
|
+
|
|
701
|
+
async def mute(
|
|
702
|
+
self,
|
|
703
|
+
bot: bot.Bot,
|
|
704
|
+
chat_id: Union[int, str],
|
|
705
|
+
until_date: Optional[int] = None
|
|
706
|
+
) -> bool:
|
|
707
|
+
'''
|
|
708
|
+
Mutes (restricts) this chat member.
|
|
709
|
+
'''
|
|
710
|
+
return await bot.restrict_chat_member(
|
|
711
|
+
chat_id=chat_id,
|
|
712
|
+
user_id=self.user.id,
|
|
713
|
+
permissions=ChatPermissions(
|
|
714
|
+
can_send_messages=False,
|
|
715
|
+
can_send_audios=False,
|
|
716
|
+
can_send_documents=False,
|
|
717
|
+
can_send_photos=False,
|
|
718
|
+
can_send_videos=False,
|
|
719
|
+
can_send_video_notes=False,
|
|
720
|
+
can_send_voice_notes=False,
|
|
721
|
+
can_send_polls=False,
|
|
722
|
+
can_send_other_messages=False,
|
|
723
|
+
can_add_web_page_previews=False,
|
|
724
|
+
can_change_info=False,
|
|
725
|
+
can_invite_users=False,
|
|
726
|
+
can_pin_messages=False
|
|
727
|
+
),
|
|
728
|
+
until_date=until_date
|
|
729
|
+
)
|
|
730
|
+
|
|
637
731
|
|
|
638
732
|
class ChatMemberOwner(ChatMember):
|
|
639
733
|
'''
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|