⏭ Improve import speed
- By doing this can import required module on-the-fly
✨ Reformatted files
This commit is contained in:
parent
3c65090c4e
commit
e318562b16
@ -35,14 +35,14 @@ class ContinuePropagation(StopAsyncIteration):
|
||||
pass
|
||||
|
||||
|
||||
from asyncio import get_event_loop
|
||||
import asyncio
|
||||
|
||||
from . import raw, types, filters, handlers, emoji
|
||||
from .client import Client
|
||||
from .sync import idle
|
||||
|
||||
# Save the main thread loop for future references
|
||||
main_event_loop = get_event_loop()
|
||||
main_event_loop = asyncio.get_event_loop()
|
||||
|
||||
CRYPTO_EXECUTOR_SIZE_THRESHOLD = 512
|
||||
|
||||
|
@ -16,19 +16,19 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
import functools
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
from asyncio import get_event_loop
|
||||
from concurrent.futures.thread import ThreadPoolExecutor
|
||||
from configparser import ConfigParser
|
||||
from hashlib import sha256
|
||||
from importlib import import_module
|
||||
from os import path, makedirs, remove as os_remove
|
||||
from pathlib import Path
|
||||
from re import sub as re_sub
|
||||
from typing import Union, List, Optional
|
||||
|
||||
import pyrogram
|
||||
@ -182,32 +182,32 @@ class Client(Methods, Scaffold):
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
session_name: Union[str, Storage],
|
||||
api_id: Union[int, str] = None,
|
||||
api_hash: str = None,
|
||||
app_version: str = None,
|
||||
device_model: str = None,
|
||||
system_version: str = None,
|
||||
lang_code: str = None,
|
||||
ipv6: bool = False,
|
||||
proxy: dict = None,
|
||||
test_mode: bool = False,
|
||||
mode: int = 3,
|
||||
bot_token: str = None,
|
||||
phone_number: str = None,
|
||||
phone_code: str = None,
|
||||
password: str = None,
|
||||
force_sms: bool = False,
|
||||
workers: int = Scaffold.WORKERS,
|
||||
workdir: str = Scaffold.WORKDIR,
|
||||
config_file: str = Scaffold.CONFIG_FILE,
|
||||
plugins: dict = None,
|
||||
parse_mode: str = Scaffold.PARSE_MODES[0],
|
||||
no_updates: bool = None,
|
||||
takeout: bool = None,
|
||||
sleep_threshold: int = Session.SLEEP_THRESHOLD,
|
||||
hide_password: bool = False
|
||||
self,
|
||||
session_name: Union[str, Storage],
|
||||
api_id: Union[int, str] = None,
|
||||
api_hash: str = None,
|
||||
app_version: str = None,
|
||||
device_model: str = None,
|
||||
system_version: str = None,
|
||||
lang_code: str = None,
|
||||
ipv6: bool = False,
|
||||
proxy: dict = None,
|
||||
test_mode: bool = False,
|
||||
mode: int = 3,
|
||||
bot_token: str = None,
|
||||
phone_number: str = None,
|
||||
phone_code: str = None,
|
||||
password: str = None,
|
||||
force_sms: bool = False,
|
||||
workers: int = Scaffold.WORKERS,
|
||||
workdir: str = Scaffold.WORKDIR,
|
||||
config_file: str = Scaffold.CONFIG_FILE,
|
||||
plugins: dict = None,
|
||||
parse_mode: str = Scaffold.PARSE_MODES[0],
|
||||
no_updates: bool = None,
|
||||
takeout: bool = None,
|
||||
sleep_threshold: int = Session.SLEEP_THRESHOLD,
|
||||
hide_password: bool = False
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
@ -242,7 +242,7 @@ class Client(Methods, Scaffold):
|
||||
|
||||
if isinstance(session_name, str):
|
||||
if session_name == ":memory:" or len(session_name) >= MemoryStorage.SESSION_STRING_SIZE:
|
||||
session_name = re_sub(r"[\n\s]+", "", session_name)
|
||||
session_name = re.sub(r"[\n\s]+", "", session_name)
|
||||
self.storage = MemoryStorage(session_name)
|
||||
else:
|
||||
self.storage = FileStorage(session_name, self.workdir)
|
||||
@ -252,7 +252,7 @@ class Client(Methods, Scaffold):
|
||||
raise ValueError("Unknown storage engine")
|
||||
|
||||
self.dispatcher = Dispatcher(self)
|
||||
self.loop = get_event_loop()
|
||||
self.loop = asyncio.get_event_loop()
|
||||
|
||||
def __enter__(self):
|
||||
return self.start()
|
||||
@ -519,14 +519,14 @@ class Client(Methods, Scaffold):
|
||||
)
|
||||
|
||||
if temp_file_path:
|
||||
final_file_path = path.abspath(re_sub("\\\\", "/", path.join(directory, file_name)))
|
||||
makedirs(directory, exist_ok=True)
|
||||
final_file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name)))
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
shutil.move(temp_file_path, final_file_path)
|
||||
except Exception as e:
|
||||
log.error(e, exc_info=True)
|
||||
|
||||
try:
|
||||
os_remove(temp_file_path)
|
||||
os.remove(temp_file_path)
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
@ -819,11 +819,11 @@ class Client(Methods, Scaffold):
|
||||
log.warning(f'[{self.session_name}] No plugin loaded from "{root}"')
|
||||
|
||||
async def get_file(
|
||||
self,
|
||||
file_id: FileId,
|
||||
file_size: int,
|
||||
progress: callable,
|
||||
progress_args: tuple = ()
|
||||
self,
|
||||
file_id: FileId,
|
||||
file_size: int,
|
||||
progress: callable,
|
||||
progress_args: tuple = ()
|
||||
) -> str:
|
||||
dc_id = file_id.dc_id
|
||||
|
||||
@ -1049,7 +1049,7 @@ class Client(Methods, Scaffold):
|
||||
log.error(e, exc_info=True)
|
||||
|
||||
try:
|
||||
os_remove(file_name)
|
||||
os.remove(file_name)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
@ -33,11 +33,11 @@ class RPCError(Exception):
|
||||
MESSAGE = "{x}"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
x: Union[int, str, raw.types.RpcError] = None,
|
||||
rpc_name: str = None,
|
||||
is_unknown: bool = False,
|
||||
is_signed: bool = False
|
||||
self,
|
||||
x: Union[int, str, raw.types.RpcError] = None,
|
||||
rpc_name: str = None,
|
||||
is_unknown: bool = False,
|
||||
is_signed: bool = False
|
||||
):
|
||||
super().__init__("Telegram says: [{}{} {}] - {} {}".format(
|
||||
"-" if is_signed else "",
|
||||
|
@ -154,25 +154,25 @@ class FileId:
|
||||
MINOR = 30
|
||||
|
||||
def __init__(
|
||||
self, *,
|
||||
major: int = MAJOR,
|
||||
minor: int = MINOR,
|
||||
file_type: FileType,
|
||||
dc_id: int,
|
||||
file_reference: bytes = b"",
|
||||
url: str = None,
|
||||
media_id: int = None,
|
||||
access_hash: int = None,
|
||||
volume_id: int = None,
|
||||
thumbnail_source: ThumbnailSource = None,
|
||||
thumbnail_file_type: FileType = None,
|
||||
thumbnail_size: str = "",
|
||||
secret: int = None,
|
||||
local_id: int = None,
|
||||
chat_id: int = None,
|
||||
chat_access_hash: int = None,
|
||||
sticker_set_id: int = None,
|
||||
sticker_set_access_hash: int = None
|
||||
self, *,
|
||||
major: int = MAJOR,
|
||||
minor: int = MINOR,
|
||||
file_type: FileType,
|
||||
dc_id: int,
|
||||
file_reference: bytes = b"",
|
||||
url: str = None,
|
||||
media_id: int = None,
|
||||
access_hash: int = None,
|
||||
volume_id: int = None,
|
||||
thumbnail_source: ThumbnailSource = None,
|
||||
thumbnail_file_type: FileType = None,
|
||||
thumbnail_size: str = "",
|
||||
secret: int = None,
|
||||
local_id: int = None,
|
||||
chat_id: int = None,
|
||||
chat_access_hash: int = None,
|
||||
sticker_set_id: int = None,
|
||||
sticker_set_access_hash: int = None
|
||||
):
|
||||
self.major = major
|
||||
self.minor = minor
|
||||
@ -410,12 +410,12 @@ class FileUniqueType(IntEnum):
|
||||
|
||||
class FileUniqueId:
|
||||
def __init__(
|
||||
self, *,
|
||||
file_unique_type: FileUniqueType,
|
||||
url: str = None,
|
||||
media_id: int = None,
|
||||
volume_id: int = None,
|
||||
local_id: int = None
|
||||
self, *,
|
||||
file_unique_type: FileUniqueType,
|
||||
url: str = None,
|
||||
media_id: int = None,
|
||||
volume_id: int = None,
|
||||
local_id: int = None
|
||||
):
|
||||
self.file_unique_type = file_unique_type
|
||||
self.url = url
|
||||
|
@ -30,8 +30,8 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class ResolvePeer(Scaffold):
|
||||
async def resolve_peer(
|
||||
self,
|
||||
peer_id: Union[int, str]
|
||||
self,
|
||||
peer_id: Union[int, str]
|
||||
) -> Union[raw.base.InputPeer, raw.base.InputUser, raw.base.InputChannel]:
|
||||
"""Get the InputPeer of a known peer id.
|
||||
Useful whenever an InputPeer type is required.
|
||||
|
@ -37,12 +37,12 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class SaveFile(Scaffold):
|
||||
async def save_file(
|
||||
self,
|
||||
path: Union[str, BinaryIO],
|
||||
file_id: int = None,
|
||||
file_part: int = 0,
|
||||
progress: callable = None,
|
||||
progress_args: tuple = ()
|
||||
self,
|
||||
path: Union[str, BinaryIO],
|
||||
file_id: int = None,
|
||||
file_part: int = 0,
|
||||
progress: callable = None,
|
||||
progress_args: tuple = ()
|
||||
):
|
||||
"""Upload a file onto Telegram servers, without actually sending the message to anyone.
|
||||
Useful whenever an InputFile type is required.
|
||||
|
@ -28,11 +28,11 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class Send(Scaffold):
|
||||
async def send(
|
||||
self,
|
||||
data: TLObject,
|
||||
retries: int = Session.MAX_RETRIES,
|
||||
timeout: float = Session.WAIT_TIMEOUT,
|
||||
sleep_threshold: float = None
|
||||
self,
|
||||
data: TLObject,
|
||||
retries: int = Session.MAX_RETRIES,
|
||||
timeout: float = Session.WAIT_TIMEOUT,
|
||||
sleep_threshold: float = None
|
||||
):
|
||||
"""Send raw Telegram queries.
|
||||
|
||||
|
@ -28,10 +28,10 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class SignIn(Scaffold):
|
||||
async def sign_in(
|
||||
self,
|
||||
phone_number: str,
|
||||
phone_code_hash: str,
|
||||
phone_code: str
|
||||
self,
|
||||
phone_number: str,
|
||||
phone_code_hash: str,
|
||||
phone_code: str
|
||||
) -> Union["types.User", "types.TermsOfService", bool]:
|
||||
"""Authorize a user in Telegram with a valid confirmation code.
|
||||
|
||||
|
@ -27,11 +27,11 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class SignUp(Scaffold):
|
||||
async def sign_up(
|
||||
self,
|
||||
phone_number: str,
|
||||
phone_code_hash: str,
|
||||
first_name: str,
|
||||
last_name: str = ""
|
||||
self,
|
||||
phone_number: str,
|
||||
phone_code_hash: str,
|
||||
first_name: str,
|
||||
last_name: str = ""
|
||||
) -> "types.User":
|
||||
"""Register a new user in Telegram.
|
||||
|
||||
|
@ -22,12 +22,12 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class AnswerCallbackQuery(Scaffold):
|
||||
async def answer_callback_query(
|
||||
self,
|
||||
callback_query_id: str,
|
||||
text: str = None,
|
||||
show_alert: bool = None,
|
||||
url: str = None,
|
||||
cache_time: int = 0
|
||||
self,
|
||||
callback_query_id: str,
|
||||
text: str = None,
|
||||
show_alert: bool = None,
|
||||
url: str = None,
|
||||
cache_time: int = 0
|
||||
):
|
||||
"""Send answers to callback queries sent from inline keyboards.
|
||||
The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
|
||||
|
@ -25,15 +25,15 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class AnswerInlineQuery(Scaffold):
|
||||
async def answer_inline_query(
|
||||
self,
|
||||
inline_query_id: str,
|
||||
results: List["types.InlineQueryResult"],
|
||||
cache_time: int = 300,
|
||||
is_gallery: bool = False,
|
||||
is_personal: bool = False,
|
||||
next_offset: str = "",
|
||||
switch_pm_text: str = "",
|
||||
switch_pm_parameter: str = ""
|
||||
self,
|
||||
inline_query_id: str,
|
||||
results: List["types.InlineQueryResult"],
|
||||
cache_time: int = 300,
|
||||
is_gallery: bool = False,
|
||||
is_personal: bool = False,
|
||||
next_offset: str = "",
|
||||
switch_pm_text: str = "",
|
||||
switch_pm_parameter: str = ""
|
||||
):
|
||||
"""Send answers to an inline query.
|
||||
|
||||
|
@ -25,10 +25,10 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetGameHighScores(Scaffold):
|
||||
async def get_game_high_scores(
|
||||
self,
|
||||
user_id: Union[int, str],
|
||||
chat_id: Union[int, str],
|
||||
message_id: int = None
|
||||
self,
|
||||
user_id: Union[int, str],
|
||||
chat_id: Union[int, str],
|
||||
message_id: int = None
|
||||
) -> List["types.GameHighScore"]:
|
||||
"""Get data for high score tables.
|
||||
|
||||
|
@ -25,12 +25,12 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetInlineBotResults(Scaffold):
|
||||
async def get_inline_bot_results(
|
||||
self,
|
||||
bot: Union[int, str],
|
||||
query: str = "",
|
||||
offset: str = "",
|
||||
latitude: float = None,
|
||||
longitude: float = None
|
||||
self,
|
||||
bot: Union[int, str],
|
||||
query: str = "",
|
||||
offset: str = "",
|
||||
latitude: float = None,
|
||||
longitude: float = None
|
||||
):
|
||||
"""Get bot results via inline queries.
|
||||
You can then send a result using :meth:`~pyrogram.Client.send_inline_bot_result`
|
||||
|
@ -24,11 +24,11 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class RequestCallbackAnswer(Scaffold):
|
||||
async def request_callback_answer(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
callback_data: Union[str, bytes],
|
||||
timeout: int = 10
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
callback_data: Union[str, bytes],
|
||||
timeout: int = 10
|
||||
):
|
||||
"""Request a callback answer from bots.
|
||||
This is the equivalent of clicking an inline button containing callback data.
|
||||
|
@ -25,18 +25,18 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SendGame(Scaffold):
|
||||
async def send_game(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
game_short_name: str,
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
protect_content: bool = None,
|
||||
reply_markup: Union[
|
||||
"types.InlineKeyboardMarkup",
|
||||
"types.ReplyKeyboardMarkup",
|
||||
"types.ReplyKeyboardRemove",
|
||||
"types.ForceReply"
|
||||
] = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
game_short_name: str,
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
protect_content: bool = None,
|
||||
reply_markup: Union[
|
||||
"types.InlineKeyboardMarkup",
|
||||
"types.ReplyKeyboardMarkup",
|
||||
"types.ReplyKeyboardRemove",
|
||||
"types.ForceReply"
|
||||
] = None
|
||||
) -> "types.Message":
|
||||
"""Send a game.
|
||||
|
||||
|
@ -24,13 +24,13 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SendInlineBotResult(Scaffold):
|
||||
async def send_inline_bot_result(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
query_id: int,
|
||||
result_id: str,
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
hide_via: bool = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
query_id: int,
|
||||
result_id: str,
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
hide_via: bool = None
|
||||
):
|
||||
"""Send an inline bot result.
|
||||
Bot results can be retrieved using :meth:`~pyrogram.Client.get_inline_bot_results`
|
||||
|
@ -25,13 +25,13 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SetGameScore(Scaffold):
|
||||
async def set_game_score(
|
||||
self,
|
||||
user_id: Union[int, str],
|
||||
score: int,
|
||||
force: bool = None,
|
||||
disable_edit_message: bool = None,
|
||||
chat_id: Union[int, str] = None,
|
||||
message_id: int = None
|
||||
self,
|
||||
user_id: Union[int, str],
|
||||
score: int,
|
||||
force: bool = None,
|
||||
disable_edit_message: bool = None,
|
||||
chat_id: Union[int, str] = None,
|
||||
message_id: int = None
|
||||
) -> Union["types.Message", bool]:
|
||||
# inline_message_id: str = None): TODO Add inline_message_id
|
||||
"""Set the score of the specified user in a game.
|
||||
|
@ -24,10 +24,10 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class AddChatMembers(Scaffold):
|
||||
async def add_chat_members(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_ids: Union[Union[int, str], List[Union[int, str]]],
|
||||
forward_limit: int = 100
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_ids: Union[Union[int, str], List[Union[int, str]]],
|
||||
forward_limit: int = 100
|
||||
) -> bool:
|
||||
"""Add new chat members to a group, supergroup or channel
|
||||
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class ArchiveChats(Scaffold):
|
||||
async def archive_chats(
|
||||
self,
|
||||
chat_ids: Union[int, str, List[Union[int, str]]],
|
||||
self,
|
||||
chat_ids: Union[int, str, List[Union[int, str]]],
|
||||
) -> bool:
|
||||
"""Archive one or more chats.
|
||||
|
||||
|
@ -25,10 +25,10 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class BanChatMember(Scaffold):
|
||||
async def ban_chat_member(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
until_date: int = 0
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
until_date: int = 0
|
||||
) -> Union["types.Message", bool]:
|
||||
"""Ban 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
|
||||
|
@ -23,9 +23,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class CreateChannel(Scaffold):
|
||||
async def create_channel(
|
||||
self,
|
||||
title: str,
|
||||
description: str = ""
|
||||
self,
|
||||
title: str,
|
||||
description: str = ""
|
||||
) -> "types.Chat":
|
||||
"""Create a new broadcast channel.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class CreateGroup(Scaffold):
|
||||
async def create_group(
|
||||
self,
|
||||
title: str,
|
||||
users: Union[Union[int, str], List[Union[int, str]]]
|
||||
self,
|
||||
title: str,
|
||||
users: Union[Union[int, str], List[Union[int, str]]]
|
||||
) -> "types.Chat":
|
||||
"""Create a new basic group.
|
||||
|
||||
|
@ -23,9 +23,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class CreateSupergroup(Scaffold):
|
||||
async def create_supergroup(
|
||||
self,
|
||||
title: str,
|
||||
description: str = ""
|
||||
self,
|
||||
title: str,
|
||||
description: str = ""
|
||||
) -> "types.Chat":
|
||||
"""Create a new supergroup.
|
||||
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class DeleteChatPhoto(Scaffold):
|
||||
async def delete_chat_photo(
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
) -> bool:
|
||||
"""Delete a chat photo.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class DeleteUserHistory(Scaffold):
|
||||
async def delete_user_history(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
) -> bool:
|
||||
"""Delete all messages sent by a certain user in a supergroup.
|
||||
|
||||
|
@ -26,8 +26,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChat(Scaffold):
|
||||
async def get_chat(
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
) -> Union["types.Chat", "types.ChatPreview"]:
|
||||
"""Get up to date information about a chat.
|
||||
|
||||
|
@ -25,13 +25,13 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChatEventLog(Scaffold):
|
||||
async def get_chat_event_log(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
query: str = "",
|
||||
offset_id: int = 0,
|
||||
limit: int = 0,
|
||||
filters: "types.ChatEventFilter" = None,
|
||||
user_ids: List[Union[int, str]] = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
query: str = "",
|
||||
offset_id: int = 0,
|
||||
limit: int = 0,
|
||||
filters: "types.ChatEventFilter" = None,
|
||||
user_ids: List[Union[int, str]] = None
|
||||
) -> Optional[AsyncGenerator["types.ChatEvent", None]]:
|
||||
"""Get the actions taken by chat members and administrators in the last 48h.
|
||||
|
||||
|
@ -26,9 +26,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChatMember(Scaffold):
|
||||
async def get_chat_member(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str]
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str]
|
||||
) -> "types.ChatMember":
|
||||
"""Get information about one member of a chat.
|
||||
|
||||
|
@ -37,12 +37,12 @@ class Filters:
|
||||
|
||||
class GetChatMembers(Scaffold):
|
||||
async def get_chat_members(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
offset: int = 0,
|
||||
limit: int = 200,
|
||||
query: str = "",
|
||||
filter: str = Filters.RECENT
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
offset: int = 0,
|
||||
limit: int = 200,
|
||||
query: str = "",
|
||||
filter: str = Filters.RECENT
|
||||
) -> List["types.ChatMember"]:
|
||||
"""Get a chunk of the members list of a chat.
|
||||
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChatMembersCount(Scaffold):
|
||||
async def get_chat_members_count(
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
) -> int:
|
||||
"""Get the number of members in a chat.
|
||||
|
||||
|
@ -29,10 +29,10 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class GetDialogs(Scaffold):
|
||||
async def get_dialogs(
|
||||
self,
|
||||
offset_date: int = 0,
|
||||
limit: int = 100,
|
||||
pinned_only: bool = False
|
||||
self,
|
||||
offset_date: int = 0,
|
||||
limit: int = 100,
|
||||
pinned_only: bool = False
|
||||
) -> List["types.Dialog"]:
|
||||
"""Get a chunk of the user's dialogs.
|
||||
|
||||
|
@ -26,9 +26,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetNearbyChats(Scaffold):
|
||||
async def get_nearby_chats(
|
||||
self,
|
||||
latitude: float,
|
||||
longitude: float
|
||||
self,
|
||||
latitude: float,
|
||||
longitude: float
|
||||
) -> List["types.Chat"]:
|
||||
"""Get nearby chats.
|
||||
|
||||
|
@ -25,8 +25,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetSendAsChats(Scaffold):
|
||||
async def get_send_as_chats(
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
) -> List["types.Chat"]:
|
||||
"""Get the list of "send_as" chats available.
|
||||
|
||||
|
@ -34,11 +34,11 @@ class Filters:
|
||||
|
||||
class IterChatMembers(Scaffold):
|
||||
async def iter_chat_members(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
limit: int = 0,
|
||||
query: str = "",
|
||||
filter: str = Filters.RECENT
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
limit: int = 0,
|
||||
query: str = "",
|
||||
filter: str = Filters.RECENT
|
||||
) -> Optional[AsyncGenerator["types.ChatMember", None]]:
|
||||
"""Iterate through the members of a chat sequentially.
|
||||
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class IterDialogs(Scaffold):
|
||||
async def iter_dialogs(
|
||||
self,
|
||||
limit: int = 0
|
||||
self,
|
||||
limit: int = 0
|
||||
) -> Optional[AsyncGenerator["types.Dialog", None]]:
|
||||
"""Iterate through a user's dialogs sequentially.
|
||||
|
||||
|
@ -25,8 +25,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class JoinChat(Scaffold):
|
||||
async def join_chat(
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
):
|
||||
"""Join a group chat or channel.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class LeaveChat(Scaffold):
|
||||
async def leave_chat(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
delete: bool = False
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
delete: bool = False
|
||||
):
|
||||
"""Leave a group chat or channel.
|
||||
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class MarkChatUnread(Scaffold):
|
||||
async def mark_chat_unread(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
) -> bool:
|
||||
"""Mark a chat as unread.
|
||||
|
||||
|
@ -24,11 +24,11 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class PinChatMessage(Scaffold):
|
||||
async def pin_chat_message(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
disable_notification: bool = False,
|
||||
both_sides: bool = False,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
disable_notification: bool = False,
|
||||
both_sides: bool = False,
|
||||
) -> bool:
|
||||
"""Pin a message in a group, channel or your own chat.
|
||||
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in
|
||||
|
@ -24,20 +24,20 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class PromoteChatMember(Scaffold):
|
||||
async def promote_chat_member(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
is_anonymous: bool = False,
|
||||
can_manage_chat: bool = True,
|
||||
can_change_info: bool = False,
|
||||
can_post_messages: bool = False,
|
||||
can_edit_messages: bool = False,
|
||||
can_delete_messages: bool = False,
|
||||
can_restrict_members: bool = False,
|
||||
can_invite_users: bool = False,
|
||||
can_pin_messages: bool = False,
|
||||
can_promote_members: bool = False,
|
||||
can_manage_voice_chats: bool = False
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
is_anonymous: bool = False,
|
||||
can_manage_chat: bool = True,
|
||||
can_change_info: bool = False,
|
||||
can_post_messages: bool = False,
|
||||
can_edit_messages: bool = False,
|
||||
can_delete_messages: bool = False,
|
||||
can_restrict_members: bool = False,
|
||||
can_invite_users: bool = False,
|
||||
can_pin_messages: bool = False,
|
||||
can_promote_members: bool = False,
|
||||
can_manage_voice_chats: bool = False
|
||||
) -> bool:
|
||||
"""Promote or demote a user in a supergroup or a channel.
|
||||
|
||||
|
@ -25,11 +25,11 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class RestrictChatMember(Scaffold):
|
||||
async def restrict_chat_member(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
permissions: "types.ChatPermissions",
|
||||
until_date: int = 0
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
permissions: "types.ChatPermissions",
|
||||
until_date: int = 0
|
||||
) -> "types.Chat":
|
||||
"""Restrict a user in a supergroup.
|
||||
|
||||
|
@ -24,10 +24,10 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SetAdministratorTitle(Scaffold):
|
||||
async def set_administrator_title(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
title: str,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str],
|
||||
title: str,
|
||||
) -> bool:
|
||||
"""Set a custom title (rank) to an administrator of a supergroup.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SetChatDescription(Scaffold):
|
||||
async def set_chat_description(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
description: str
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
description: str
|
||||
) -> bool:
|
||||
"""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.
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SetChatPermissions(Scaffold):
|
||||
async def set_chat_permissions(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
permissions: "types.ChatPermissions",
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
permissions: "types.ChatPermissions",
|
||||
) -> "types.Chat":
|
||||
"""Set default chat permissions for all members.
|
||||
|
||||
|
@ -27,11 +27,11 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SetChatPhoto(Scaffold):
|
||||
async def set_chat_photo(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
*,
|
||||
photo: Union[str, BinaryIO] = None,
|
||||
video: Union[str, BinaryIO] = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
*,
|
||||
photo: Union[str, BinaryIO] = None,
|
||||
video: Union[str, BinaryIO] = None
|
||||
) -> bool:
|
||||
"""Set a new chat photo or video (H.264/MPEG-4 AVC video, max 5 seconds).
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SetChatProtectedContent(Scaffold):
|
||||
async def set_chat_protected_content(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
enabled: bool
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
enabled: bool
|
||||
) -> bool:
|
||||
"""Set the chat protected content setting.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SetChatTitle(Scaffold):
|
||||
async def set_chat_title(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
title: str
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
title: str
|
||||
) -> bool:
|
||||
"""Change the title of a chat.
|
||||
Titles can't be changed for private chats.
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SetSendAsChat(Scaffold):
|
||||
async def set_send_as_chat(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
send_as_chat_id: Union[int, str]
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
send_as_chat_id: Union[int, str]
|
||||
) -> bool:
|
||||
"""Set the default "send_as" chat for a chat.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class SetSlowMode(Scaffold):
|
||||
async def set_slow_mode(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
seconds: Optional[int]
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
seconds: Optional[int]
|
||||
) -> bool:
|
||||
"""Set the slow mode interval for a chat.
|
||||
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class UnarchiveChats(Scaffold):
|
||||
async def unarchive_chats(
|
||||
self,
|
||||
chat_ids: Union[int, str, List[Union[int, str]]],
|
||||
self,
|
||||
chat_ids: Union[int, str, List[Union[int, str]]],
|
||||
) -> bool:
|
||||
"""Unarchive one or more chats.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class UnbanChatMember(Scaffold):
|
||||
async def unban_chat_member(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str]
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: Union[int, str]
|
||||
) -> bool:
|
||||
"""Unban a previously banned 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.
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class UnpinAllChatMessages(Scaffold):
|
||||
async def unpin_all_chat_messages(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
) -> bool:
|
||||
"""Use this method to clear the list of pinned messages in a chat.
|
||||
If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class UnpinChatMessage(Scaffold):
|
||||
async def unpin_chat_message(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int = 0
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int = 0
|
||||
) -> bool:
|
||||
"""Unpin a message in a group, channel or your own chat.
|
||||
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class UpdateChatUsername(Scaffold):
|
||||
async def update_chat_username(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
username: Optional[str]
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
username: Optional[str]
|
||||
) -> bool:
|
||||
"""Update a channel or a supergroup username.
|
||||
|
||||
|
@ -25,12 +25,12 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class AddContact(Scaffold):
|
||||
async def add_contact(
|
||||
self,
|
||||
user_id: Union[int, str],
|
||||
first_name: str,
|
||||
last_name: str = "",
|
||||
phone_number: str = "",
|
||||
share_phone_number: bool = False
|
||||
self,
|
||||
user_id: Union[int, str],
|
||||
first_name: str,
|
||||
last_name: str = "",
|
||||
phone_number: str = "",
|
||||
share_phone_number: bool = False
|
||||
):
|
||||
"""Add an existing Telegram user as contact, even without a phone number.
|
||||
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class DeleteContacts(Scaffold):
|
||||
async def delete_contacts(
|
||||
self,
|
||||
user_ids: Union[int, str, List[Union[int, str]]]
|
||||
self,
|
||||
user_ids: Union[int, str, List[Union[int, str]]]
|
||||
) -> Union["types.User", List["types.User"], None]:
|
||||
"""Delete contacts from your Telegram address book.
|
||||
|
||||
|
@ -25,8 +25,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class ImportContacts(Scaffold):
|
||||
async def import_contacts(
|
||||
self,
|
||||
contacts: List["types.InputPhoneContact"]
|
||||
self,
|
||||
contacts: List["types.InputPhoneContact"]
|
||||
):
|
||||
"""Import contacts to your Telegram address book.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnCallbackQuery(Scaffold):
|
||||
def on_callback_query(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling callback queries.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnChatJoinRequest(Scaffold):
|
||||
def on_chat_join_request(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling chat join requests.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnChatMemberUpdated(Scaffold):
|
||||
def on_chat_member_updated(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling event changes on chat members.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnChosenInlineResult(Scaffold):
|
||||
def on_chosen_inline_result(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling chosen inline results.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnDeletedMessages(Scaffold):
|
||||
def on_deleted_messages(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling deleted messages.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnInlineQuery(Scaffold):
|
||||
def on_inline_query(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling inline queries.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnMessage(Scaffold):
|
||||
def on_message(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling messages.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnPoll(Scaffold):
|
||||
def on_poll(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling poll updates.
|
||||
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnRawUpdate(Scaffold):
|
||||
def on_raw_update(
|
||||
self=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling raw updates.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class OnUserStatus(Scaffold):
|
||||
def on_user_status(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""Decorator for handling user status updates.
|
||||
This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class ApproveChatJoinRequest(Scaffold):
|
||||
async def approve_chat_join_request(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: int,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: int,
|
||||
) -> bool:
|
||||
"""Approve a chat join request.
|
||||
|
||||
|
@ -25,12 +25,12 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class CreateChatInviteLink(Scaffold):
|
||||
async def create_chat_invite_link(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
name: str = None,
|
||||
expire_date: int = None,
|
||||
member_limit: int = None,
|
||||
creates_join_request: bool = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
name: str = None,
|
||||
expire_date: int = None,
|
||||
member_limit: int = None,
|
||||
creates_join_request: bool = None
|
||||
) -> "types.ChatInviteLink":
|
||||
"""Create an additional invite link for a chat.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class DeclineChatJoinRequest(Scaffold):
|
||||
async def decline_chat_join_request(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: int,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
user_id: int,
|
||||
) -> bool:
|
||||
"""Decline a chat join request.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class DeleteChatAdminInviteLinks(Scaffold):
|
||||
async def delete_chat_admin_invite_links(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
admin_id: Union[int, str],
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
admin_id: Union[int, str],
|
||||
) -> bool:
|
||||
"""Delete all revoked invite links of an administrator.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class DeleteChatInviteLink(Scaffold):
|
||||
async def delete_chat_invite_link(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
) -> bool:
|
||||
"""Delete an already revoked invite link.
|
||||
|
||||
|
@ -25,13 +25,13 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class EditChatInviteLink(Scaffold):
|
||||
async def edit_chat_invite_link(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
name: str = None,
|
||||
expire_date: int = None,
|
||||
member_limit: int = None,
|
||||
creates_join_request: bool = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
name: str = None,
|
||||
expire_date: int = None,
|
||||
member_limit: int = None,
|
||||
creates_join_request: bool = None
|
||||
) -> "types.ChatInviteLink":
|
||||
"""Edit a non-primary invite link.
|
||||
|
||||
|
@ -25,8 +25,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class ExportChatInviteLink(Scaffold):
|
||||
async def export_chat_invite_link(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
) -> "types.ChatInviteLink":
|
||||
"""Generate a new primary invite link for a chat; any previously generated primary link is revoked.
|
||||
|
||||
|
@ -25,11 +25,11 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChatAdminInviteLinks(Scaffold):
|
||||
async def get_chat_admin_invite_links(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
admin_id: Union[int, str],
|
||||
revoked: bool = False,
|
||||
limit: int = 0,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
admin_id: Union[int, str],
|
||||
revoked: bool = False,
|
||||
limit: int = 0,
|
||||
) -> Optional[AsyncGenerator["types.ChatInviteLink", None]]:
|
||||
"""Get the invite links created by an administrator in a chat.
|
||||
|
||||
|
@ -24,10 +24,10 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChatAdminInviteLinksCount(Scaffold):
|
||||
async def get_chat_admin_invite_links_count(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
admin_id: Union[int, str],
|
||||
revoked: bool = False,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
admin_id: Union[int, str],
|
||||
revoked: bool = False,
|
||||
) -> int:
|
||||
"""Get the count of the invite links created by an administrator in a chat.
|
||||
|
||||
|
@ -24,8 +24,8 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChatAdminsWithInviteLinks(Scaffold):
|
||||
async def get_chat_admins_with_invite_links(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
):
|
||||
"""Get the list of the administrators that have exported invite links in a chat.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChatInviteLink(Scaffold):
|
||||
async def get_chat_invite_link(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
) -> "types.ChatInviteLink":
|
||||
"""Get detailed information about a chat invite link.
|
||||
|
||||
|
@ -25,10 +25,10 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChatInviteLinkMembers(Scaffold):
|
||||
async def get_chat_invite_link_members(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
limit: int = 0
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
limit: int = 0
|
||||
) -> Optional[AsyncGenerator["types.ChatMember", None]]:
|
||||
"""Get the members who joined the chat with the invite link.
|
||||
|
||||
|
@ -24,9 +24,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetChatInviteLinkMembersCount(Scaffold):
|
||||
async def get_chat_invite_link_members_count(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str
|
||||
) -> int:
|
||||
"""Get the count of the members who joined the chat with the invite link.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class RevokeChatInviteLink(Scaffold):
|
||||
async def revoke_chat_invite_link(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
invite_link: str,
|
||||
) -> "types.ChatInviteLink":
|
||||
"""Revoke a previously created invite link.
|
||||
|
||||
|
@ -24,14 +24,14 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class CopyMediaGroup(Scaffold):
|
||||
async def copy_media_group(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
from_chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
captions: Union[List[str], str] = None,
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
schedule_date: int = None,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
from_chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
captions: Union[List[str], str] = None,
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
schedule_date: int = None,
|
||||
) -> List["types.Message"]:
|
||||
"""Copy a media group by providing one of the message ids.
|
||||
|
||||
|
@ -27,23 +27,23 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class CopyMessage(Scaffold):
|
||||
async def copy_message(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
from_chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
caption: str = None,
|
||||
parse_mode: Optional[str] = object,
|
||||
caption_entities: List["types.MessageEntity"] = None,
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
schedule_date: int = None,
|
||||
protect_content: bool = None,
|
||||
reply_markup: Union[
|
||||
"types.InlineKeyboardMarkup",
|
||||
"types.ReplyKeyboardMarkup",
|
||||
"types.ReplyKeyboardRemove",
|
||||
"types.ForceReply"
|
||||
] = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
from_chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
caption: str = None,
|
||||
parse_mode: Optional[str] = object,
|
||||
caption_entities: List["types.MessageEntity"] = None,
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
schedule_date: int = None,
|
||||
protect_content: bool = None,
|
||||
reply_markup: Union[
|
||||
"types.InlineKeyboardMarkup",
|
||||
"types.ReplyKeyboardMarkup",
|
||||
"types.ReplyKeyboardRemove",
|
||||
"types.ForceReply"
|
||||
] = None
|
||||
) -> List["types.Message"]:
|
||||
"""Copy messages of any kind.
|
||||
|
||||
|
@ -24,10 +24,10 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class DeleteMessages(Scaffold):
|
||||
async def delete_messages(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_ids: Union[int, Iterable[int]],
|
||||
revoke: bool = True
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_ids: Union[int, Iterable[int]],
|
||||
revoke: bool = True
|
||||
) -> bool:
|
||||
"""Delete messages, including service messages.
|
||||
|
||||
|
@ -31,12 +31,12 @@ DEFAULT_DOWNLOAD_DIR = "downloads/"
|
||||
|
||||
class DownloadMedia(Scaffold):
|
||||
async def download_media(
|
||||
self,
|
||||
message: Union["types.Message", str],
|
||||
file_name: str = DEFAULT_DOWNLOAD_DIR,
|
||||
block: bool = True,
|
||||
progress: callable = None,
|
||||
progress_args: tuple = ()
|
||||
self,
|
||||
message: Union["types.Message", str],
|
||||
file_name: str = DEFAULT_DOWNLOAD_DIR,
|
||||
block: bool = True,
|
||||
progress: callable = None,
|
||||
progress_args: tuple = ()
|
||||
) -> Optional[str]:
|
||||
"""Download the media from a message.
|
||||
|
||||
|
@ -24,11 +24,11 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class EditInlineCaption(Scaffold):
|
||||
async def edit_inline_caption(
|
||||
self,
|
||||
inline_message_id: str,
|
||||
caption: str,
|
||||
parse_mode: Optional[str] = object,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
self,
|
||||
inline_message_id: str,
|
||||
caption: str,
|
||||
parse_mode: Optional[str] = object,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
) -> bool:
|
||||
"""Edit the caption of inline media messages.
|
||||
|
||||
|
@ -29,10 +29,10 @@ from .inline_session import get_session
|
||||
|
||||
class EditInlineMedia(Scaffold):
|
||||
async def edit_inline_media(
|
||||
self,
|
||||
inline_message_id: str,
|
||||
media: "types.InputMedia",
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
self,
|
||||
inline_message_id: str,
|
||||
media: "types.InputMedia",
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
) -> bool:
|
||||
"""Edit inline animation, audio, document, photo or video messages.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from .inline_session import get_session
|
||||
|
||||
class EditInlineReplyMarkup(Scaffold):
|
||||
async def edit_inline_reply_markup(
|
||||
self,
|
||||
inline_message_id: str,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
self,
|
||||
inline_message_id: str,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
) -> bool:
|
||||
"""Edit only the reply markup of inline messages sent via the bot (for inline bots).
|
||||
|
||||
|
@ -27,12 +27,12 @@ from .inline_session import get_session
|
||||
|
||||
class EditInlineText(Scaffold):
|
||||
async def edit_inline_text(
|
||||
self,
|
||||
inline_message_id: str,
|
||||
text: str,
|
||||
parse_mode: Optional[str] = object,
|
||||
disable_web_page_preview: bool = None,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
self,
|
||||
inline_message_id: str,
|
||||
text: str,
|
||||
parse_mode: Optional[str] = object,
|
||||
disable_web_page_preview: bool = None,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
) -> bool:
|
||||
"""Edit the text of inline messages.
|
||||
|
||||
|
@ -24,13 +24,13 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class EditMessageCaption(Scaffold):
|
||||
async def edit_message_caption(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
caption: str,
|
||||
parse_mode: Optional[str] = object,
|
||||
caption_entities: List["types.MessageEntity"] = None,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
caption: str,
|
||||
parse_mode: Optional[str] = object,
|
||||
caption_entities: List["types.MessageEntity"] = None,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
) -> "types.Message":
|
||||
"""Edit the caption of media messages.
|
||||
|
||||
|
@ -29,12 +29,12 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class EditMessageMedia(Scaffold):
|
||||
async def edit_message_media(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
media: "types.InputMedia",
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None,
|
||||
file_name: str = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
media: "types.InputMedia",
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None,
|
||||
file_name: str = None
|
||||
) -> "types.Message":
|
||||
"""Edit animation, audio, document, photo or video messages.
|
||||
|
||||
|
@ -25,10 +25,10 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class EditMessageReplyMarkup(Scaffold):
|
||||
async def edit_message_reply_markup(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None,
|
||||
) -> "types.Message":
|
||||
"""Edit only the reply markup of messages sent by the bot.
|
||||
|
||||
|
@ -26,14 +26,14 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class EditMessageText(Scaffold):
|
||||
async def edit_message_text(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
text: str,
|
||||
parse_mode: Optional[str] = object,
|
||||
entities: List["types.MessageEntity"] = None,
|
||||
disable_web_page_preview: bool = None,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
text: str,
|
||||
parse_mode: Optional[str] = object,
|
||||
entities: List["types.MessageEntity"] = None,
|
||||
disable_web_page_preview: bool = None,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None
|
||||
) -> "types.Message":
|
||||
"""Edit the text of messages.
|
||||
|
||||
|
@ -25,13 +25,13 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class ForwardMessages(Scaffold):
|
||||
async def forward_messages(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
from_chat_id: Union[int, str],
|
||||
message_ids: Union[int, Iterable[int]],
|
||||
disable_notification: bool = None,
|
||||
schedule_date: int = None,
|
||||
protect_content: bool = None
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
from_chat_id: Union[int, str],
|
||||
message_ids: Union[int, Iterable[int]],
|
||||
disable_notification: bool = None,
|
||||
schedule_date: int = None,
|
||||
protect_content: bool = None
|
||||
) -> Union["types.Message", List["types.Message"]]:
|
||||
"""Forward messages of any kind.
|
||||
|
||||
|
@ -25,9 +25,9 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class GetDiscussionMessage(Scaffold):
|
||||
async def get_discussion_message(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int,
|
||||
) -> "types.Message":
|
||||
"""Get the discussion message from the linked discussion group of a channel post.
|
||||
|
||||
|
@ -29,13 +29,13 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class GetHistory(Scaffold):
|
||||
async def get_history(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
limit: int = 100,
|
||||
offset: int = 0,
|
||||
offset_id: int = 0,
|
||||
offset_date: int = 0,
|
||||
reverse: bool = False
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
limit: int = 100,
|
||||
offset: int = 0,
|
||||
offset_id: int = 0,
|
||||
offset_date: int = 0,
|
||||
reverse: bool = False
|
||||
) -> List["types.Message"]:
|
||||
"""Retrieve a chunk of the history of a chat.
|
||||
|
||||
|
@ -27,8 +27,8 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class GetHistoryCount(Scaffold):
|
||||
async def get_history_count(
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
self,
|
||||
chat_id: Union[int, str]
|
||||
) -> int:
|
||||
"""Get the total count of messages in a chat.
|
||||
|
||||
|
@ -27,9 +27,9 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class GetMediaGroup(Scaffold):
|
||||
async def get_media_group(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int
|
||||
) -> List["types.Message"]:
|
||||
"""Get the media group a message belongs to.
|
||||
|
||||
|
@ -32,11 +32,11 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class GetMessages(Scaffold):
|
||||
async def get_messages(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_ids: Union[int, Iterable[int]] = None,
|
||||
reply_to_message_ids: Union[int, Iterable[int]] = None,
|
||||
replies: int = 1
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_ids: Union[int, Iterable[int]] = None,
|
||||
reply_to_message_ids: Union[int, Iterable[int]] = None,
|
||||
replies: int = 1
|
||||
) -> Union["types.Message", List["types.Message"]]:
|
||||
"""Get one or more messages from a chat by using message identifiers.
|
||||
|
||||
|
@ -24,13 +24,13 @@ from pyrogram.scaffold import Scaffold
|
||||
|
||||
class IterHistory(Scaffold):
|
||||
async def iter_history(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
limit: int = 0,
|
||||
offset: int = 0,
|
||||
offset_id: int = 0,
|
||||
offset_date: int = 0,
|
||||
reverse: bool = False
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
limit: int = 0,
|
||||
offset: int = 0,
|
||||
offset_id: int = 0,
|
||||
offset_date: int = 0,
|
||||
reverse: bool = False
|
||||
) -> Optional[AsyncGenerator["types.Message", None]]:
|
||||
"""Iterate through a chat history sequentially.
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user