2016-05-24 01:22:31 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2024-02-19 20:06:25 +01:00
|
|
|
# Copyright (C) 2015-2024
|
2016-05-24 01:22:31 +02:00
|
|
|
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser Public License
|
|
|
|
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
2016-10-17 00:22:40 +02:00
|
|
|
"""This module contains an object that represents a Telegram ChatMember."""
|
2024-09-01 09:32:42 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
import datetime
|
2023-06-29 18:17:47 +02:00
|
|
|
from typing import TYPE_CHECKING, Dict, Final, Optional, Type
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram import constants
|
|
|
|
from telegram._telegramobject import TelegramObject
|
|
|
|
from telegram._user import User
|
2023-04-18 16:16:23 +02:00
|
|
|
from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
|
2021-10-10 15:10:21 +02:00
|
|
|
from telegram._utils.types import JSONDict
|
2020-10-09 17:22:07 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
from telegram import Bot
|
|
|
|
|
2016-05-24 01:22:31 +02:00
|
|
|
|
|
|
|
class ChatMember(TelegramObject):
|
2021-07-01 17:45:19 +02:00
|
|
|
"""Base class for Telegram ChatMember Objects.
|
|
|
|
Currently, the following 6 types of chat members are supported:
|
|
|
|
|
|
|
|
* :class:`telegram.ChatMemberOwner`
|
|
|
|
* :class:`telegram.ChatMemberAdministrator`
|
|
|
|
* :class:`telegram.ChatMemberMember`
|
|
|
|
* :class:`telegram.ChatMemberRestricted`
|
|
|
|
* :class:`telegram.ChatMemberLeft`
|
|
|
|
* :class:`telegram.ChatMemberBanned`
|
2016-05-24 01:22:31 +02:00
|
|
|
|
2020-07-14 21:33:56 +02:00
|
|
|
Objects of this class are comparable in terms of equality. Two objects of this class are
|
|
|
|
considered equal, if their :attr:`user` and :attr:`status` are equal.
|
|
|
|
|
Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
|
|
|
Examples:
|
2023-01-01 16:24:00 +01:00
|
|
|
:any:`Chat Member Bot <examples.chatmemberbot>`
|
2022-08-27 11:46:51 +02:00
|
|
|
|
2022-05-06 17:15:23 +02:00
|
|
|
.. versionchanged:: 20.0
|
2022-06-09 17:08:54 +02:00
|
|
|
|
2022-04-30 22:18:11 +02:00
|
|
|
* As of Bot API 5.3, :class:`ChatMember` is nothing but the base class for the subclasses
|
|
|
|
listed above and is no longer returned directly by :meth:`~telegram.Bot.get_chat`.
|
|
|
|
Therefore, most of the arguments and attributes were removed and you should no longer
|
|
|
|
use :class:`ChatMember` directly.
|
|
|
|
* The constant ``ChatMember.CREATOR`` was replaced by :attr:`~telegram.ChatMember.OWNER`
|
|
|
|
* The constant ``ChatMember.KICKED`` was replaced by :attr:`~telegram.ChatMember.BANNED`
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2016-05-24 01:22:31 +02:00
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2021-07-01 17:45:19 +02:00
|
|
|
status (:obj:`str`): The member's status in the chat. Can be
|
2022-04-30 22:18:11 +02:00
|
|
|
:attr:`~telegram.ChatMember.ADMINISTRATOR`, :attr:`~telegram.ChatMember.OWNER`,
|
|
|
|
:attr:`~telegram.ChatMember.BANNED`, :attr:`~telegram.ChatMember.LEFT`,
|
2021-07-01 17:45:19 +02:00
|
|
|
:attr:`~telegram.ChatMember.MEMBER` or :attr:`~telegram.ChatMember.RESTRICTED`.
|
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Attributes:
|
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2023-01-01 16:24:00 +01:00
|
|
|
status (:obj:`str`): The member's status in the chat. Can be
|
|
|
|
:attr:`~telegram.ChatMember.ADMINISTRATOR`, :attr:`~telegram.ChatMember.OWNER`,
|
|
|
|
:attr:`~telegram.ChatMember.BANNED`, :attr:`~telegram.ChatMember.LEFT`,
|
|
|
|
:attr:`~telegram.ChatMember.MEMBER` or :attr:`~telegram.ChatMember.RESTRICTED`.
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2017-09-01 08:43:08 +02:00
|
|
|
"""
|
2020-10-23 13:40:02 +02:00
|
|
|
|
2024-02-05 19:24:00 +01:00
|
|
|
__slots__ = ("status", "user")
|
2021-05-29 16:18:16 +02:00
|
|
|
|
2023-06-29 18:17:47 +02:00
|
|
|
ADMINISTRATOR: Final[str] = constants.ChatMemberStatus.ADMINISTRATOR
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.ChatMemberStatus.ADMINISTRATOR`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
OWNER: Final[str] = constants.ChatMemberStatus.OWNER
|
2022-04-30 22:18:11 +02:00
|
|
|
""":const:`telegram.constants.ChatMemberStatus.OWNER`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
BANNED: Final[str] = constants.ChatMemberStatus.BANNED
|
2022-04-30 22:18:11 +02:00
|
|
|
""":const:`telegram.constants.ChatMemberStatus.BANNED`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
LEFT: Final[str] = constants.ChatMemberStatus.LEFT
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.ChatMemberStatus.LEFT`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
MEMBER: Final[str] = constants.ChatMemberStatus.MEMBER
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.ChatMemberStatus.MEMBER`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
RESTRICTED: Final[str] = constants.ChatMemberStatus.RESTRICTED
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.ChatMemberStatus.RESTRICTED`"""
|
2016-05-28 16:51:44 +02:00
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
user: User,
|
|
|
|
status: str,
|
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
):
|
|
|
|
super().__init__(api_kwargs=api_kwargs)
|
2021-08-29 18:17:06 +02:00
|
|
|
# Required by all subclasses
|
2023-02-02 18:55:07 +01:00
|
|
|
self.user: User = user
|
|
|
|
self.status: str = status
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2017-05-14 23:29:31 +02:00
|
|
|
self._id_attrs = (self.user, self.status)
|
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
|
|
|
|
2017-07-23 21:14:38 +02:00
|
|
|
@classmethod
|
2024-07-01 19:59:54 +02:00
|
|
|
def de_json(
|
|
|
|
cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
|
|
|
|
) -> Optional["ChatMember"]:
|
2021-05-27 09:38:17 +02:00
|
|
|
"""See :meth:`telegram.TelegramObject.de_json`."""
|
|
|
|
data = cls._parse_data(data)
|
2020-10-06 19:28:40 +02:00
|
|
|
|
2016-05-24 01:22:31 +02:00
|
|
|
if not data:
|
|
|
|
return None
|
|
|
|
|
2023-08-02 11:51:17 +02:00
|
|
|
_class_mapping: Dict[str, Type[ChatMember]] = {
|
2022-04-30 22:18:11 +02:00
|
|
|
cls.OWNER: ChatMemberOwner,
|
2021-07-01 17:45:19 +02:00
|
|
|
cls.ADMINISTRATOR: ChatMemberAdministrator,
|
|
|
|
cls.MEMBER: ChatMemberMember,
|
|
|
|
cls.RESTRICTED: ChatMemberRestricted,
|
|
|
|
cls.LEFT: ChatMemberLeft,
|
2022-04-30 22:18:11 +02:00
|
|
|
cls.BANNED: ChatMemberBanned,
|
2021-07-01 17:45:19 +02:00
|
|
|
}
|
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
if cls is ChatMember and data.get("status") in _class_mapping:
|
|
|
|
return _class_mapping[data.pop("status")].de_json(data=data, bot=bot)
|
|
|
|
|
|
|
|
data["user"] = User.de_json(data.get("user"), bot)
|
|
|
|
if "until_date" in data:
|
2023-04-18 16:16:23 +02:00
|
|
|
# Get the local timezone from the bot if it has defaults
|
|
|
|
loc_tzinfo = extract_tzinfo_from_defaults(bot)
|
|
|
|
|
|
|
|
data["until_date"] = from_timestamp(data["until_date"], tzinfo=loc_tzinfo)
|
2022-10-07 11:51:53 +02:00
|
|
|
|
2023-09-03 14:23:48 +02:00
|
|
|
# This is a deprecated field that TG still returns for backwards compatibility
|
|
|
|
# Let's filter it out to speed up the de-json process
|
|
|
|
if cls is ChatMemberRestricted and data.get("can_send_media_messages") is not None:
|
|
|
|
api_kwargs = {"can_send_media_messages": data.pop("can_send_media_messages")}
|
|
|
|
return super()._de_json(data=data, bot=bot, api_kwargs=api_kwargs)
|
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
return super().de_json(data=data, bot=bot)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
class ChatMemberOwner(ChatMember):
|
|
|
|
"""
|
|
|
|
Represents a chat member that owns the chat
|
|
|
|
and has all administrator privileges.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
Args:
|
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2021-08-29 18:17:06 +02:00
|
|
|
is_anonymous (:obj:`bool`): :obj:`True`, if the
|
2021-07-01 17:45:19 +02:00
|
|
|
user's presence in the chat is hidden.
|
2021-08-29 18:17:06 +02:00
|
|
|
custom_title (:obj:`str`, optional): Custom title for this user.
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
Attributes:
|
|
|
|
status (:obj:`str`): The member's status in the chat,
|
2022-04-30 22:18:11 +02:00
|
|
|
always :tg-const:`telegram.ChatMember.OWNER`.
|
2021-07-01 17:45:19 +02:00
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2021-08-29 18:17:06 +02:00
|
|
|
is_anonymous (:obj:`bool`): :obj:`True`, if the user's
|
|
|
|
presence in the chat is hidden.
|
2021-07-01 17:45:19 +02:00
|
|
|
custom_title (:obj:`str`): Optional. Custom title for
|
|
|
|
this user.
|
|
|
|
"""
|
|
|
|
|
2024-02-05 19:24:00 +01:00
|
|
|
__slots__ = ("custom_title", "is_anonymous")
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
user: User,
|
2021-08-29 18:17:06 +02:00
|
|
|
is_anonymous: bool,
|
2023-05-18 07:57:59 +02:00
|
|
|
custom_title: Optional[str] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-07-01 17:45:19 +02:00
|
|
|
):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(status=ChatMember.OWNER, user=user, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-02-02 18:55:07 +01:00
|
|
|
self.is_anonymous: bool = is_anonymous
|
|
|
|
self.custom_title: Optional[str] = custom_title
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ChatMemberAdministrator(ChatMember):
|
|
|
|
"""
|
|
|
|
Represents a chat member that has some additional privileges.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
2022-05-03 18:21:50 +02:00
|
|
|
.. versionchanged:: 20.0
|
2022-10-07 11:51:53 +02:00
|
|
|
|
|
|
|
* Argument and attribute ``can_manage_voice_chats`` were renamed to
|
|
|
|
:paramref:`can_manage_video_chats` and :attr:`can_manage_video_chats` in accordance to
|
|
|
|
Bot API 6.0.
|
2022-11-22 10:43:50 +01:00
|
|
|
* The argument :paramref:`can_manage_topics` was added, which changes the position of the
|
|
|
|
optional argument :paramref:`custom_title`.
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2024-04-12 12:39:38 +02:00
|
|
|
.. versionchanged:: 21.1
|
2024-04-06 17:13:43 +02:00
|
|
|
As of this version, :attr:`can_post_stories`, :attr:`can_edit_stories`,
|
|
|
|
and :attr:`can_delete_stories` is now required. Thus, the order of arguments had to be
|
|
|
|
changed.
|
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
Args:
|
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_be_edited (:obj:`bool`): :obj:`True`, if the bot
|
2021-07-01 17:45:19 +02:00
|
|
|
is allowed to edit administrator privileges of that user.
|
2021-08-29 18:17:06 +02:00
|
|
|
is_anonymous (:obj:`bool`): :obj:`True`, if the user's
|
2021-07-01 17:45:19 +02:00
|
|
|
presence in the chat is hidden.
|
2024-03-02 10:56:15 +01:00
|
|
|
can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
|
|
|
|
log, get boost list, see hidden supergroup and channel members, report spam messages
|
2021-07-01 17:45:19 +02:00
|
|
|
and ignore slow mode. Implied by any other administrator privilege.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_delete_messages (:obj:`bool`): :obj:`True`, if the
|
2021-07-01 17:45:19 +02:00
|
|
|
administrator can delete messages of other users.
|
2022-05-03 18:21:50 +02:00
|
|
|
can_manage_video_chats (:obj:`bool`): :obj:`True`, if the
|
|
|
|
administrator can manage video chats.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2021-08-29 18:17:06 +02:00
|
|
|
can_restrict_members (:obj:`bool`): :obj:`True`, if the
|
2021-07-01 17:45:19 +02:00
|
|
|
administrator can restrict, ban or unban chat members.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_promote_members (:obj:`bool`): :obj:`True`, if the administrator
|
2021-07-01 17:45:19 +02:00
|
|
|
can add new administrators with a subset of his own privileges or demote
|
|
|
|
administrators that he has promoted, directly or indirectly (promoted by
|
|
|
|
administrators that were appointed by the user).
|
2021-08-29 18:17:06 +02:00
|
|
|
can_change_info (:obj:`bool`): :obj:`True`, if the user can change
|
2021-07-01 17:45:19 +02:00
|
|
|
the chat title, photo and other settings.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_invite_users (:obj:`bool`): :obj:`True`, if the user can invite
|
2021-07-01 17:45:19 +02:00
|
|
|
new users to the chat.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_post_messages (:obj:`bool`, optional): :obj:`True`, if the
|
2024-03-06 14:45:50 +01:00
|
|
|
administrator can post messages in the channel, or access channel statistics;
|
|
|
|
for channels only.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_edit_messages (:obj:`bool`, optional): :obj:`True`, if the
|
|
|
|
administrator can edit messages of other users and can pin
|
2024-03-06 14:45:50 +01:00
|
|
|
messages; for channels only.
|
2021-07-01 17:45:19 +02:00
|
|
|
can_pin_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed
|
2024-03-06 14:45:50 +01:00
|
|
|
to pin messages; for groups and supergroups only.
|
2024-03-02 10:56:15 +01:00
|
|
|
can_post_stories (:obj:`bool`): :obj:`True`, if the administrator can post
|
|
|
|
stories to the chat.
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-03-02 10:56:15 +01:00
|
|
|
|non_optional_story_argument|
|
2024-05-20 15:25:25 +02:00
|
|
|
can_edit_stories (:obj:`bool`): :obj:`True`, if the administrator can edit stories posted
|
|
|
|
by other users, post stories to the chat page, pin chat stories, and access the chat's
|
|
|
|
story archive
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-03-02 10:56:15 +01:00
|
|
|
|non_optional_story_argument|
|
|
|
|
can_delete_stories (:obj:`bool`): :obj:`True`, if the administrator can delete
|
|
|
|
stories posted by other users.
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-03-02 10:56:15 +01:00
|
|
|
|non_optional_story_argument|
|
2022-11-22 10:43:50 +01:00
|
|
|
can_manage_topics (:obj:`bool`, optional): :obj:`True`, if the user is allowed
|
2024-03-06 14:45:50 +01:00
|
|
|
to create, rename, close, and reopen forum topics; for supergroups only.
|
2022-11-22 10:43:50 +01:00
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2021-08-29 18:17:06 +02:00
|
|
|
custom_title (:obj:`str`, optional): Custom title for this user.
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
Attributes:
|
|
|
|
status (:obj:`str`): The member's status in the chat,
|
2021-10-19 18:28:19 +02:00
|
|
|
always :tg-const:`telegram.ChatMember.ADMINISTRATOR`.
|
2021-07-01 17:45:19 +02:00
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_be_edited (:obj:`bool`): :obj:`True`, if the bot
|
2021-07-01 17:45:19 +02:00
|
|
|
is allowed to edit administrator privileges of that user.
|
2021-08-29 18:17:06 +02:00
|
|
|
is_anonymous (:obj:`bool`): :obj:`True`, if the user's
|
2021-07-01 17:45:19 +02:00
|
|
|
presence in the chat is hidden.
|
2023-10-03 15:11:37 +02:00
|
|
|
can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
|
2024-03-02 10:56:15 +01:00
|
|
|
log, get boost list, see hidden supergroup and channel members, report spam messages
|
|
|
|
and ignore slow mode. Implied by any other administrator privilege.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_delete_messages (:obj:`bool`): :obj:`True`, if the
|
2021-07-01 17:45:19 +02:00
|
|
|
administrator can delete messages of other users.
|
2022-05-03 18:21:50 +02:00
|
|
|
can_manage_video_chats (:obj:`bool`): :obj:`True`, if the
|
|
|
|
administrator can manage video chats.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2021-08-29 18:17:06 +02:00
|
|
|
can_restrict_members (:obj:`bool`): :obj:`True`, if the
|
2023-10-03 15:11:37 +02:00
|
|
|
administrator can restrict, ban or unban chat members, or access supergroup statistics.
|
2023-02-05 18:09:55 +01:00
|
|
|
can_promote_members (:obj:`bool`): :obj:`True`, if the administrator can add new
|
|
|
|
administrators with a subset of their own privileges or demote administrators
|
|
|
|
that they have promoted, directly or indirectly (promoted by administrators that
|
|
|
|
were appointed by the user).
|
2021-08-29 18:17:06 +02:00
|
|
|
can_change_info (:obj:`bool`): :obj:`True`, if the user can change
|
2021-07-01 17:45:19 +02:00
|
|
|
the chat title, photo and other settings.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_invite_users (:obj:`bool`): :obj:`True`, if the user can invite
|
2021-07-01 17:45:19 +02:00
|
|
|
new users to the chat.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_post_messages (:obj:`bool`): Optional. :obj:`True`, if the
|
2023-10-03 15:11:37 +02:00
|
|
|
administrator can post messages in the channel or access channel statistics;
|
2024-03-06 14:45:50 +01:00
|
|
|
for channels only.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_edit_messages (:obj:`bool`): Optional. :obj:`True`, if the
|
|
|
|
administrator can edit messages of other users and can pin
|
2024-03-06 14:45:50 +01:00
|
|
|
messages; for channels only.
|
2021-07-01 17:45:19 +02:00
|
|
|
can_pin_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed
|
2024-03-06 14:45:50 +01:00
|
|
|
to pin messages; for groups and supergroups only.
|
2024-03-02 10:56:15 +01:00
|
|
|
can_post_stories (:obj:`bool`): :obj:`True`, if the administrator can post
|
|
|
|
stories to the chat.
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-03-02 10:56:15 +01:00
|
|
|
|non_optional_story_argument|
|
2024-05-20 15:25:25 +02:00
|
|
|
can_edit_stories (:obj:`bool`): :obj:`True`, if the administrator can edit stories posted
|
|
|
|
by other users, post stories to the chat page, pin chat stories, and access the chat's
|
|
|
|
story archive
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-03-02 10:56:15 +01:00
|
|
|
|non_optional_story_argument|
|
|
|
|
can_delete_stories (:obj:`bool`): :obj:`True`, if the administrator can delete
|
|
|
|
stories posted by other users.
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2024-03-06 21:09:47 +01:00
|
|
|
.. versionchanged:: 21.0
|
2024-03-02 10:56:15 +01:00
|
|
|
|non_optional_story_argument|
|
2022-11-22 10:43:50 +01:00
|
|
|
can_manage_topics (:obj:`bool`): Optional. :obj:`True`, if the user is allowed
|
2024-03-06 14:45:50 +01:00
|
|
|
to create, rename, close, and reopen forum topics; for supergroups only
|
2022-11-22 10:43:50 +01:00
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2021-08-29 18:17:06 +02:00
|
|
|
custom_title (:obj:`str`): Optional. Custom title for this user.
|
2021-07-01 17:45:19 +02:00
|
|
|
"""
|
|
|
|
|
2021-08-29 18:17:06 +02:00
|
|
|
__slots__ = (
|
|
|
|
"can_be_edited",
|
|
|
|
"can_change_info",
|
2024-02-05 19:24:00 +01:00
|
|
|
"can_delete_messages",
|
|
|
|
"can_delete_stories",
|
2021-08-29 18:17:06 +02:00
|
|
|
"can_edit_messages",
|
2024-02-05 19:24:00 +01:00
|
|
|
"can_edit_stories",
|
|
|
|
"can_invite_users",
|
|
|
|
"can_manage_chat",
|
2022-11-22 10:43:50 +01:00
|
|
|
"can_manage_topics",
|
2024-02-05 19:24:00 +01:00
|
|
|
"can_manage_video_chats",
|
|
|
|
"can_pin_messages",
|
|
|
|
"can_post_messages",
|
2023-10-03 14:32:57 +02:00
|
|
|
"can_post_stories",
|
2024-02-05 19:24:00 +01:00
|
|
|
"can_promote_members",
|
|
|
|
"can_restrict_members",
|
|
|
|
"custom_title",
|
|
|
|
"is_anonymous",
|
2021-08-29 18:17:06 +02:00
|
|
|
)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
user: User,
|
2021-08-29 18:17:06 +02:00
|
|
|
can_be_edited: bool,
|
|
|
|
is_anonymous: bool,
|
|
|
|
can_manage_chat: bool,
|
|
|
|
can_delete_messages: bool,
|
2022-05-03 18:21:50 +02:00
|
|
|
can_manage_video_chats: bool,
|
2021-08-29 18:17:06 +02:00
|
|
|
can_restrict_members: bool,
|
|
|
|
can_promote_members: bool,
|
|
|
|
can_change_info: bool,
|
|
|
|
can_invite_users: bool,
|
2024-04-06 17:13:43 +02:00
|
|
|
can_post_stories: bool,
|
|
|
|
can_edit_stories: bool,
|
|
|
|
can_delete_stories: bool,
|
2023-05-18 07:57:59 +02:00
|
|
|
can_post_messages: Optional[bool] = None,
|
|
|
|
can_edit_messages: Optional[bool] = None,
|
|
|
|
can_pin_messages: Optional[bool] = None,
|
|
|
|
can_manage_topics: Optional[bool] = None,
|
|
|
|
custom_title: Optional[str] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-07-01 17:45:19 +02:00
|
|
|
):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(status=ChatMember.ADMINISTRATOR, user=user, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-02-02 18:55:07 +01:00
|
|
|
self.can_be_edited: bool = can_be_edited
|
|
|
|
self.is_anonymous: bool = is_anonymous
|
|
|
|
self.can_manage_chat: bool = can_manage_chat
|
|
|
|
self.can_delete_messages: bool = can_delete_messages
|
|
|
|
self.can_manage_video_chats: bool = can_manage_video_chats
|
|
|
|
self.can_restrict_members: bool = can_restrict_members
|
|
|
|
self.can_promote_members: bool = can_promote_members
|
|
|
|
self.can_change_info: bool = can_change_info
|
|
|
|
self.can_invite_users: bool = can_invite_users
|
2024-03-02 10:56:15 +01:00
|
|
|
self.can_post_stories: bool = can_post_stories
|
|
|
|
self.can_edit_stories: bool = can_edit_stories
|
|
|
|
self.can_delete_stories: bool = can_delete_stories
|
|
|
|
# Optionals
|
2023-02-02 18:55:07 +01:00
|
|
|
self.can_post_messages: Optional[bool] = can_post_messages
|
|
|
|
self.can_edit_messages: Optional[bool] = can_edit_messages
|
|
|
|
self.can_pin_messages: Optional[bool] = can_pin_messages
|
|
|
|
self.can_manage_topics: Optional[bool] = can_manage_topics
|
|
|
|
self.custom_title: Optional[str] = custom_title
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ChatMemberMember(ChatMember):
|
|
|
|
"""
|
|
|
|
Represents a chat member that has no additional
|
|
|
|
privileges or restrictions.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
Args:
|
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2024-09-01 09:32:42 +02:00
|
|
|
until_date (:class:`datetime.datetime`, optional): Date when the user's subscription will
|
|
|
|
expire.
|
|
|
|
|
|
|
|
.. versionadded:: NEXT.VERSION
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
Attributes:
|
|
|
|
status (:obj:`str`): The member's status in the chat,
|
2021-10-19 18:28:19 +02:00
|
|
|
always :tg-const:`telegram.ChatMember.MEMBER`.
|
2021-07-01 17:45:19 +02:00
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2024-09-01 09:32:42 +02:00
|
|
|
until_date (:class:`datetime.datetime`): Optional. Date when the user's subscription will
|
|
|
|
expire.
|
|
|
|
|
|
|
|
.. versionadded:: NEXT.VERSION
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
2024-09-01 09:32:42 +02:00
|
|
|
__slots__ = ("until_date",)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
user: User,
|
2024-09-01 09:32:42 +02:00
|
|
|
until_date: Optional[datetime.datetime] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
):
|
|
|
|
super().__init__(status=ChatMember.MEMBER, user=user, api_kwargs=api_kwargs)
|
2024-09-01 09:32:42 +02:00
|
|
|
with self._unfrozen():
|
|
|
|
self.until_date: Optional[datetime.datetime] = until_date
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ChatMemberRestricted(ChatMember):
|
|
|
|
"""
|
|
|
|
Represents a chat member that is under certain restrictions
|
|
|
|
in the chat. Supergroups only.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
2022-11-22 10:43:50 +01:00
|
|
|
.. versionchanged:: 20.0
|
2023-02-08 11:47:21 +01:00
|
|
|
All arguments were made positional and their order was changed.
|
|
|
|
The argument can_manage_topics was added.
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
Removed deprecated argument and attribute ``can_send_media_messages``.
|
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
Args:
|
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2021-08-29 18:17:06 +02:00
|
|
|
is_member (:obj:`bool`): :obj:`True`, if the user is a
|
2021-07-01 17:45:19 +02:00
|
|
|
member of the chat at the moment of the request.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_change_info (:obj:`bool`): :obj:`True`, if the user can change
|
2021-07-01 17:45:19 +02:00
|
|
|
the chat title, photo and other settings.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_invite_users (:obj:`bool`): :obj:`True`, if the user can invite
|
2021-07-01 17:45:19 +02:00
|
|
|
new users to the chat.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_pin_messages (:obj:`bool`): :obj:`True`, if the user is allowed
|
2021-07-01 17:45:19 +02:00
|
|
|
to pin messages; groups and supergroups only.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_send_messages (:obj:`bool`): :obj:`True`, if the user is allowed
|
2023-02-08 11:47:21 +01:00
|
|
|
to send text messages, contacts, invoices, locations and venues.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_send_polls (:obj:`bool`): :obj:`True`, if the user is allowed
|
2021-07-01 17:45:19 +02:00
|
|
|
to send polls.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_send_other_messages (:obj:`bool`): :obj:`True`, if the user is allowed
|
2021-07-01 17:45:19 +02:00
|
|
|
to send animations, games, stickers and use inline bots.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_add_web_page_previews (:obj:`bool`): :obj:`True`, if the user is
|
2021-07-01 17:45:19 +02:00
|
|
|
allowed to add web page previews to their messages.
|
2022-11-22 10:43:50 +01:00
|
|
|
can_manage_topics (:obj:`bool`): :obj:`True`, if the user is allowed to create
|
|
|
|
forum topics.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2021-08-29 18:17:06 +02:00
|
|
|
until_date (:class:`datetime.datetime`): Date when restrictions
|
2021-07-01 17:45:19 +02:00
|
|
|
will be lifted for this user.
|
2023-04-18 16:16:23 +02:00
|
|
|
|
2023-05-07 15:31:23 +02:00
|
|
|
.. versionchanged:: 20.3
|
2023-04-18 16:16:23 +02:00
|
|
|
|datetime_localization|
|
2023-02-08 11:47:21 +01:00
|
|
|
can_send_audios (:obj:`bool`): :obj:`True`, if the user is allowed to send audios.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_documents (:obj:`bool`): :obj:`True`, if the user is allowed to send documents.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_photos (:obj:`bool`): :obj:`True`, if the user is allowed to send photos.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_videos (:obj:`bool`): :obj:`True`, if the user is allowed to send videos.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_video_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send video
|
|
|
|
notes.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_voice_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send voice
|
|
|
|
notes.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
Attributes:
|
|
|
|
status (:obj:`str`): The member's status in the chat,
|
2021-10-19 18:28:19 +02:00
|
|
|
always :tg-const:`telegram.ChatMember.RESTRICTED`.
|
2021-07-01 17:45:19 +02:00
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2021-08-29 18:17:06 +02:00
|
|
|
is_member (:obj:`bool`): :obj:`True`, if the user is a
|
2021-07-01 17:45:19 +02:00
|
|
|
member of the chat at the moment of the request.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_change_info (:obj:`bool`): :obj:`True`, if the user can change
|
2021-07-01 17:45:19 +02:00
|
|
|
the chat title, photo and other settings.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_invite_users (:obj:`bool`): :obj:`True`, if the user can invite
|
2021-07-01 17:45:19 +02:00
|
|
|
new users to the chat.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_pin_messages (:obj:`bool`): :obj:`True`, if the user is allowed
|
2021-07-01 17:45:19 +02:00
|
|
|
to pin messages; groups and supergroups only.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_send_messages (:obj:`bool`): :obj:`True`, if the user is allowed
|
2021-07-01 17:45:19 +02:00
|
|
|
to send text messages, contacts, locations and venues.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_send_polls (:obj:`bool`): :obj:`True`, if the user is allowed
|
2021-07-01 17:45:19 +02:00
|
|
|
to send polls.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_send_other_messages (:obj:`bool`): :obj:`True`, if the user is allowed
|
2021-07-01 17:45:19 +02:00
|
|
|
to send animations, games, stickers and use inline bots.
|
2021-08-29 18:17:06 +02:00
|
|
|
can_add_web_page_previews (:obj:`bool`): :obj:`True`, if the user is
|
2021-07-01 17:45:19 +02:00
|
|
|
allowed to add web page previews to their messages.
|
2022-11-22 10:43:50 +01:00
|
|
|
can_manage_topics (:obj:`bool`): :obj:`True`, if the user is allowed to create
|
|
|
|
forum topics.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2021-08-29 18:17:06 +02:00
|
|
|
until_date (:class:`datetime.datetime`): Date when restrictions
|
2021-07-01 17:45:19 +02:00
|
|
|
will be lifted for this user.
|
2023-04-18 16:16:23 +02:00
|
|
|
|
2023-05-07 15:31:23 +02:00
|
|
|
.. versionchanged:: 20.3
|
2023-04-18 16:16:23 +02:00
|
|
|
|datetime_localization|
|
2023-02-08 11:47:21 +01:00
|
|
|
can_send_audios (:obj:`bool`): :obj:`True`, if the user is allowed to send audios.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_documents (:obj:`bool`): :obj:`True`, if the user is allowed to send documents.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_photos (:obj:`bool`): :obj:`True`, if the user is allowed to send photos.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_videos (:obj:`bool`): :obj:`True`, if the user is allowed to send videos.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_video_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send video
|
|
|
|
notes.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
|
|
|
can_send_voice_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send voice
|
|
|
|
notes.
|
|
|
|
|
|
|
|
.. versionadded:: 20.1
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
2021-08-29 18:17:06 +02:00
|
|
|
__slots__ = (
|
2024-02-05 19:24:00 +01:00
|
|
|
"can_add_web_page_previews",
|
2021-08-29 18:17:06 +02:00
|
|
|
"can_change_info",
|
|
|
|
"can_invite_users",
|
2022-11-22 10:43:50 +01:00
|
|
|
"can_manage_topics",
|
2024-02-05 19:24:00 +01:00
|
|
|
"can_pin_messages",
|
2023-02-08 11:47:21 +01:00
|
|
|
"can_send_audios",
|
|
|
|
"can_send_documents",
|
2024-02-05 19:24:00 +01:00
|
|
|
"can_send_messages",
|
|
|
|
"can_send_other_messages",
|
2023-02-08 11:47:21 +01:00
|
|
|
"can_send_photos",
|
2024-02-05 19:24:00 +01:00
|
|
|
"can_send_polls",
|
2023-02-08 11:47:21 +01:00
|
|
|
"can_send_video_notes",
|
2024-02-05 19:24:00 +01:00
|
|
|
"can_send_videos",
|
2023-02-08 11:47:21 +01:00
|
|
|
"can_send_voice_notes",
|
2024-02-05 19:24:00 +01:00
|
|
|
"is_member",
|
|
|
|
"until_date",
|
2021-08-29 18:17:06 +02:00
|
|
|
)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
user: User,
|
2021-08-29 18:17:06 +02:00
|
|
|
is_member: bool,
|
|
|
|
can_change_info: bool,
|
|
|
|
can_invite_users: bool,
|
|
|
|
can_pin_messages: bool,
|
|
|
|
can_send_messages: bool,
|
|
|
|
can_send_polls: bool,
|
|
|
|
can_send_other_messages: bool,
|
|
|
|
can_add_web_page_previews: bool,
|
2022-11-22 10:43:50 +01:00
|
|
|
can_manage_topics: bool,
|
2021-08-29 18:17:06 +02:00
|
|
|
until_date: datetime.datetime,
|
2023-02-08 11:47:21 +01:00
|
|
|
can_send_audios: bool,
|
|
|
|
can_send_documents: bool,
|
|
|
|
can_send_photos: bool,
|
|
|
|
can_send_videos: bool,
|
|
|
|
can_send_video_notes: bool,
|
|
|
|
can_send_voice_notes: bool,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-07-01 17:45:19 +02:00
|
|
|
):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(status=ChatMember.RESTRICTED, user=user, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-02-02 18:55:07 +01:00
|
|
|
self.is_member: bool = is_member
|
|
|
|
self.can_change_info: bool = can_change_info
|
|
|
|
self.can_invite_users: bool = can_invite_users
|
|
|
|
self.can_pin_messages: bool = can_pin_messages
|
|
|
|
self.can_send_messages: bool = can_send_messages
|
|
|
|
self.can_send_polls: bool = can_send_polls
|
|
|
|
self.can_send_other_messages: bool = can_send_other_messages
|
|
|
|
self.can_add_web_page_previews: bool = can_add_web_page_previews
|
|
|
|
self.can_manage_topics: bool = can_manage_topics
|
|
|
|
self.until_date: datetime.datetime = until_date
|
2023-02-08 11:47:21 +01:00
|
|
|
self.can_send_audios: bool = can_send_audios
|
|
|
|
self.can_send_documents: bool = can_send_documents
|
|
|
|
self.can_send_photos: bool = can_send_photos
|
|
|
|
self.can_send_videos: bool = can_send_videos
|
|
|
|
self.can_send_video_notes: bool = can_send_video_notes
|
|
|
|
self.can_send_voice_notes: bool = can_send_voice_notes
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ChatMemberLeft(ChatMember):
|
|
|
|
"""
|
|
|
|
Represents a chat member that isn't currently a member of the chat,
|
|
|
|
but may join it themselves.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
Args:
|
|
|
|
user (:class:`telegram.User`): Information about the user.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
status (:obj:`str`): The member's status in the chat,
|
2021-10-19 18:28:19 +02:00
|
|
|
always :tg-const:`telegram.ChatMember.LEFT`.
|
2021-07-01 17:45:19 +02:00
|
|
|
user (:class:`telegram.User`): Information about the user.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__slots__ = ()
|
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
user: User,
|
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
):
|
|
|
|
super().__init__(status=ChatMember.LEFT, user=user, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ChatMemberBanned(ChatMember):
|
|
|
|
"""
|
|
|
|
Represents a chat member that was banned in the chat and
|
|
|
|
can't return to the chat or view chat messages.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
Args:
|
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2021-08-29 18:17:06 +02:00
|
|
|
until_date (:class:`datetime.datetime`): Date when restrictions
|
2021-07-01 17:45:19 +02:00
|
|
|
will be lifted for this user.
|
|
|
|
|
2023-05-07 15:31:23 +02:00
|
|
|
.. versionchanged:: 20.3
|
2023-04-18 16:16:23 +02:00
|
|
|
|datetime_localization|
|
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
Attributes:
|
|
|
|
status (:obj:`str`): The member's status in the chat,
|
2022-04-30 22:18:11 +02:00
|
|
|
always :tg-const:`telegram.ChatMember.BANNED`.
|
2021-07-01 17:45:19 +02:00
|
|
|
user (:class:`telegram.User`): Information about the user.
|
2021-08-29 18:17:06 +02:00
|
|
|
until_date (:class:`datetime.datetime`): Date when restrictions
|
2021-07-01 17:45:19 +02:00
|
|
|
will be lifted for this user.
|
|
|
|
|
2023-05-07 15:31:23 +02:00
|
|
|
.. versionchanged:: 20.3
|
2023-04-18 16:16:23 +02:00
|
|
|
|datetime_localization|
|
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
"""
|
|
|
|
|
2021-08-29 18:17:06 +02:00
|
|
|
__slots__ = ("until_date",)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
user: User,
|
|
|
|
until_date: datetime.datetime,
|
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
):
|
|
|
|
super().__init__(status=ChatMember.BANNED, user=user, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-02-02 18:55:07 +01:00
|
|
|
self.until_date: datetime.datetime = until_date
|