diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index 84fc4f20..c3903913 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -187,7 +187,7 @@ def pyrogram_api(): Chats join_chat leave_chat - kick_chat_member + ban_chat_member unban_chat_member restrict_chat_member promote_chat_member @@ -501,7 +501,7 @@ def pyrogram_api(): Chat.set_title Chat.set_description Chat.set_photo - Chat.kick_member + Chat.ban_member Chat.unban_member Chat.restrict_member Chat.promote_member diff --git a/pyrogram/methods/chats/__init__.py b/pyrogram/methods/chats/__init__.py index 31ffe4fd..71125ce0 100644 --- a/pyrogram/methods/chats/__init__.py +++ b/pyrogram/methods/chats/__init__.py @@ -18,6 +18,7 @@ from .add_chat_members import AddChatMembers from .archive_chats import ArchiveChats +from .ban_chat_member import BanChatMember from .create_channel import CreateChannel from .create_group import CreateGroup from .create_supergroup import CreateSupergroup @@ -30,13 +31,13 @@ from .get_chat_event_log import GetChatEventLog from .get_chat_member import GetChatMember from .get_chat_members import GetChatMembers from .get_chat_members_count import GetChatMembersCount +from .get_chat_online_count import GetChatOnlineCount from .get_dialogs import GetDialogs from .get_dialogs_count import GetDialogsCount from .get_nearby_chats import GetNearbyChats from .iter_chat_members import IterChatMembers from .iter_dialogs import IterDialogs from .join_chat import JoinChat -from .kick_chat_member import KickChatMember from .leave_chat import LeaveChat from .mark_chat_unread import MarkChatUnread from .pin_chat_message import PinChatMessage @@ -53,14 +54,13 @@ from .unban_chat_member import UnbanChatMember from .unpin_all_chat_messages import UnpinAllChatMessages from .unpin_chat_message import UnpinChatMessage from .update_chat_username import UpdateChatUsername -from .get_chat_online_count import GetChatOnlineCount class Chats( GetChat, LeaveChat, JoinChat, - KickChatMember, + BanChatMember, UnbanChatMember, RestrictChatMember, PromoteChatMember, diff --git a/pyrogram/methods/chats/kick_chat_member.py b/pyrogram/methods/chats/ban_chat_member.py similarity index 92% rename from pyrogram/methods/chats/kick_chat_member.py rename to pyrogram/methods/chats/ban_chat_member.py index 495eac94..0d17fec6 100644 --- a/pyrogram/methods/chats/kick_chat_member.py +++ b/pyrogram/methods/chats/ban_chat_member.py @@ -23,14 +23,14 @@ from pyrogram import types from pyrogram.scaffold import Scaffold -class KickChatMember(Scaffold): - async def kick_chat_member( +class BanChatMember(Scaffold): + async def ban_chat_member( self, chat_id: Union[int, str], user_id: Union[int, str], until_date: int = 0 ) -> Union["types.Message", bool]: - """Kick a user from a group, a supergroup or a channel. + """Ban a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. You must be an administrator in the chat for this to work and must have the appropriate admin rights. @@ -63,10 +63,10 @@ class KickChatMember(Scaffold): from time import time # Ban chat member forever - app.kick_chat_member(chat_id, user_id) + app.ban_chat_member(chat_id, user_id) - # Kick chat member and automatically unban after 24h - app.kick_chat_member(chat_id, user_id, int(time.time() + 86400)) + # Ban chat member and automatically unban after 24h + app.ban_chat_member(chat_id, user_id, int(time.time() + 86400)) """ chat_peer = await self.resolve_peer(chat_id) user_peer = await self.resolve_peer(user_id) diff --git a/pyrogram/methods/chats/get_chat_members.py b/pyrogram/methods/chats/get_chat_members.py index 64abf1e5..d22cc446 100644 --- a/pyrogram/methods/chats/get_chat_members.py +++ b/pyrogram/methods/chats/get_chat_members.py @@ -28,7 +28,7 @@ log = logging.getLogger(__name__) class Filters: ALL = "all" - KICKED = "kicked" + BANNED = "banned" RESTRICTED = "restricted" BOTS = "bots" RECENT = "recent" @@ -72,7 +72,7 @@ class GetChatMembers(Scaffold): Filter used to select the kind of members you want to retrieve. Only applicable for supergroups and channels. It can be any of the followings: *"all"* - all kind of members, - *"kicked"* - kicked (banned) members only, + *"banned"* - banned members only, *"restricted"* - restricted members only, *"bots"* - bots only, *"recent"* - recent members only, @@ -83,7 +83,7 @@ class GetChatMembers(Scaffold): .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members on channels. - .. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only. + .. [2] A query string is applicable only for *"all"*, *"banned"* and *"restricted"* filters only. Returns: List of :obj:`~pyrogram.types.ChatMember`: On success, a list of chat members is returned. @@ -121,7 +121,7 @@ class GetChatMembers(Scaffold): if filter == Filters.ALL: filter = raw.types.ChannelParticipantsSearch(q=query) - elif filter == Filters.KICKED: + elif filter == Filters.BANNED: filter = raw.types.ChannelParticipantsKicked(q=query) elif filter == Filters.RESTRICTED: filter = raw.types.ChannelParticipantsBanned(q=query) diff --git a/pyrogram/methods/chats/iter_chat_members.py b/pyrogram/methods/chats/iter_chat_members.py index 86ef457c..3db39355 100644 --- a/pyrogram/methods/chats/iter_chat_members.py +++ b/pyrogram/methods/chats/iter_chat_members.py @@ -26,7 +26,7 @@ from pyrogram.scaffold import Scaffold class Filters: ALL = "all" - KICKED = "kicked" + BANNED = "banned" RESTRICTED = "restricted" BOTS = "bots" RECENT = "recent" @@ -34,7 +34,7 @@ class Filters: QUERIES = [""] + [str(i) for i in range(10)] + list(ascii_lowercase) -QUERYABLE_FILTERS = (Filters.ALL, Filters.KICKED, Filters.RESTRICTED) +QUERYABLE_FILTERS = (Filters.ALL, Filters.BANNED, Filters.RESTRICTED) class IterChatMembers(Scaffold): @@ -67,7 +67,7 @@ class IterChatMembers(Scaffold): Filter used to select the kind of members you want to retrieve. Only applicable for supergroups and channels. It can be any of the followings: *"all"* - all kind of members, - *"kicked"* - kicked (banned) members only, + *"banned"* - banned members only, *"restricted"* - restricted members only, *"bots"* - bots only, *"recent"* - recent members only, @@ -77,7 +77,7 @@ class IterChatMembers(Scaffold): .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members on channels. - .. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only. + .. [2] A query string is applicable only for *"all"*, *"banned"* and *"restricted"* filters only. Returns: ``Generator``: A generator yielding :obj:`~pyrogram.types.ChatMember` objects. diff --git a/pyrogram/methods/chats/unban_chat_member.py b/pyrogram/methods/chats/unban_chat_member.py index 44c19286..9f81f9c7 100644 --- a/pyrogram/methods/chats/unban_chat_member.py +++ b/pyrogram/methods/chats/unban_chat_member.py @@ -28,7 +28,7 @@ class UnbanChatMember(Scaffold): chat_id: Union[int, str], user_id: Union[int, str] ) -> bool: - """Unban a previously kicked user in a supergroup or channel. + """Unban a previously banned user in a supergroup or channel. The user will **not** return to the group or channel automatically, but will be able to join via link, etc. You must be an administrator for this to work. diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index 4042c073..5ba68aac 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -479,18 +479,18 @@ class Chat(Object): photo=photo ) - async def kick_member( + async def ban_member( self, user_id: Union[int, str], until_date: int = 0 ) -> Union["types.Message", bool]: - """Bound method *kick_member* of :obj:`~pyrogram.types.Chat`. + """Bound method *ban_member* of :obj:`~pyrogram.types.Chat`. Use as a shortcut for: .. code-block:: python - client.kick_chat_member( + client.ban_chat_member( chat_id=chat_id, user_id=user_id ) @@ -498,7 +498,7 @@ class Chat(Object): Example: .. code-block:: python - chat.kick_member(123456789) + chat.ban_member(123456789) Note: In regular groups (non-supergroups), this method will only work if the "All Members Are Admins" setting is @@ -523,7 +523,7 @@ class Chat(Object): RPCError: In case of a Telegram RPC error. """ - return await self._client.kick_chat_member( + return await self._client.ban_chat_member( chat_id=self.id, user_id=user_id, until_date=until_date @@ -840,7 +840,7 @@ class Chat(Object): Filter used to select the kind of members you want to retrieve. Only applicable for supergroups and channels. It can be any of the followings: *"all"* - all kind of members, - *"kicked"* - kicked (banned) members only, + *"banned"* - banned members only, *"restricted"* - restricted members only, *"bots"* - bots only, *"recent"* - recent members only, @@ -851,7 +851,7 @@ class Chat(Object): .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members on channels. - .. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only. + .. [2] A query string is applicable only for *"all"*, *"banned"* and *"restricted"* filters only. Example: .. code-block:: python @@ -903,7 +903,7 @@ class Chat(Object): Filter used to select the kind of members you want to retrieve. Only applicable for supergroups and channels. It can be any of the followings: *"all"* - all kind of members, - *"kicked"* - kicked (banned) members only, + *"banned"* - banned members only, *"restricted"* - restricted members only, *"bots"* - bots only, *"recent"* - recent members only, @@ -914,7 +914,7 @@ class Chat(Object): .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members on channels. - .. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only. + .. [2] A query string is applicable only for *"all"*, *"banned"* and *"restricted"* filters only. Example: .. code-block:: python diff --git a/pyrogram/types/user_and_chats/chat_member.py b/pyrogram/types/user_and_chats/chat_member.py index d33bcfc5..a6f2f4cc 100644 --- a/pyrogram/types/user_and_chats/chat_member.py +++ b/pyrogram/types/user_and_chats/chat_member.py @@ -31,14 +31,14 @@ class ChatMember(Object): status (``str``): The member's status in the chat. - Can be "creator", "administrator", "member", "restricted", "left" or "kicked". + Can be "creator", "administrator", "member", "restricted", "left" or "banned". title (``str``, *optional*): A custom title that will be shown to all members instead of "Owner" or "Admin". Creator (owner) and administrators only. Can be None in case there's no custom title set. until_date (``int``, *optional*): - Restricted and kicked only. + Restricted and banned only. Date when restrictions will be lifted for this user; unix time. joined_date (``int``, *optional*): @@ -53,7 +53,7 @@ class ChatMember(Object): Administrators only. Information about the user who promoted this member as administrator. restricted_by (:obj:`~pyrogram.types.User`, *optional*): - Restricted and kicked only. Information about the user who restricted or kicked this member. + Restricted and banned only. Information about the user who restricted or banned this member. is_member (``bool``, *optional*): Restricted only. True, if the user is a member of the chat at the moment of the request. @@ -305,7 +305,7 @@ class ChatMember(Object): return ChatMember( user=user, - status="kicked" if member.banned_rights.view_messages else "restricted", + status="banned" if member.banned_rights.view_messages else "restricted", until_date=denied_permissions.until_date, joined_date=member.date, is_member=not member.left,