2021-07-01 17:45:19 +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
|
2021-07-01 17:45:19 +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/].
|
2021-10-08 08:17:00 +02:00
|
|
|
# pylint: disable=redefined-builtin
|
2021-07-01 17:45:19 +02:00
|
|
|
"""This module contains objects representing Telegram bot command scopes."""
|
2024-10-24 20:48:49 +02:00
|
|
|
from typing import TYPE_CHECKING, Final, Optional, Union
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram import constants
|
|
|
|
from telegram._telegramobject import TelegramObject
|
2024-01-17 21:32:37 +01:00
|
|
|
from telegram._utils import enum
|
2021-10-10 15:10:21 +02:00
|
|
|
from telegram._utils.types import JSONDict
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from telegram import Bot
|
|
|
|
|
|
|
|
|
|
|
|
class BotCommandScope(TelegramObject):
|
|
|
|
"""Base class for objects that represent the scope to which bot commands are applied.
|
|
|
|
Currently, the following 7 scopes are supported:
|
|
|
|
|
|
|
|
* :class:`telegram.BotCommandScopeDefault`
|
|
|
|
* :class:`telegram.BotCommandScopeAllPrivateChats`
|
|
|
|
* :class:`telegram.BotCommandScopeAllGroupChats`
|
|
|
|
* :class:`telegram.BotCommandScopeAllChatAdministrators`
|
|
|
|
* :class:`telegram.BotCommandScopeChat`
|
|
|
|
* :class:`telegram.BotCommandScopeChatAdministrators`
|
|
|
|
* :class:`telegram.BotCommandScopeChatMember`
|
|
|
|
|
|
|
|
Objects of this class are comparable in terms of equality. Two objects of this class are
|
|
|
|
considered equal, if their :attr:`type` is equal. For subclasses with additional attributes,
|
|
|
|
the notion of equality is overridden.
|
|
|
|
|
|
|
|
Note:
|
|
|
|
Please see the `official docs`_ on how Telegram determines which commands to display.
|
|
|
|
|
|
|
|
.. _`official docs`: https://core.telegram.org/bots/api#determining-list-of-commands
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
Args:
|
|
|
|
type (:obj:`str`): Scope type.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
type (:obj:`str`): Scope type.
|
|
|
|
"""
|
|
|
|
|
2021-08-19 22:01:10 +02:00
|
|
|
__slots__ = ("type",)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2023-06-29 18:17:47 +02:00
|
|
|
DEFAULT: Final[str] = constants.BotCommandScopeType.DEFAULT
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.BotCommandScopeType.DEFAULT`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
ALL_PRIVATE_CHATS: Final[str] = constants.BotCommandScopeType.ALL_PRIVATE_CHATS
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.BotCommandScopeType.ALL_PRIVATE_CHATS`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
ALL_GROUP_CHATS: Final[str] = constants.BotCommandScopeType.ALL_GROUP_CHATS
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.BotCommandScopeType.ALL_GROUP_CHATS`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
ALL_CHAT_ADMINISTRATORS: Final[str] = constants.BotCommandScopeType.ALL_CHAT_ADMINISTRATORS
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.BotCommandScopeType.ALL_CHAT_ADMINISTRATORS`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
CHAT: Final[str] = constants.BotCommandScopeType.CHAT
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.BotCommandScopeType.CHAT`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
CHAT_ADMINISTRATORS: Final[str] = constants.BotCommandScopeType.CHAT_ADMINISTRATORS
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.BotCommandScopeType.CHAT_ADMINISTRATORS`"""
|
2023-06-29 18:17:47 +02:00
|
|
|
CHAT_MEMBER: Final[str] = constants.BotCommandScopeType.CHAT_MEMBER
|
2021-10-19 18:28:19 +02:00
|
|
|
""":const:`telegram.constants.BotCommandScopeType.CHAT_MEMBER`"""
|
2021-07-01 17:45:19 +02:00
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(self, type: str, *, api_kwargs: Optional[JSONDict] = None):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(api_kwargs=api_kwargs)
|
2024-01-17 21:32:37 +01:00
|
|
|
self.type: str = enum.get_member(constants.BotCommandScopeType, type, type)
|
2021-07-01 17:45:19 +02:00
|
|
|
self._id_attrs = (self.type,)
|
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
@classmethod
|
2024-07-01 19:59:54 +02:00
|
|
|
def de_json(
|
|
|
|
cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
|
|
|
|
) -> Optional["BotCommandScope"]:
|
2021-07-01 17:45:19 +02:00
|
|
|
"""Converts JSON data to the appropriate :class:`BotCommandScope` object, i.e. takes
|
|
|
|
care of selecting the correct subclass.
|
|
|
|
|
|
|
|
Args:
|
2024-10-24 20:48:49 +02:00
|
|
|
data (dict[:obj:`str`, ...]): The JSON data.
|
2024-07-01 19:59:54 +02:00
|
|
|
bot (:class:`telegram.Bot`, optional): The bot associated with this object. Defaults to
|
|
|
|
:obj:`None`, in which case shortcut methods will not be available.
|
|
|
|
|
2024-07-12 17:40:42 +02:00
|
|
|
.. versionchanged:: 21.4
|
2024-07-01 19:59:54 +02:00
|
|
|
:paramref:`bot` is now optional and defaults to :obj:`None`
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
The Telegram object.
|
|
|
|
|
|
|
|
"""
|
|
|
|
data = cls._parse_data(data)
|
|
|
|
|
|
|
|
if not data:
|
|
|
|
return None
|
|
|
|
|
2024-10-24 20:48:49 +02:00
|
|
|
_class_mapping: dict[str, type[BotCommandScope]] = {
|
2021-07-01 17:45:19 +02:00
|
|
|
cls.DEFAULT: BotCommandScopeDefault,
|
|
|
|
cls.ALL_PRIVATE_CHATS: BotCommandScopeAllPrivateChats,
|
|
|
|
cls.ALL_GROUP_CHATS: BotCommandScopeAllGroupChats,
|
|
|
|
cls.ALL_CHAT_ADMINISTRATORS: BotCommandScopeAllChatAdministrators,
|
|
|
|
cls.CHAT: BotCommandScopeChat,
|
|
|
|
cls.CHAT_ADMINISTRATORS: BotCommandScopeChatAdministrators,
|
|
|
|
cls.CHAT_MEMBER: BotCommandScopeChatMember,
|
|
|
|
}
|
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
if cls is BotCommandScope and data.get("type") in _class_mapping:
|
|
|
|
return _class_mapping[data.pop("type")].de_json(data=data, bot=bot)
|
|
|
|
return super().de_json(data=data, bot=bot)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BotCommandScopeDefault(BotCommandScope):
|
|
|
|
"""Represents the default scope of bot commands. Default commands are used if no commands with
|
|
|
|
a `narrower scope`_ are specified for the user.
|
|
|
|
|
|
|
|
.. _`narrower scope`: https://core.telegram.org/bots/api#determining-list-of-commands
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.DEFAULT`.
|
2021-07-01 17:45:19 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
__slots__ = ()
|
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(type=BotCommandScope.DEFAULT, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BotCommandScopeAllPrivateChats(BotCommandScope):
|
|
|
|
"""Represents the scope of bot commands, covering all private chats.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.ALL_PRIVATE_CHATS`.
|
2021-07-01 17:45:19 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
__slots__ = ()
|
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(type=BotCommandScope.ALL_PRIVATE_CHATS, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BotCommandScopeAllGroupChats(BotCommandScope):
|
|
|
|
"""Represents the scope of bot commands, covering all group and supergroup chats.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.ALL_GROUP_CHATS`.
|
2021-07-01 17:45:19 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
__slots__ = ()
|
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(type=BotCommandScope.ALL_GROUP_CHATS, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BotCommandScopeAllChatAdministrators(BotCommandScope):
|
|
|
|
"""Represents the scope of bot commands, covering all group and supergroup chat administrators.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.ALL_CHAT_ADMINISTRATORS`.
|
2021-07-01 17:45:19 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
__slots__ = ()
|
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(type=BotCommandScope.ALL_CHAT_ADMINISTRATORS, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BotCommandScopeChat(BotCommandScope):
|
|
|
|
"""Represents the scope of bot commands, covering a specific chat.
|
|
|
|
|
|
|
|
Objects of this class are comparable in terms of equality. Two objects of this class are
|
|
|
|
considered equal, if their :attr:`type` and :attr:`chat_id` are equal.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
Args:
|
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
|
|
|
chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
|
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.CHAT`.
|
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
|
|
|
chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
|
2021-07-01 17:45:19 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
__slots__ = ("chat_id",)
|
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(self, chat_id: Union[str, int], *, api_kwargs: Optional[JSONDict] = None):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(type=BotCommandScope.CHAT, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-02-02 18:55:07 +01:00
|
|
|
self.chat_id: Union[str, int] = (
|
2022-12-15 15:00:36 +01:00
|
|
|
chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id)
|
|
|
|
)
|
|
|
|
self._id_attrs = (self.type, self.chat_id)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BotCommandScopeChatAdministrators(BotCommandScope):
|
|
|
|
"""Represents the scope of bot commands, covering all administrators of a specific group or
|
|
|
|
supergroup chat.
|
|
|
|
|
|
|
|
Objects of this class are comparable in terms of equality. Two objects of this class are
|
|
|
|
considered equal, if their :attr:`type` and :attr:`chat_id` are equal.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
Args:
|
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
|
|
|
chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
|
2021-07-01 17:45:19 +02:00
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.CHAT_ADMINISTRATORS`.
|
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
|
|
|
chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
|
2021-07-01 17:45:19 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
__slots__ = ("chat_id",)
|
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(self, chat_id: Union[str, int], *, api_kwargs: Optional[JSONDict] = None):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(type=BotCommandScope.CHAT_ADMINISTRATORS, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-02-02 18:55:07 +01:00
|
|
|
self.chat_id: Union[str, int] = (
|
2022-12-15 15:00:36 +01:00
|
|
|
chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id)
|
|
|
|
)
|
|
|
|
self._id_attrs = (self.type, self.chat_id)
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BotCommandScopeChatMember(BotCommandScope):
|
|
|
|
"""Represents the scope of bot commands, covering a specific member of a group or supergroup
|
|
|
|
chat.
|
|
|
|
|
|
|
|
Objects of this class are comparable in terms of equality. Two objects of this class are
|
|
|
|
considered equal, if their :attr:`type`, :attr:`chat_id` and :attr:`user_id` are equal.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
|
|
|
Args:
|
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
|
|
|
chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
|
2021-07-01 17:45:19 +02:00
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
|
|
|
|
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.CHAT_MEMBER`.
|
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
|
|
|
chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
|
2021-07-01 17:45:19 +02:00
|
|
|
user_id (:obj:`int`): Unique identifier of the target user.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__slots__ = ("chat_id", "user_id")
|
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(
|
|
|
|
self, chat_id: Union[str, int], user_id: int, *, api_kwargs: Optional[JSONDict] = None
|
|
|
|
):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(type=BotCommandScope.CHAT_MEMBER, api_kwargs=api_kwargs)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-02-02 18:55:07 +01:00
|
|
|
self.chat_id: Union[str, int] = (
|
2022-12-15 15:00:36 +01:00
|
|
|
chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id)
|
|
|
|
)
|
2023-02-02 18:55:07 +01:00
|
|
|
self.user_id: int = user_id
|
2022-12-15 15:00:36 +01:00
|
|
|
self._id_attrs = (self.type, self.chat_id, self.user_id)
|