banChatMember¶
Returns: bool
- class aiogram.methods.ban_chat_member.BanChatMember(*, chat_id: int | str, user_id: int, until_date: datetime | timedelta | int | None = None, revoke_messages: bool | None = None, **extra_data: Any)[source]¶
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 administrator rights. Returns
True
on success.Source: https://core.telegram.org/bots/api#banchatmember
- chat_id: int | str¶
Unique identifier for the target group or username of the target supergroup or channel (in the format
@channelusername
)
- user_id: int¶
Unique identifier of the target user
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_post_init(context: Any, /) None ¶
We need to both initialize private attributes and call the user-defined model_post_init method.
- until_date: datetime.datetime | datetime.timedelta | int | None¶
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.
- revoke_messages: bool | None¶
Pass
True
to delete all messages from the chat for the user that is being removed. IfFalse
, the user will be able to see messages in the group that were sent before the user was removed. AlwaysTrue
for supergroups and channels.
Usage¶
As bot method¶
result: bool = await bot.ban_chat_member(...)
Method as object¶
Imports:
from aiogram.methods.ban_chat_member import BanChatMember
alias:
from aiogram.methods import BanChatMember
With specific bot¶
result: bool = await bot(BanChatMember(...))
As reply into Webhook in handler¶
return BanChatMember(...)