mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Type hint all methods return values
This commit is contained in:
parent
bf0b947253
commit
a0355a5cc4
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
class DeleteChatPhoto(BaseClient):
|
class DeleteChatPhoto(BaseClient):
|
||||||
def delete_chat_photo(self,
|
def delete_chat_photo(self,
|
||||||
chat_id: Union[int, str]):
|
chat_id: Union[int, str]) -> bool:
|
||||||
"""Use this method to delete a chat photo.
|
"""Use this method to delete a chat photo.
|
||||||
Photos can't be changed for private chats.
|
Photos can't be changed for private chats.
|
||||||
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
class ExportChatInviteLink(BaseClient):
|
class ExportChatInviteLink(BaseClient):
|
||||||
def export_chat_invite_link(self,
|
def export_chat_invite_link(self,
|
||||||
chat_id: Union[int, str]):
|
chat_id: Union[int, str]) -> str:
|
||||||
"""Use this method to generate a new invite link for a chat; any previously generated link is revoked.
|
"""Use this method to generate a new invite link for a chat; any previously generated link is revoked.
|
||||||
|
|
||||||
You must be an administrator in the chat for this to work and have the appropriate admin rights.
|
You must be an administrator in the chat for this to work and have the appropriate admin rights.
|
||||||
|
@ -25,7 +25,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
class GetChat(BaseClient):
|
class GetChat(BaseClient):
|
||||||
def get_chat(self,
|
def get_chat(self,
|
||||||
chat_id: Union[int, str]):
|
chat_id: Union[int, str]) -> "pyrogram.Chat":
|
||||||
"""Use this method to get up to date information about the chat (current name of the user for
|
"""Use this method to get up to date information about the chat (current name of the user for
|
||||||
one-on-one conversations, current username of a user, group or channel, etc.)
|
one-on-one conversations, current username of a user, group or channel, etc.)
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ from ...ext import BaseClient
|
|||||||
class GetChatMember(BaseClient):
|
class GetChatMember(BaseClient):
|
||||||
def get_chat_member(self,
|
def get_chat_member(self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
user_id: Union[int, str]):
|
user_id: Union[int, str]) -> "pyrogram.ChatMember":
|
||||||
"""Use this method to get information about one member of a chat.
|
"""Use this method to get information about one member of a chat.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -67,13 +67,6 @@ class GetChatMember(BaseClient):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return pyrogram.ChatMembers._parse(
|
return pyrogram.ChatMember._parse(self, r.participant, r.users[0])
|
||||||
self,
|
|
||||||
types.channels.ChannelParticipants(
|
|
||||||
count=1,
|
|
||||||
participants=[r.participant],
|
|
||||||
users=r.users
|
|
||||||
)
|
|
||||||
).chat_members[0]
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("The chat_id \"{}\" belongs to a user".format(chat_id))
|
raise ValueError("The chat_id \"{}\" belongs to a user".format(chat_id))
|
||||||
|
@ -38,7 +38,7 @@ class GetChatMembers(BaseClient):
|
|||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
limit: int = 200,
|
limit: int = 200,
|
||||||
query: str = "",
|
query: str = "",
|
||||||
filter: str = Filters.ALL):
|
filter: str = Filters.ALL) -> "pyrogram.ChatMembers":
|
||||||
"""Use this method to get the members list of a chat.
|
"""Use this method to get the members list of a chat.
|
||||||
|
|
||||||
A chat can be either a basic group, a supergroup or a channel.
|
A chat can be either a basic group, a supergroup or a channel.
|
||||||
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
class GetChatMembersCount(BaseClient):
|
class GetChatMembersCount(BaseClient):
|
||||||
def get_chat_members_count(self,
|
def get_chat_members_count(self,
|
||||||
chat_id: Union[int, str]):
|
chat_id: Union[int, str]) -> int:
|
||||||
"""Use this method to get the number of members in a chat.
|
"""Use this method to get the number of members in a chat.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -25,7 +25,7 @@ class GetDialogs(BaseClient):
|
|||||||
def get_dialogs(self,
|
def get_dialogs(self,
|
||||||
offset_dialog: "pyrogram.Dialog" = None,
|
offset_dialog: "pyrogram.Dialog" = None,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
pinned_only: bool = False):
|
pinned_only: bool = False) -> "pyrogram.Dialogs":
|
||||||
"""Use this method to get the user's dialogs
|
"""Use this method to get the user's dialogs
|
||||||
|
|
||||||
You can get up to 100 dialogs at once.
|
You can get up to 100 dialogs at once.
|
||||||
|
@ -27,7 +27,7 @@ class KickChatMember(BaseClient):
|
|||||||
def kick_chat_member(self,
|
def kick_chat_member(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) -> "pyrogram.Message":
|
||||||
"""Use this method to kick a user from a group, a supergroup or a channel.
|
"""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 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
|
||||||
|
@ -26,7 +26,7 @@ class PinChatMessage(BaseClient):
|
|||||||
def pin_chat_message(self,
|
def pin_chat_message(self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
message_id: int,
|
message_id: int,
|
||||||
disable_notification: bool = None):
|
disable_notification: bool = None) -> bool:
|
||||||
"""Use this method to pin a message in a supergroup or a channel.
|
"""Use this method to pin a message in a supergroup or a channel.
|
||||||
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in
|
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in
|
||||||
the supergroup or "can_edit_messages" admin right in the channel.
|
the supergroup or "can_edit_messages" admin right in the channel.
|
||||||
|
@ -33,7 +33,7 @@ class PromoteChatMember(BaseClient):
|
|||||||
can_invite_users: bool = True,
|
can_invite_users: bool = True,
|
||||||
can_restrict_members: bool = True,
|
can_restrict_members: bool = True,
|
||||||
can_pin_messages: bool = False,
|
can_pin_messages: bool = False,
|
||||||
can_promote_members: bool = False):
|
can_promote_members: bool = False) -> bool:
|
||||||
"""Use this method to promote or demote a user in a supergroup or a channel.
|
"""Use this method to promote or demote a user in a supergroup or a channel.
|
||||||
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
Pass False for all boolean parameters to demote a user.
|
Pass False for all boolean parameters to demote a user.
|
||||||
|
@ -30,7 +30,7 @@ class RestrictChatMember(BaseClient):
|
|||||||
can_send_messages: bool = False,
|
can_send_messages: bool = False,
|
||||||
can_send_media_messages: bool = False,
|
can_send_media_messages: bool = False,
|
||||||
can_send_other_messages: bool = False,
|
can_send_other_messages: bool = False,
|
||||||
can_add_web_page_previews: bool = False):
|
can_add_web_page_previews: bool = False) -> bool:
|
||||||
"""Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for
|
"""Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for
|
||||||
this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift
|
this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift
|
||||||
restrictions from a user.
|
restrictions from a user.
|
||||||
|
@ -25,7 +25,7 @@ from ...ext import BaseClient
|
|||||||
class SetChatDescription(BaseClient):
|
class SetChatDescription(BaseClient):
|
||||||
def set_chat_description(self,
|
def set_chat_description(self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
description: str):
|
description: str) -> bool:
|
||||||
"""Use this method to change the description of a supergroup or a channel.
|
"""Use this method to change the description of a supergroup or a channel.
|
||||||
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ from ...ext import BaseClient
|
|||||||
class SetChatPhoto(BaseClient):
|
class SetChatPhoto(BaseClient):
|
||||||
def set_chat_photo(self,
|
def set_chat_photo(self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
photo: str):
|
photo: str) -> bool:
|
||||||
"""Use this method to set a new profile photo for the chat.
|
"""Use this method to set a new profile photo for the chat.
|
||||||
Photos can't be changed for private chats.
|
Photos can't be changed for private chats.
|
||||||
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
|
@ -25,7 +25,7 @@ from ...ext import BaseClient
|
|||||||
class SetChatTitle(BaseClient):
|
class SetChatTitle(BaseClient):
|
||||||
def set_chat_title(self,
|
def set_chat_title(self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
title: str):
|
title: str) -> bool:
|
||||||
"""Use this method to change the title of a chat.
|
"""Use this method to change the title of a chat.
|
||||||
Titles can't be changed for private chats.
|
Titles can't be changed for private chats.
|
||||||
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
|
@ -25,7 +25,7 @@ from ...ext import BaseClient
|
|||||||
class UnbanChatMember(BaseClient):
|
class UnbanChatMember(BaseClient):
|
||||||
def unban_chat_member(self,
|
def unban_chat_member(self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
user_id: Union[int, str]):
|
user_id: Union[int, str]) -> bool:
|
||||||
"""Use this method to unban a previously kicked user in a supergroup or channel.
|
"""Use this method to unban a previously kicked 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.
|
||||||
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
class UnpinChatMessage(BaseClient):
|
class UnpinChatMessage(BaseClient):
|
||||||
def unpin_chat_message(self,
|
def unpin_chat_message(self,
|
||||||
chat_id: Union[int, str]):
|
chat_id: Union[int, str]) -> bool:
|
||||||
"""Use this method to unpin a message in a supergroup or a channel.
|
"""Use this method to unpin a message in a supergroup or a channel.
|
||||||
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin
|
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin
|
||||||
right in the supergroup or "can_edit_messages" admin right in the channel.
|
right in the supergroup or "can_edit_messages" admin right in the channel.
|
||||||
|
@ -16,15 +16,18 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.client.filters.filter import Filter
|
from pyrogram.client.filters.filter import Filter
|
||||||
|
from pyrogram.client.handlers.handler import Handler
|
||||||
from ...ext import BaseClient
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class OnCallbackQuery(BaseClient):
|
class OnCallbackQuery(BaseClient):
|
||||||
def on_callback_query(self=None,
|
def on_callback_query(self=None,
|
||||||
filters=None,
|
filters=None,
|
||||||
group: int = 0):
|
group: int = 0) -> callable:
|
||||||
"""Use this decorator to automatically register a function for handling
|
"""Use this decorator to automatically register a function for handling
|
||||||
callback queries. This does the same thing as :meth:`add_handler` using the
|
callback queries. This does the same thing as :meth:`add_handler` using the
|
||||||
:class:`CallbackQueryHandler`.
|
:class:`CallbackQueryHandler`.
|
||||||
@ -45,7 +48,7 @@ class OnCallbackQuery(BaseClient):
|
|||||||
The group identifier, defaults to 0.
|
The group identifier, defaults to 0.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func: callable) -> Tuple[Handler, int]:
|
||||||
if isinstance(func, tuple):
|
if isinstance(func, tuple):
|
||||||
func = func[0].callback
|
func = func[0].callback
|
||||||
|
|
||||||
|
@ -16,15 +16,18 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.client.filters.filter import Filter
|
from pyrogram.client.filters.filter import Filter
|
||||||
|
from pyrogram.client.handlers.handler import Handler
|
||||||
from ...ext import BaseClient
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class OnDeletedMessages(BaseClient):
|
class OnDeletedMessages(BaseClient):
|
||||||
def on_deleted_messages(self=None,
|
def on_deleted_messages(self=None,
|
||||||
filters=None,
|
filters=None,
|
||||||
group: int = 0):
|
group: int = 0) -> callable:
|
||||||
"""Use this decorator to automatically register a function for handling
|
"""Use this decorator to automatically register a function for handling
|
||||||
deleted messages. This does the same thing as :meth:`add_handler` using the
|
deleted messages. This does the same thing as :meth:`add_handler` using the
|
||||||
:class:`DeletedMessagesHandler`.
|
:class:`DeletedMessagesHandler`.
|
||||||
@ -45,7 +48,7 @@ class OnDeletedMessages(BaseClient):
|
|||||||
The group identifier, defaults to 0.
|
The group identifier, defaults to 0.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func: callable) -> Tuple[Handler, int]:
|
||||||
if isinstance(func, tuple):
|
if isinstance(func, tuple):
|
||||||
func = func[0].callback
|
func = func[0].callback
|
||||||
|
|
||||||
|
@ -17,17 +17,18 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
|
from pyrogram.client.handlers.handler import Handler
|
||||||
from ...ext import BaseClient
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class OnDisconnect(BaseClient):
|
class OnDisconnect(BaseClient):
|
||||||
def on_disconnect(self=None):
|
def on_disconnect(self=None) -> callable:
|
||||||
"""Use this decorator to automatically register a function for handling
|
"""Use this decorator to automatically register a function for handling
|
||||||
disconnections. This does the same thing as :meth:`add_handler` using the
|
disconnections. This does the same thing as :meth:`add_handler` using the
|
||||||
:class:`DisconnectHandler`.
|
:class:`DisconnectHandler`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func: callable) -> Handler:
|
||||||
handler = pyrogram.DisconnectHandler(func)
|
handler = pyrogram.DisconnectHandler(func)
|
||||||
|
|
||||||
if self is not None:
|
if self is not None:
|
||||||
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
class OnMessage(BaseClient):
|
class OnMessage(BaseClient):
|
||||||
def on_message(self=None,
|
def on_message(self=None,
|
||||||
filters=None,
|
filters=None,
|
||||||
group: int = 0):
|
group: int = 0) -> callable:
|
||||||
"""Use this decorator to automatically register a function for handling
|
"""Use this decorator to automatically register a function for handling
|
||||||
messages. This does the same thing as :meth:`add_handler` using the
|
messages. This does the same thing as :meth:`add_handler` using the
|
||||||
:class:`MessageHandler`.
|
:class:`MessageHandler`.
|
||||||
|
@ -16,13 +16,16 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
|
from pyrogram.client.handlers.handler import Handler
|
||||||
from ...ext import BaseClient
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class OnRawUpdate(BaseClient):
|
class OnRawUpdate(BaseClient):
|
||||||
def on_raw_update(self=None,
|
def on_raw_update(self=None,
|
||||||
group: int = 0):
|
group: int = 0) -> callable:
|
||||||
"""Use this decorator to automatically register a function for handling
|
"""Use this decorator to automatically register a function for handling
|
||||||
raw updates. This does the same thing as :meth:`add_handler` using the
|
raw updates. This does the same thing as :meth:`add_handler` using the
|
||||||
:class:`RawUpdateHandler`.
|
:class:`RawUpdateHandler`.
|
||||||
@ -39,7 +42,7 @@ class OnRawUpdate(BaseClient):
|
|||||||
The group identifier, defaults to 0.
|
The group identifier, defaults to 0.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func: callable) -> Tuple[Handler, int]:
|
||||||
if isinstance(func, tuple):
|
if isinstance(func, tuple):
|
||||||
func = func[0].callback
|
func = func[0].callback
|
||||||
|
|
||||||
|
@ -16,15 +16,18 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.client.filters.filter import Filter
|
from pyrogram.client.filters.filter import Filter
|
||||||
|
from pyrogram.client.handlers.handler import Handler
|
||||||
from ...ext import BaseClient
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class OnUserStatus(BaseClient):
|
class OnUserStatus(BaseClient):
|
||||||
def on_user_status(self=None,
|
def on_user_status(self=None,
|
||||||
filters=None,
|
filters=None,
|
||||||
group: int = 0):
|
group: int = 0) -> callable:
|
||||||
"""Use this decorator to automatically register a function for handling
|
"""Use this decorator to automatically register a function for handling
|
||||||
user status updates. This does the same thing as :meth:`add_handler` using the
|
user status updates. This does the same thing as :meth:`add_handler` using the
|
||||||
:class:`UserStatusHandler`.
|
:class:`UserStatusHandler`.
|
||||||
@ -44,7 +47,7 @@ class OnUserStatus(BaseClient):
|
|||||||
The group identifier, defaults to 0.
|
The group identifier, defaults to 0.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func: callable) -> Tuple[Handler, int]:
|
||||||
if isinstance(func, tuple):
|
if isinstance(func, tuple):
|
||||||
func = func[0].callback
|
func = func[0].callback
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class DeleteMessages(BaseClient):
|
|||||||
def delete_messages(self,
|
def delete_messages(self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
message_ids: Iterable[int],
|
message_ids: Iterable[int],
|
||||||
revoke: bool = True):
|
revoke: bool = True) -> bool:
|
||||||
"""Use this method to delete messages, including service messages, with the following limitations:
|
"""Use this method to delete messages, including service messages, with the following limitations:
|
||||||
|
|
||||||
- A message can only be deleted if it was sent less than 48 hours ago.
|
- A message can only be deleted if it was sent less than 48 hours ago.
|
||||||
|
@ -29,7 +29,7 @@ class EditMessageCaption(BaseClient):
|
|||||||
message_id: int,
|
message_id: int,
|
||||||
caption: str,
|
caption: str,
|
||||||
parse_mode: str = "",
|
parse_mode: str = "",
|
||||||
reply_markup: "pyrogram.InlineKeyboardMarkup" = None):
|
reply_markup: "pyrogram.InlineKeyboardMarkup" = None) -> "pyrogram.Message":
|
||||||
"""Use this method to edit captions of messages.
|
"""Use this method to edit captions of messages.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -38,7 +38,7 @@ class EditMessageMedia(BaseClient):
|
|||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
message_id: int,
|
message_id: int,
|
||||||
media: InputMedia,
|
media: InputMedia,
|
||||||
reply_markup: "pyrogram.InlineKeyboardMarkup" = None):
|
reply_markup: "pyrogram.InlineKeyboardMarkup" = None) -> "pyrogram.Message":
|
||||||
"""Use this method to edit audio, document, photo, or video messages.
|
"""Use this method to edit audio, document, photo, or video messages.
|
||||||
|
|
||||||
If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise,
|
If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise,
|
||||||
|
@ -27,7 +27,7 @@ class EditMessageReplyMarkup(BaseClient):
|
|||||||
def edit_message_reply_markup(self,
|
def edit_message_reply_markup(self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
message_id: int,
|
message_id: int,
|
||||||
reply_markup: "pyrogram.InlineKeyboardMarkup" = None):
|
reply_markup: "pyrogram.InlineKeyboardMarkup" = None) -> "pyrogram.Message":
|
||||||
"""Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
|
"""Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -30,7 +30,7 @@ class EditMessageText(BaseClient):
|
|||||||
text: str,
|
text: str,
|
||||||
parse_mode: str = "",
|
parse_mode: str = "",
|
||||||
disable_web_page_preview: bool = None,
|
disable_web_page_preview: bool = None,
|
||||||
reply_markup: "pyrogram.InlineKeyboardMarkup" = None):
|
reply_markup: "pyrogram.InlineKeyboardMarkup" = None) -> "pyrogram.Message":
|
||||||
"""Use this method to edit text messages.
|
"""Use this method to edit text messages.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -28,7 +28,7 @@ class ForwardMessages(BaseClient):
|
|||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
from_chat_id: Union[int, str],
|
from_chat_id: Union[int, str],
|
||||||
message_ids: Iterable[int],
|
message_ids: Iterable[int],
|
||||||
disable_notification: bool = None):
|
disable_notification: bool = None) -> "pyrogram.Messages":
|
||||||
"""Use this method to forward messages of any kind.
|
"""Use this method to forward messages of any kind.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -51,7 +51,7 @@ class ForwardMessages(BaseClient):
|
|||||||
Users will receive a notification with no sound.
|
Users will receive a notification with no sound.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success and in case *message_ids* was a list, the returned value will be a list of the forwarded
|
On success and in case *message_ids* was an iterable, the returned value will be a list of the forwarded
|
||||||
:obj:`Messages <pyrogram.Message>` even if a list contains just one element, otherwise if
|
:obj:`Messages <pyrogram.Message>` even if a list contains just one element, otherwise if
|
||||||
*message_ids* was an integer, the single forwarded :obj:`Message <pyrogram.Message>`
|
*message_ids* was an integer, the single forwarded :obj:`Message <pyrogram.Message>`
|
||||||
is returned.
|
is returned.
|
||||||
@ -86,4 +86,8 @@ class ForwardMessages(BaseClient):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return messages if is_iterable else messages[0]
|
return pyrogram.Messages(
|
||||||
|
client=self,
|
||||||
|
total_count=len(messages),
|
||||||
|
messages=messages
|
||||||
|
) if is_iterable else messages[0]
|
||||||
|
@ -28,7 +28,7 @@ class GetMessages(BaseClient):
|
|||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
message_ids: Union[int, Iterable[int]] = None,
|
message_ids: Union[int, Iterable[int]] = None,
|
||||||
reply_to_message_ids: Union[int, Iterable[int]] = None,
|
reply_to_message_ids: Union[int, Iterable[int]] = None,
|
||||||
replies: int = 1):
|
replies: int = 1) -> "pyrogram.Messages":
|
||||||
"""Use this method to get one or more messages that belong to a specific chat.
|
"""Use this method to get one or more messages that belong to a specific chat.
|
||||||
You can retrieve up to 200 messages at once.
|
You can retrieve up to 200 messages at once.
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class SendAnimation(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()):
|
progress_args: tuple = ()) -> "pyrogram.Message":
|
||||||
"""Use this method to send animation files (animation or H.264/MPEG-4 AVC video without sound).
|
"""Use this method to send animation files (animation or H.264/MPEG-4 AVC video without sound).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -45,7 +45,7 @@ class SendAudio(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()):
|
progress_args: tuple = ()) -> "pyrogram.Message":
|
||||||
"""Use this method to send audio files.
|
"""Use this method to send audio files.
|
||||||
|
|
||||||
For sending voice messages, use the :obj:`send_voice()` method instead.
|
For sending voice messages, use the :obj:`send_voice()` method instead.
|
||||||
|
@ -35,7 +35,7 @@ class SendContact(BaseClient):
|
|||||||
reply_markup: Union["pyrogram.InlineKeyboardMarkup",
|
reply_markup: Union["pyrogram.InlineKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardMarkup",
|
"pyrogram.ReplyKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None):
|
"pyrogram.ForceReply"] = None) -> "pyrogram.Message":
|
||||||
"""Use this method to send phone contacts.
|
"""Use this method to send phone contacts.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -42,7 +42,7 @@ class SendDocument(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()):
|
progress_args: tuple = ()) -> "pyrogram.Message":
|
||||||
"""Use this method to send general files.
|
"""Use this method to send general files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -33,7 +33,7 @@ class SendLocation(BaseClient):
|
|||||||
reply_markup: Union["pyrogram.InlineKeyboardMarkup",
|
reply_markup: Union["pyrogram.InlineKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardMarkup",
|
"pyrogram.ReplyKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None):
|
"pyrogram.ForceReply"] = None) -> "pyrogram.Message":
|
||||||
"""Use this method to send points on the map.
|
"""Use this method to send points on the map.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -34,7 +34,7 @@ class SendMessage(BaseClient):
|
|||||||
reply_markup: Union["pyrogram.InlineKeyboardMarkup",
|
reply_markup: Union["pyrogram.InlineKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardMarkup",
|
"pyrogram.ReplyKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None):
|
"pyrogram.ForceReply"] = None) -> "pyrogram.Message":
|
||||||
"""Use this method to send text messages.
|
"""Use this method to send text messages.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -41,7 +41,7 @@ class SendPhoto(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()):
|
progress_args: tuple = ()) -> "pyrogram.Message":
|
||||||
"""Use this method to send photos.
|
"""Use this method to send photos.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -38,7 +38,7 @@ class SendSticker(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()):
|
progress_args: tuple = ()) -> "pyrogram.Message":
|
||||||
"""Use this method to send .webp stickers.
|
"""Use this method to send .webp stickers.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -37,7 +37,7 @@ class SendVenue(BaseClient):
|
|||||||
reply_markup: Union["pyrogram.InlineKeyboardMarkup",
|
reply_markup: Union["pyrogram.InlineKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardMarkup",
|
"pyrogram.ReplyKeyboardMarkup",
|
||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None):
|
"pyrogram.ForceReply"] = None) -> "pyrogram.Message":
|
||||||
"""Use this method to send information about a venue.
|
"""Use this method to send information about a venue.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -46,7 +46,7 @@ class SendVideo(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()):
|
progress_args: tuple = ()) -> "pyrogram.Message":
|
||||||
"""Use this method to send video files.
|
"""Use this method to send video files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -42,7 +42,7 @@ class SendVideoNote(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()):
|
progress_args: tuple = ()) -> "pyrogram.Message":
|
||||||
"""Use this method to send video messages.
|
"""Use this method to send video messages.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -42,7 +42,7 @@ class SendVoice(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()):
|
progress_args: tuple = ()) -> "pyrogram.Message":
|
||||||
"""Use this method to send audio files.
|
"""Use this method to send audio files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -27,7 +27,7 @@ class ChangeCloudPassword(BaseClient):
|
|||||||
def change_cloud_password(self,
|
def change_cloud_password(self,
|
||||||
current_password: str,
|
current_password: str,
|
||||||
new_password: str,
|
new_password: str,
|
||||||
new_hint: str = ""):
|
new_hint: str = "") -> bool:
|
||||||
"""Use this method to change your Two-Step Verification password (Cloud Password) with a new one.
|
"""Use this method to change your Two-Step Verification password (Cloud Password) with a new one.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -27,7 +27,7 @@ class EnableCloudPassword(BaseClient):
|
|||||||
def enable_cloud_password(self,
|
def enable_cloud_password(self,
|
||||||
password: str,
|
password: str,
|
||||||
hint: str = "",
|
hint: str = "",
|
||||||
email: str = ""):
|
email: str = "") -> bool:
|
||||||
"""Use this method to enable the Two-Step Verification security feature (Cloud Password) on your account.
|
"""Use this method to enable the Two-Step Verification security feature (Cloud Password) on your account.
|
||||||
|
|
||||||
This password will be asked when you log in on a new device in addition to the SMS code.
|
This password will be asked when you log in on a new device in addition to the SMS code.
|
||||||
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
class RemoveCloudPassword(BaseClient):
|
class RemoveCloudPassword(BaseClient):
|
||||||
def remove_cloud_password(self,
|
def remove_cloud_password(self,
|
||||||
password: str):
|
password: str) -> bool:
|
||||||
"""Use this method to turn off the Two-Step Verification security feature (Cloud Password) on your account.
|
"""Use this method to turn off the Two-Step Verification security feature (Cloud Password) on your account.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -26,7 +26,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
class DeleteUserProfilePhotos(BaseClient):
|
class DeleteUserProfilePhotos(BaseClient):
|
||||||
def delete_user_profile_photos(self,
|
def delete_user_profile_photos(self,
|
||||||
id: Union[str, List[str]]):
|
id: Union[str, List[str]]) -> bool:
|
||||||
"""Use this method to delete your own profile photos
|
"""Use this method to delete your own profile photos
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -22,7 +22,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class GetMe(BaseClient):
|
class GetMe(BaseClient):
|
||||||
def get_me(self):
|
def get_me(self) -> pyrogram.User:
|
||||||
"""A simple method for testing your authorization. Requires no parameters.
|
"""A simple method for testing your authorization. Requires no parameters.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -27,7 +27,7 @@ class GetUserProfilePhotos(BaseClient):
|
|||||||
def get_user_profile_photos(self,
|
def get_user_profile_photos(self,
|
||||||
user_id: Union[int, str],
|
user_id: Union[int, str],
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
limit: int = 100):
|
limit: int = 100) -> pyrogram.UserProfilePhotos:
|
||||||
"""Use this method to get a list of profile pictures for a user.
|
"""Use this method to get a list of profile pictures for a user.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from typing import Iterable, Union
|
from typing import Iterable, Union, List
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import functions
|
from pyrogram.api import functions
|
||||||
@ -25,7 +25,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
class GetUsers(BaseClient):
|
class GetUsers(BaseClient):
|
||||||
def get_users(self,
|
def get_users(self,
|
||||||
user_ids: Iterable[Union[int, str]]):
|
user_ids: Iterable[Union[int, str]]) -> Union[pyrogram.User or List[pyrogram.User]]:
|
||||||
"""Use this method to get information about a user.
|
"""Use this method to get information about a user.
|
||||||
You can retrieve up to 200 users at once.
|
You can retrieve up to 200 users at once.
|
||||||
|
|
||||||
@ -36,9 +36,9 @@ class GetUsers(BaseClient):
|
|||||||
Iterators and Generators are also accepted.
|
Iterators and Generators are also accepted.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success and in case *user_ids* was a list, the returned value will be a list of the requested
|
On success and in case *user_ids* was an iterable, the returned value will be a list of the requested
|
||||||
:obj:`Users <User>` even if a list contains just one element, otherwise if
|
:obj:`Users <User>` even if a list contains just one element, otherwise if
|
||||||
*user_ids* was an integer, the single requested :obj:`User` is returned.
|
*user_ids* was an integer or string, the single requested :obj:`User` is returned.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
|
@ -22,7 +22,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
class SetUserProfilePhoto(BaseClient):
|
class SetUserProfilePhoto(BaseClient):
|
||||||
def set_user_profile_photo(self,
|
def set_user_profile_photo(self,
|
||||||
photo: str):
|
photo: str) -> bool:
|
||||||
"""Use this method to set a new profile photo.
|
"""Use this method to set a new profile photo.
|
||||||
|
|
||||||
This method only works for Users.
|
This method only works for Users.
|
||||||
|
@ -29,7 +29,7 @@ class DownloadMedia(BaseClient):
|
|||||||
file_name: str = "",
|
file_name: str = "",
|
||||||
block: bool = True,
|
block: bool = True,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()):
|
progress_args: tuple = ()) -> Union[str, None]:
|
||||||
"""Use this method to download the media from a Message.
|
"""Use this method to download the media from a Message.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -121,6 +121,8 @@ class ChatMember(PyrogramType):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, member, user) -> "ChatMember":
|
def _parse(client, member, user) -> "ChatMember":
|
||||||
|
user = pyrogram.User._parse(client, user)
|
||||||
|
|
||||||
if isinstance(member, (types.ChannelParticipant, types.ChannelParticipantSelf, types.ChatParticipant)):
|
if isinstance(member, (types.ChannelParticipant, types.ChannelParticipantSelf, types.ChatParticipant)):
|
||||||
return ChatMember(user=user, status="member", client=client)
|
return ChatMember(user=user, status="member", client=client)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user