Rename kick(ed) occurrences to ban(ned)

This commit is contained in:
Dan 2021-12-22 14:39:52 +01:00
parent a909dc12e7
commit 2024b3c120
8 changed files with 33 additions and 33 deletions

View File

@ -187,7 +187,7 @@ def pyrogram_api():
Chats Chats
join_chat join_chat
leave_chat leave_chat
kick_chat_member ban_chat_member
unban_chat_member unban_chat_member
restrict_chat_member restrict_chat_member
promote_chat_member promote_chat_member
@ -501,7 +501,7 @@ def pyrogram_api():
Chat.set_title Chat.set_title
Chat.set_description Chat.set_description
Chat.set_photo Chat.set_photo
Chat.kick_member Chat.ban_member
Chat.unban_member Chat.unban_member
Chat.restrict_member Chat.restrict_member
Chat.promote_member Chat.promote_member

View File

@ -18,6 +18,7 @@
from .add_chat_members import AddChatMembers from .add_chat_members import AddChatMembers
from .archive_chats import ArchiveChats from .archive_chats import ArchiveChats
from .ban_chat_member import BanChatMember
from .create_channel import CreateChannel from .create_channel import CreateChannel
from .create_group import CreateGroup from .create_group import CreateGroup
from .create_supergroup import CreateSupergroup 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_member import GetChatMember
from .get_chat_members import GetChatMembers from .get_chat_members import GetChatMembers
from .get_chat_members_count import GetChatMembersCount from .get_chat_members_count import GetChatMembersCount
from .get_chat_online_count import GetChatOnlineCount
from .get_dialogs import GetDialogs from .get_dialogs import GetDialogs
from .get_dialogs_count import GetDialogsCount from .get_dialogs_count import GetDialogsCount
from .get_nearby_chats import GetNearbyChats from .get_nearby_chats import GetNearbyChats
from .iter_chat_members import IterChatMembers from .iter_chat_members import IterChatMembers
from .iter_dialogs import IterDialogs from .iter_dialogs import IterDialogs
from .join_chat import JoinChat from .join_chat import JoinChat
from .kick_chat_member import KickChatMember
from .leave_chat import LeaveChat from .leave_chat import LeaveChat
from .mark_chat_unread import MarkChatUnread from .mark_chat_unread import MarkChatUnread
from .pin_chat_message import PinChatMessage 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_all_chat_messages import UnpinAllChatMessages
from .unpin_chat_message import UnpinChatMessage from .unpin_chat_message import UnpinChatMessage
from .update_chat_username import UpdateChatUsername from .update_chat_username import UpdateChatUsername
from .get_chat_online_count import GetChatOnlineCount
class Chats( class Chats(
GetChat, GetChat,
LeaveChat, LeaveChat,
JoinChat, JoinChat,
KickChatMember, BanChatMember,
UnbanChatMember, UnbanChatMember,
RestrictChatMember, RestrictChatMember,
PromoteChatMember, PromoteChatMember,

View File

@ -23,14 +23,14 @@ from pyrogram import types
from pyrogram.scaffold import Scaffold from pyrogram.scaffold import Scaffold
class KickChatMember(Scaffold): class BanChatMember(Scaffold):
async def kick_chat_member( async def ban_chat_member(
self, self,
chat_id: Union[int, str], chat_id: Union[int, str],
user_id: Union[int, str], user_id: Union[int, str],
until_date: int = 0 until_date: int = 0
) -> Union["types.Message", bool]: ) -> 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 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 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. have the appropriate admin rights.
@ -63,10 +63,10 @@ class KickChatMember(Scaffold):
from time import time from time import time
# Ban chat member forever # 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 # Ban chat member and automatically unban after 24h
app.kick_chat_member(chat_id, user_id, int(time.time() + 86400)) app.ban_chat_member(chat_id, user_id, int(time.time() + 86400))
""" """
chat_peer = await self.resolve_peer(chat_id) chat_peer = await self.resolve_peer(chat_id)
user_peer = await self.resolve_peer(user_id) user_peer = await self.resolve_peer(user_id)

View File

@ -28,7 +28,7 @@ log = logging.getLogger(__name__)
class Filters: class Filters:
ALL = "all" ALL = "all"
KICKED = "kicked" BANNED = "banned"
RESTRICTED = "restricted" RESTRICTED = "restricted"
BOTS = "bots" BOTS = "bots"
RECENT = "recent" 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 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: and channels. It can be any of the followings:
*"all"* - all kind of members, *"all"* - all kind of members,
*"kicked"* - kicked (banned) members only, *"banned"* - banned members only,
*"restricted"* - restricted members only, *"restricted"* - restricted members only,
*"bots"* - bots only, *"bots"* - bots only,
*"recent"* - recent members 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 .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members
on channels. 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: Returns:
List of :obj:`~pyrogram.types.ChatMember`: On success, a list of chat members is returned. 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: if filter == Filters.ALL:
filter = raw.types.ChannelParticipantsSearch(q=query) filter = raw.types.ChannelParticipantsSearch(q=query)
elif filter == Filters.KICKED: elif filter == Filters.BANNED:
filter = raw.types.ChannelParticipantsKicked(q=query) filter = raw.types.ChannelParticipantsKicked(q=query)
elif filter == Filters.RESTRICTED: elif filter == Filters.RESTRICTED:
filter = raw.types.ChannelParticipantsBanned(q=query) filter = raw.types.ChannelParticipantsBanned(q=query)

View File

@ -26,7 +26,7 @@ from pyrogram.scaffold import Scaffold
class Filters: class Filters:
ALL = "all" ALL = "all"
KICKED = "kicked" BANNED = "banned"
RESTRICTED = "restricted" RESTRICTED = "restricted"
BOTS = "bots" BOTS = "bots"
RECENT = "recent" RECENT = "recent"
@ -34,7 +34,7 @@ class Filters:
QUERIES = [""] + [str(i) for i in range(10)] + list(ascii_lowercase) 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): 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 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: and channels. It can be any of the followings:
*"all"* - all kind of members, *"all"* - all kind of members,
*"kicked"* - kicked (banned) members only, *"banned"* - banned members only,
*"restricted"* - restricted members only, *"restricted"* - restricted members only,
*"bots"* - bots only, *"bots"* - bots only,
*"recent"* - recent members 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 .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members
on channels. 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: Returns:
``Generator``: A generator yielding :obj:`~pyrogram.types.ChatMember` objects. ``Generator``: A generator yielding :obj:`~pyrogram.types.ChatMember` objects.

View File

@ -28,7 +28,7 @@ class UnbanChatMember(Scaffold):
chat_id: Union[int, str], chat_id: Union[int, str],
user_id: Union[int, str] user_id: Union[int, str]
) -> bool: ) -> 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. 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. You must be an administrator for this to work.

View File

@ -479,18 +479,18 @@ class Chat(Object):
photo=photo photo=photo
) )
async def kick_member( async def ban_member(
self, self,
user_id: Union[int, str], user_id: Union[int, str],
until_date: int = 0 until_date: int = 0
) -> Union["types.Message", bool]: ) -> 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: Use as a shortcut for:
.. code-block:: python .. code-block:: python
client.kick_chat_member( client.ban_chat_member(
chat_id=chat_id, chat_id=chat_id,
user_id=user_id user_id=user_id
) )
@ -498,7 +498,7 @@ class Chat(Object):
Example: Example:
.. code-block:: python .. code-block:: python
chat.kick_member(123456789) chat.ban_member(123456789)
Note: Note:
In regular groups (non-supergroups), this method will only work if the "All Members Are Admins" setting is 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. 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, chat_id=self.id,
user_id=user_id, user_id=user_id,
until_date=until_date 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 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: and channels. It can be any of the followings:
*"all"* - all kind of members, *"all"* - all kind of members,
*"kicked"* - kicked (banned) members only, *"banned"* - banned members only,
*"restricted"* - restricted members only, *"restricted"* - restricted members only,
*"bots"* - bots only, *"bots"* - bots only,
*"recent"* - recent members 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 .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members
on channels. 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: Example:
.. code-block:: python .. 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 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: and channels. It can be any of the followings:
*"all"* - all kind of members, *"all"* - all kind of members,
*"kicked"* - kicked (banned) members only, *"banned"* - banned members only,
*"restricted"* - restricted members only, *"restricted"* - restricted members only,
*"bots"* - bots only, *"bots"* - bots only,
*"recent"* - recent members 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 .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members
on channels. 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: Example:
.. code-block:: python .. code-block:: python

View File

@ -31,14 +31,14 @@ class ChatMember(Object):
status (``str``): status (``str``):
The member's status in the chat. 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*): title (``str``, *optional*):
A custom title that will be shown to all members instead of "Owner" or "Admin". 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. Creator (owner) and administrators only. Can be None in case there's no custom title set.
until_date (``int``, *optional*): until_date (``int``, *optional*):
Restricted and kicked only. Restricted and banned only.
Date when restrictions will be lifted for this user; unix time. Date when restrictions will be lifted for this user; unix time.
joined_date (``int``, *optional*): joined_date (``int``, *optional*):
@ -53,7 +53,7 @@ class ChatMember(Object):
Administrators only. Information about the user who promoted this member as administrator. Administrators only. Information about the user who promoted this member as administrator.
restricted_by (:obj:`~pyrogram.types.User`, *optional*): 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*): is_member (``bool``, *optional*):
Restricted only. True, if the user is a member of the chat at the moment of the request. 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( return ChatMember(
user=user, 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, until_date=denied_permissions.until_date,
joined_date=member.date, joined_date=member.date,
is_member=not member.left, is_member=not member.left,