refactor: renamed kickChatMember to banChatMember

This commit is contained in:
Oleg A 2021-06-25 23:26:29 +03:00
parent 114c914948
commit e676cb1675
2 changed files with 38 additions and 21 deletions

View file

@ -225,6 +225,7 @@ class Methods(Helper):
GET_USER_PROFILE_PHOTOS = Item() # getUserProfilePhotos
GET_FILE = Item() # getFile
KICK_CHAT_MEMBER = Item() # kickChatMember
BAN_CHAT_MEMBER = Item() # banChatMember
UNBAN_CHAT_MEMBER = Item() # unbanChatMember
RESTRICT_CHAT_MEMBER = Item() # restrictChatMember
PROMOTE_CHAT_MEMBER = Item() # promoteChatMember

View file

@ -1562,7 +1562,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
result = await self.request(api.Methods.GET_FILE, payload)
return types.File(**result)
async def kick_chat_member(self,
async def ban_chat_member(self,
chat_id: typing.Union[base.Integer, base.String],
user_id: base.Integer,
until_date: typing.Union[base.Integer, datetime.datetime,
@ -1570,33 +1570,34 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
revoke_messages: typing.Optional[base.Boolean] = None,
) -> base.Boolean:
"""
Use this method to kick 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 chat on their own using invite links, etc., unless unbanned first.
Use this method to ban a user in a group, a supergroup or a
channel. In the case of supergroups and channels, the user will
not be able to return to the chat on their own using invite
links, etc., unless unbanned first. The bot must be an
administrator in the chat for this to work and must have the
appropriate admin rights. Returns True on success.
The bot must be an administrator in the chat for this to work and must have
the appropriate admin rights.
Source: https://core.telegram.org/bots/api#banchatmember
Source: https://core.telegram.org/bots/api#kickchatmember
:param chat_id: Unique identifier for the target group or username of the
target supergroup or channel (in the format @channelusername)
:param chat_id: Unique identifier for the target group or
username of the target supergroup or channel (in the format
@channelusername)
:type chat_id: :obj:`typing.Union[base.Integer, base.String]`
:param user_id: Unique identifier of the target user
:type user_id: :obj:`base.Integer`
:param until_date: Date when the user will be unbanned. If user is banned
for more than 366 days or less than 30 seconds from the current time they
are considered to be banned forever. Applied for supergroups and channels
only.
:type until_date: :obj:`typing.Union[base.Integer, datetime.datetime,
datetime.timedelta, None]`
:param until_date: Date when the user will be unbanned, unix
time. If user is banned for more than 366 days or less than
30 seconds from the current time they are considered to be
banned forever. Applied for supergroups and channels only.
:type until_date: :obj:`typing.Union[base.Integer,
datetime.datetime, datetime.timedelta, None]`
:param revoke_messages: Pass True to delete all messages from the chat for
the user that is being removed. If False, the user will be able to see
messages in the group that were sent before the user was removed. Always
True for supergroups and channels.
:param revoke_messages: Pass True to delete all messages from
the chat for the user that is being removed. If False, the user
will be able to see messages in the group that were sent before
the user was removed. Always True for supergroups and channels.
:type revoke_messages: :obj:`typing.Optional[base.Boolean]`
:return: Returns True on success
@ -1605,7 +1606,22 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
until_date = prepare_arg(until_date)
payload = generate_payload(**locals())
return await self.request(api.Methods.KICK_CHAT_MEMBER, payload)
return await self.request(api.Methods.BAN_CHAT_MEMBER, payload)
async def kick_chat_member(self,
chat_id: typing.Union[base.Integer, base.String],
user_id: base.Integer,
until_date: typing.Union[base.Integer, datetime.datetime,
datetime.timedelta, None] = None,
revoke_messages: typing.Optional[base.Boolean] = None,
) -> base.Boolean:
"""Renamed to ban_chat_member."""
return await self.ban_chat_member(
chat_id=chat_id,
user_id=user_id,
until_date=until_date,
revoke_messages=revoke_messages,
)
async def unban_chat_member(self,
chat_id: typing.Union[base.Integer, base.String],