mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Rename Client.send to Client.invoke
This commit is contained in:
parent
4f6ce8bec1
commit
78efb04b40
@ -567,7 +567,7 @@ class Client(Methods):
|
|||||||
|
|
||||||
if not isinstance(message, raw.types.MessageEmpty):
|
if not isinstance(message, raw.types.MessageEmpty):
|
||||||
try:
|
try:
|
||||||
diff = await self.send(
|
diff = await self.invoke(
|
||||||
raw.functions.updates.GetChannelDifference(
|
raw.functions.updates.GetChannelDifference(
|
||||||
channel=await self.resolve_peer(utils.get_channel_id(channel_id)),
|
channel=await self.resolve_peer(utils.get_channel_id(channel_id)),
|
||||||
filter=raw.types.ChannelMessagesFilter(
|
filter=raw.types.ChannelMessagesFilter(
|
||||||
@ -589,7 +589,7 @@ class Client(Methods):
|
|||||||
|
|
||||||
self.dispatcher.updates_queue.put_nowait((update, users, chats))
|
self.dispatcher.updates_queue.put_nowait((update, users, chats))
|
||||||
elif isinstance(updates, (raw.types.UpdateShortMessage, raw.types.UpdateShortChatMessage)):
|
elif isinstance(updates, (raw.types.UpdateShortMessage, raw.types.UpdateShortChatMessage)):
|
||||||
diff = await self.send(
|
diff = await self.invoke(
|
||||||
raw.functions.updates.GetDifference(
|
raw.functions.updates.GetDifference(
|
||||||
pts=updates.pts - updates.pts_count,
|
pts=updates.pts - updates.pts_count,
|
||||||
date=updates.date,
|
date=updates.date,
|
||||||
@ -847,14 +847,14 @@ class Client(Methods):
|
|||||||
await session.start()
|
await session.start()
|
||||||
|
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
exported_auth = await self.send(
|
exported_auth = await self.invoke(
|
||||||
raw.functions.auth.ExportAuthorization(
|
raw.functions.auth.ExportAuthorization(
|
||||||
dc_id=dc_id
|
dc_id=dc_id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await session.send(
|
await session.invoke(
|
||||||
raw.functions.auth.ImportAuthorization(
|
raw.functions.auth.ImportAuthorization(
|
||||||
id=exported_auth.id,
|
id=exported_auth.id,
|
||||||
bytes=exported_auth.bytes
|
bytes=exported_auth.bytes
|
||||||
@ -920,7 +920,7 @@ class Client(Methods):
|
|||||||
file_name = ""
|
file_name = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r = await session.send(
|
r = await session.invoke(
|
||||||
raw.functions.upload.GetFile(
|
raw.functions.upload.GetFile(
|
||||||
location=location,
|
location=location,
|
||||||
offset=offset,
|
offset=offset,
|
||||||
@ -958,7 +958,7 @@ class Client(Methods):
|
|||||||
if len(chunk) < limit:
|
if len(chunk) < limit:
|
||||||
break
|
break
|
||||||
|
|
||||||
r = await session.send(
|
r = await session.invoke(
|
||||||
raw.functions.upload.GetFile(
|
raw.functions.upload.GetFile(
|
||||||
location=location,
|
location=location,
|
||||||
offset=offset,
|
offset=offset,
|
||||||
@ -986,7 +986,7 @@ class Client(Methods):
|
|||||||
file_name = f.name
|
file_name = f.name
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
r2 = await cdn_session.send(
|
r2 = await cdn_session.invoke(
|
||||||
raw.functions.upload.GetCdnFile(
|
raw.functions.upload.GetCdnFile(
|
||||||
file_token=r.file_token,
|
file_token=r.file_token,
|
||||||
offset=offset,
|
offset=offset,
|
||||||
@ -996,7 +996,7 @@ class Client(Methods):
|
|||||||
|
|
||||||
if isinstance(r2, raw.types.upload.CdnFileReuploadNeeded):
|
if isinstance(r2, raw.types.upload.CdnFileReuploadNeeded):
|
||||||
try:
|
try:
|
||||||
await session.send(
|
await session.invoke(
|
||||||
raw.functions.upload.ReuploadCdnFile(
|
raw.functions.upload.ReuploadCdnFile(
|
||||||
file_token=r.file_token,
|
file_token=r.file_token,
|
||||||
request_token=r2.request_token
|
request_token=r2.request_token
|
||||||
@ -1019,7 +1019,7 @@ class Client(Methods):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
hashes = await session.send(
|
hashes = await session.invoke(
|
||||||
raw.functions.upload.GetCdnFileHashes(
|
raw.functions.upload.GetCdnFileHashes(
|
||||||
file_token=r.file_token,
|
file_token=r.file_token,
|
||||||
offset=offset
|
offset=offset
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
# 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 .invoke import Invoke
|
||||||
from .resolve_peer import ResolvePeer
|
from .resolve_peer import ResolvePeer
|
||||||
from .save_file import SaveFile
|
from .save_file import SaveFile
|
||||||
from .send import Send
|
|
||||||
|
|
||||||
|
|
||||||
class Advanced(
|
class Advanced(
|
||||||
|
Invoke,
|
||||||
ResolvePeer,
|
ResolvePeer,
|
||||||
SaveFile,
|
SaveFile
|
||||||
Send
|
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
@ -26,15 +26,15 @@ from pyrogram.session import Session
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Send:
|
class Invoke:
|
||||||
async def send(
|
async def invoke(
|
||||||
self: "pyrogram.Client",
|
self: "pyrogram.Client",
|
||||||
data: TLObject,
|
query: TLObject,
|
||||||
retries: int = Session.MAX_RETRIES,
|
retries: int = Session.MAX_RETRIES,
|
||||||
timeout: float = Session.WAIT_TIMEOUT,
|
timeout: float = Session.WAIT_TIMEOUT,
|
||||||
sleep_threshold: float = None
|
sleep_threshold: float = None
|
||||||
):
|
):
|
||||||
"""Send raw Telegram queries.
|
"""Invoke raw Telegram functions.
|
||||||
|
|
||||||
This method makes it possible to manually call every single Telegram API method in a low-level manner.
|
This method makes it possible to manually call every single Telegram API method in a low-level manner.
|
||||||
Available functions are listed in the :obj:`functions <pyrogram.api.functions>` package and may accept compound
|
Available functions are listed in the :obj:`functions <pyrogram.api.functions>` package and may accept compound
|
||||||
@ -47,7 +47,7 @@ class Send:
|
|||||||
available yet in the Client class as an easy-to-use method).
|
available yet in the Client class as an easy-to-use method).
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
data (``RawFunction``):
|
query (``RawFunction``):
|
||||||
The API Schema function filled with proper arguments.
|
The API Schema function filled with proper arguments.
|
||||||
|
|
||||||
retries (``int``):
|
retries (``int``):
|
||||||
@ -69,13 +69,13 @@ class Send:
|
|||||||
raise ConnectionError("Client has not been started yet")
|
raise ConnectionError("Client has not been started yet")
|
||||||
|
|
||||||
if self.no_updates:
|
if self.no_updates:
|
||||||
data = raw.functions.InvokeWithoutUpdates(query=data)
|
query = raw.functions.InvokeWithoutUpdates(query=query)
|
||||||
|
|
||||||
if self.takeout_id:
|
if self.takeout_id:
|
||||||
data = raw.functions.InvokeWithTakeout(takeout_id=self.takeout_id, query=data)
|
query = raw.functions.InvokeWithTakeout(takeout_id=self.takeout_id, query=query)
|
||||||
|
|
||||||
r = await self.session.send(
|
r = await self.session.invoke(
|
||||||
data, retries, timeout,
|
query, retries, timeout,
|
||||||
(sleep_threshold
|
(sleep_threshold
|
||||||
if sleep_threshold is not None
|
if sleep_threshold is not None
|
||||||
else self.sleep_threshold)
|
else self.sleep_threshold)
|
@ -71,7 +71,7 @@ class ResolvePeer:
|
|||||||
try:
|
try:
|
||||||
return await self.storage.get_peer_by_username(peer_id)
|
return await self.storage.get_peer_by_username(peer_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.contacts.ResolveUsername(
|
raw.functions.contacts.ResolveUsername(
|
||||||
username=peer_id
|
username=peer_id
|
||||||
)
|
)
|
||||||
@ -88,7 +88,7 @@ class ResolvePeer:
|
|||||||
|
|
||||||
if peer_type == "user":
|
if peer_type == "user":
|
||||||
await self.fetch_peers(
|
await self.fetch_peers(
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.users.GetUsers(
|
raw.functions.users.GetUsers(
|
||||||
id=[
|
id=[
|
||||||
raw.types.InputUser(
|
raw.types.InputUser(
|
||||||
@ -100,13 +100,13 @@ class ResolvePeer:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif peer_type == "chat":
|
elif peer_type == "chat":
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.GetChats(
|
raw.functions.messages.GetChats(
|
||||||
id=[-peer_id]
|
id=[-peer_id]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.GetChannels(
|
raw.functions.channels.GetChannels(
|
||||||
id=[
|
id=[
|
||||||
raw.types.InputChannel(
|
raw.types.InputChannel(
|
||||||
|
@ -103,7 +103,7 @@ class SaveFile:
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await session.send(data)
|
await session.invoke(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e)
|
log.error(e)
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class AcceptTermsOfService:
|
|||||||
terms_of_service_id (``str``):
|
terms_of_service_id (``str``):
|
||||||
The terms of service identifier.
|
The terms of service identifier.
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.help.AcceptTermsOfService(
|
raw.functions.help.AcceptTermsOfService(
|
||||||
id=raw.types.DataJSON(
|
id=raw.types.DataJSON(
|
||||||
data=terms_of_service_id
|
data=terms_of_service_id
|
||||||
|
@ -43,10 +43,10 @@ class CheckPassword:
|
|||||||
Raises:
|
Raises:
|
||||||
BadRequest: In case the password is invalid.
|
BadRequest: In case the password is invalid.
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.auth.CheckPassword(
|
raw.functions.auth.CheckPassword(
|
||||||
password=compute_password_check(
|
password=compute_password_check(
|
||||||
await self.send(raw.functions.account.GetPassword()),
|
await self.invoke(raw.functions.account.GetPassword()),
|
||||||
password
|
password
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -33,4 +33,4 @@ class GetPasswordHint:
|
|||||||
Returns:
|
Returns:
|
||||||
``str``: On success, the password hint as string is returned.
|
``str``: On success, the password hint as string is returned.
|
||||||
"""
|
"""
|
||||||
return (await self.send(raw.functions.account.GetPassword())).hint
|
return (await self.invoke(raw.functions.account.GetPassword())).hint
|
||||||
|
@ -42,7 +42,7 @@ class LogOut:
|
|||||||
# Log out.
|
# Log out.
|
||||||
app.log_out()
|
app.log_out()
|
||||||
"""
|
"""
|
||||||
await self.send(raw.functions.auth.LogOut())
|
await self.invoke(raw.functions.auth.LogOut())
|
||||||
await self.stop()
|
await self.stop()
|
||||||
await self.storage.delete()
|
await self.storage.delete()
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class RecoverPassword:
|
|||||||
Raises:
|
Raises:
|
||||||
BadRequest: In case the recovery code is invalid.
|
BadRequest: In case the recovery code is invalid.
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.auth.RecoverPassword(
|
raw.functions.auth.RecoverPassword(
|
||||||
code=recovery_code
|
code=recovery_code
|
||||||
)
|
)
|
||||||
|
@ -52,7 +52,7 @@ class ResendCode:
|
|||||||
"""
|
"""
|
||||||
phone_number = phone_number.strip(" +")
|
phone_number = phone_number.strip(" +")
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.auth.ResendCode(
|
raw.functions.auth.ResendCode(
|
||||||
phone_number=phone_number,
|
phone_number=phone_number,
|
||||||
phone_code_hash=phone_code_hash
|
phone_code_hash=phone_code_hash
|
||||||
|
@ -49,7 +49,7 @@ class SendCode:
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.auth.SendCode(
|
raw.functions.auth.SendCode(
|
||||||
phone_number=phone_number,
|
phone_number=phone_number,
|
||||||
api_id=self.api_id,
|
api_id=self.api_id,
|
||||||
|
@ -36,6 +36,6 @@ class SendRecoveryCode:
|
|||||||
Raises:
|
Raises:
|
||||||
BadRequest: In case no recovery email was set up.
|
BadRequest: In case no recovery email was set up.
|
||||||
"""
|
"""
|
||||||
return (await self.send(
|
return (await self.invoke(
|
||||||
raw.functions.auth.RequestPasswordRecovery()
|
raw.functions.auth.RequestPasswordRecovery()
|
||||||
)).email_pattern
|
)).email_pattern
|
||||||
|
@ -58,7 +58,7 @@ class SignIn:
|
|||||||
"""
|
"""
|
||||||
phone_number = phone_number.strip(" +")
|
phone_number = phone_number.strip(" +")
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.auth.SignIn(
|
raw.functions.auth.SignIn(
|
||||||
phone_number=phone_number,
|
phone_number=phone_number,
|
||||||
phone_code_hash=phone_code_hash,
|
phone_code_hash=phone_code_hash,
|
||||||
|
@ -46,7 +46,7 @@ class SignInBot:
|
|||||||
"""
|
"""
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.auth.ImportBotAuthorization(
|
raw.functions.auth.ImportBotAuthorization(
|
||||||
flags=0,
|
flags=0,
|
||||||
api_id=self.api_id,
|
api_id=self.api_id,
|
||||||
|
@ -56,7 +56,7 @@ class SignUp:
|
|||||||
"""
|
"""
|
||||||
phone_number = phone_number.strip(" +")
|
phone_number = phone_number.strip(" +")
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.auth.SignUp(
|
raw.functions.auth.SignUp(
|
||||||
phone_number=phone_number,
|
phone_number=phone_number,
|
||||||
first_name=first_name,
|
first_name=first_name,
|
||||||
|
@ -41,7 +41,7 @@ class Terminate:
|
|||||||
raise ConnectionError("Client is already terminated")
|
raise ConnectionError("Client is already terminated")
|
||||||
|
|
||||||
if self.takeout_id:
|
if self.takeout_id:
|
||||||
await self.send(raw.functions.account.FinishTakeoutSession())
|
await self.invoke(raw.functions.account.FinishTakeoutSession())
|
||||||
log.warning(f"Takeout session {self.takeout_id} finished")
|
log.warning(f"Takeout session {self.takeout_id} finished")
|
||||||
|
|
||||||
await Syncer.remove(self)
|
await Syncer.remove(self)
|
||||||
|
@ -68,7 +68,7 @@ class AnswerCallbackQuery:
|
|||||||
# Answer with alert
|
# Answer with alert
|
||||||
app.answer_callback_query(query_id, text=text, show_alert=True)
|
app.answer_callback_query(query_id, text=text, show_alert=True)
|
||||||
"""
|
"""
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.messages.SetBotCallbackAnswer(
|
raw.functions.messages.SetBotCallbackAnswer(
|
||||||
query_id=int(callback_query_id),
|
query_id=int(callback_query_id),
|
||||||
cache_time=cache_time,
|
cache_time=cache_time,
|
||||||
|
@ -94,7 +94,7 @@ class AnswerInlineQuery:
|
|||||||
InputTextMessageContent("Message content"))])
|
InputTextMessageContent("Message content"))])
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.messages.SetInlineBotResults(
|
raw.functions.messages.SetInlineBotResults(
|
||||||
query_id=int(inline_query_id),
|
query_id=int(inline_query_id),
|
||||||
results=[await r.write(self) for r in results],
|
results=[await r.write(self) for r in results],
|
||||||
|
@ -59,7 +59,7 @@ class GetGameHighScores:
|
|||||||
"""
|
"""
|
||||||
# TODO: inline_message_id
|
# TODO: inline_message_id
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetGameHighScores(
|
raw.functions.messages.GetGameHighScores(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
id=message_id,
|
id=message_id,
|
||||||
|
@ -70,7 +70,7 @@ class GetInlineBotResults:
|
|||||||
# TODO: Don't return the raw type
|
# TODO: Don't return the raw type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.messages.GetInlineBotResults(
|
raw.functions.messages.GetInlineBotResults(
|
||||||
bot=await self.resolve_peer(bot),
|
bot=await self.resolve_peer(bot),
|
||||||
peer=raw.types.InputPeerSelf(),
|
peer=raw.types.InputPeerSelf(),
|
||||||
|
@ -64,7 +64,7 @@ class RequestCallbackAnswer:
|
|||||||
# Telegram only wants bytes, but we are allowed to pass strings too.
|
# Telegram only wants bytes, but we are allowed to pass strings too.
|
||||||
data = bytes(callback_data, "utf-8") if isinstance(callback_data, str) else callback_data
|
data = bytes(callback_data, "utf-8") if isinstance(callback_data, str) else callback_data
|
||||||
|
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.messages.GetBotCallbackAnswer(
|
raw.functions.messages.GetBotCallbackAnswer(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
msg_id=message_id,
|
msg_id=message_id,
|
||||||
|
@ -71,7 +71,7 @@ class SendGame:
|
|||||||
|
|
||||||
app.send_game(chat_id, "gamename")
|
app.send_game(chat_id, "gamename")
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.SendMedia(
|
raw.functions.messages.SendMedia(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
media=raw.types.InputMediaGame(
|
media=raw.types.InputMediaGame(
|
||||||
|
@ -61,7 +61,7 @@ class SendInlineBotResult:
|
|||||||
|
|
||||||
app.send_inline_bot_result(chat_id, query_id, result_id)
|
app.send_inline_bot_result(chat_id, query_id, result_id)
|
||||||
"""
|
"""
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.messages.SendInlineBotResult(
|
raw.functions.messages.SendInlineBotResult(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
query_id=query_id,
|
query_id=query_id,
|
||||||
|
@ -62,7 +62,7 @@ class SetBotCommands:
|
|||||||
BotCommand("settings", "Bot settings")])
|
BotCommand("settings", "Bot settings")])
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.bots.SetBotCommands(
|
raw.functions.bots.SetBotCommands(
|
||||||
commands=[c.write() for c in commands],
|
commands=[c.write() for c in commands],
|
||||||
scope=await scope.write(self),
|
scope=await scope.write(self),
|
||||||
|
@ -75,7 +75,7 @@ class SetGameScore:
|
|||||||
# Force set new score
|
# Force set new score
|
||||||
app.set_game_score(user_id, 25, force=True)
|
app.set_game_score(user_id, 25, force=True)
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.SetGameScore(
|
raw.functions.messages.SetGameScore(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
score=score,
|
score=score,
|
||||||
|
@ -67,7 +67,7 @@ class AddChatMembers:
|
|||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChat):
|
if isinstance(peer, raw.types.InputPeerChat):
|
||||||
for user_id in user_ids:
|
for user_id in user_ids:
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.AddChatUser(
|
raw.functions.messages.AddChatUser(
|
||||||
chat_id=peer.chat_id,
|
chat_id=peer.chat_id,
|
||||||
user_id=await self.resolve_peer(user_id),
|
user_id=await self.resolve_peer(user_id),
|
||||||
@ -75,7 +75,7 @@ class AddChatMembers:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.InviteToChannel(
|
raw.functions.channels.InviteToChannel(
|
||||||
channel=peer,
|
channel=peer,
|
||||||
users=[
|
users=[
|
||||||
|
@ -60,7 +60,7 @@ class ArchiveChats:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.folders.EditPeerFolders(
|
raw.functions.folders.EditPeerFolders(
|
||||||
folder_peers=folder_peers
|
folder_peers=folder_peers
|
||||||
)
|
)
|
||||||
|
@ -73,7 +73,7 @@ class BanChatMember:
|
|||||||
user_peer = await self.resolve_peer(user_id)
|
user_peer = await self.resolve_peer(user_id)
|
||||||
|
|
||||||
if isinstance(chat_peer, raw.types.InputPeerChannel):
|
if isinstance(chat_peer, raw.types.InputPeerChannel):
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.EditBanned(
|
raw.functions.channels.EditBanned(
|
||||||
channel=chat_peer,
|
channel=chat_peer,
|
||||||
participant=user_peer,
|
participant=user_peer,
|
||||||
@ -91,7 +91,7 @@ class BanChatMember:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.DeleteChatUser(
|
raw.functions.messages.DeleteChatUser(
|
||||||
chat_id=abs(chat_id),
|
chat_id=abs(chat_id),
|
||||||
user_id=user_peer
|
user_id=user_peer
|
||||||
|
@ -43,7 +43,7 @@ class CreateChannel:
|
|||||||
|
|
||||||
app.create_channel("Channel Title", "Channel Description")
|
app.create_channel("Channel Title", "Channel Description")
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.CreateChannel(
|
raw.functions.channels.CreateChannel(
|
||||||
title=title,
|
title=title,
|
||||||
about=description,
|
about=description,
|
||||||
|
@ -55,7 +55,7 @@ class CreateGroup:
|
|||||||
if not isinstance(users, list):
|
if not isinstance(users, list):
|
||||||
users = [users]
|
users = [users]
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.CreateChat(
|
raw.functions.messages.CreateChat(
|
||||||
title=title,
|
title=title,
|
||||||
users=[await self.resolve_peer(u) for u in users]
|
users=[await self.resolve_peer(u) for u in users]
|
||||||
|
@ -47,7 +47,7 @@ class CreateSupergroup:
|
|||||||
|
|
||||||
app.create_supergroup("Supergroup Title", "Supergroup Description")
|
app.create_supergroup("Supergroup Title", "Supergroup Description")
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.CreateChannel(
|
raw.functions.channels.CreateChannel(
|
||||||
title=title,
|
title=title,
|
||||||
about=description,
|
about=description,
|
||||||
|
@ -41,7 +41,7 @@ class DeleteChannel:
|
|||||||
|
|
||||||
app.delete_channel(channel_id)
|
app.delete_channel(channel_id)
|
||||||
"""
|
"""
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.DeleteChannel(
|
raw.functions.channels.DeleteChannel(
|
||||||
channel=await self.resolve_peer(chat_id)
|
channel=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
|
@ -49,14 +49,14 @@ class DeleteChatPhoto:
|
|||||||
peer = await self.resolve_peer(chat_id)
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChat):
|
if isinstance(peer, raw.types.InputPeerChat):
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.EditChatPhoto(
|
raw.functions.messages.EditChatPhoto(
|
||||||
chat_id=peer.chat_id,
|
chat_id=peer.chat_id,
|
||||||
photo=raw.types.InputChatPhotoEmpty()
|
photo=raw.types.InputChatPhotoEmpty()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif isinstance(peer, raw.types.InputPeerChannel):
|
elif isinstance(peer, raw.types.InputPeerChannel):
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.EditPhoto(
|
raw.functions.channels.EditPhoto(
|
||||||
channel=peer,
|
channel=peer,
|
||||||
photo=raw.types.InputChatPhotoEmpty()
|
photo=raw.types.InputChatPhotoEmpty()
|
||||||
|
@ -41,7 +41,7 @@ class DeleteSupergroup:
|
|||||||
|
|
||||||
app.delete_supergroup(supergroup_id)
|
app.delete_supergroup(supergroup_id)
|
||||||
"""
|
"""
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.DeleteChannel(
|
raw.functions.channels.DeleteChannel(
|
||||||
channel=await self.resolve_peer(chat_id)
|
channel=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
|
@ -41,7 +41,7 @@ class DeleteUserHistory:
|
|||||||
``bool``: True on success, False otherwise.
|
``bool``: True on success, False otherwise.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.DeleteParticipantHistory(
|
raw.functions.channels.DeleteParticipantHistory(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
participant=await self.resolve_peer(user_id)
|
participant=await self.resolve_peer(user_id)
|
||||||
|
@ -56,7 +56,7 @@ class GetChat:
|
|||||||
match = self.INVITE_LINK_RE.match(str(chat_id))
|
match = self.INVITE_LINK_RE.match(str(chat_id))
|
||||||
|
|
||||||
if match:
|
if match:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.CheckChatInvite(
|
raw.functions.messages.CheckChatInvite(
|
||||||
hash=match.group(1)
|
hash=match.group(1)
|
||||||
)
|
)
|
||||||
@ -76,10 +76,10 @@ class GetChat:
|
|||||||
peer = await self.resolve_peer(chat_id)
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChannel):
|
if isinstance(peer, raw.types.InputPeerChannel):
|
||||||
r = await self.send(raw.functions.channels.GetFullChannel(channel=peer))
|
r = await self.invoke(raw.functions.channels.GetFullChannel(channel=peer))
|
||||||
elif isinstance(peer, (raw.types.InputPeerUser, raw.types.InputPeerSelf)):
|
elif isinstance(peer, (raw.types.InputPeerUser, raw.types.InputPeerSelf)):
|
||||||
r = await self.send(raw.functions.users.GetFullUser(id=peer))
|
r = await self.invoke(raw.functions.users.GetFullUser(id=peer))
|
||||||
else:
|
else:
|
||||||
r = await self.send(raw.functions.messages.GetFullChat(chat_id=peer.chat_id))
|
r = await self.invoke(raw.functions.messages.GetFullChat(chat_id=peer.chat_id))
|
||||||
|
|
||||||
return await types.Chat._parse_full(self, r)
|
return await types.Chat._parse_full(self, r)
|
||||||
|
@ -70,7 +70,7 @@ class GetChatEventLog:
|
|||||||
limit = min(100, total)
|
limit = min(100, total)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
r: raw.base.channels.AdminLogResults = await self.send(
|
r: raw.base.channels.AdminLogResults = await self.invoke(
|
||||||
raw.functions.channels.GetAdminLog(
|
raw.functions.channels.GetAdminLog(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
q=query,
|
q=query,
|
||||||
|
@ -54,7 +54,7 @@ class GetChatMember:
|
|||||||
user = await self.resolve_peer(user_id)
|
user = await self.resolve_peer(user_id)
|
||||||
|
|
||||||
if isinstance(chat, raw.types.InputPeerChat):
|
if isinstance(chat, raw.types.InputPeerChat):
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetFullChat(
|
raw.functions.messages.GetFullChat(
|
||||||
chat_id=chat.chat_id
|
chat_id=chat.chat_id
|
||||||
)
|
)
|
||||||
@ -75,7 +75,7 @@ class GetChatMember:
|
|||||||
else:
|
else:
|
||||||
raise UserNotParticipant
|
raise UserNotParticipant
|
||||||
elif isinstance(chat, raw.types.InputPeerChannel):
|
elif isinstance(chat, raw.types.InputPeerChannel):
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.GetParticipant(
|
raw.functions.channels.GetParticipant(
|
||||||
channel=chat,
|
channel=chat,
|
||||||
participant=user
|
participant=user
|
||||||
|
@ -92,7 +92,7 @@ class GetChatMembers:
|
|||||||
peer = await self.resolve_peer(chat_id)
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChat):
|
if isinstance(peer, raw.types.InputPeerChat):
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetFullChat(
|
raw.functions.messages.GetFullChat(
|
||||||
chat_id=peer.chat_id
|
chat_id=peer.chat_id
|
||||||
)
|
)
|
||||||
@ -120,7 +120,7 @@ class GetChatMembers:
|
|||||||
else:
|
else:
|
||||||
raise ValueError(f'Invalid filter "{filter}"')
|
raise ValueError(f'Invalid filter "{filter}"')
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.GetParticipants(
|
raw.functions.channels.GetParticipants(
|
||||||
channel=peer,
|
channel=peer,
|
||||||
filter=filter,
|
filter=filter,
|
||||||
|
@ -48,7 +48,7 @@ class GetChatMembersCount:
|
|||||||
peer = await self.resolve_peer(chat_id)
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChat):
|
if isinstance(peer, raw.types.InputPeerChat):
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetChats(
|
raw.functions.messages.GetChats(
|
||||||
id=[peer.chat_id]
|
id=[peer.chat_id]
|
||||||
)
|
)
|
||||||
@ -56,7 +56,7 @@ class GetChatMembersCount:
|
|||||||
|
|
||||||
return r.chats[0].participants_count
|
return r.chats[0].participants_count
|
||||||
elif isinstance(peer, raw.types.InputPeerChannel):
|
elif isinstance(peer, raw.types.InputPeerChannel):
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.GetFullChannel(
|
raw.functions.channels.GetFullChannel(
|
||||||
channel=peer
|
channel=peer
|
||||||
)
|
)
|
||||||
|
@ -42,7 +42,7 @@ class GetChatOnlineCount:
|
|||||||
online = app.get_chat_online_count(chat_id)
|
online = app.get_chat_online_count(chat_id)
|
||||||
print(online)
|
print(online)
|
||||||
"""
|
"""
|
||||||
return (await self.send(
|
return (await self.invoke(
|
||||||
raw.functions.messages.GetOnlines(
|
raw.functions.messages.GetOnlines(
|
||||||
peer=await self.resolve_peer(chat_id)
|
peer=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
|
@ -67,12 +67,12 @@ class GetDialogs:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if pinned_only:
|
if pinned_only:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetPinnedDialogs(folder_id=0),
|
raw.functions.messages.GetPinnedDialogs(folder_id=0),
|
||||||
sleep_threshold=60
|
sleep_threshold=60
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetDialogs(
|
raw.functions.messages.GetDialogs(
|
||||||
offset_date=utils.datetime_to_timestamp(offset_date),
|
offset_date=utils.datetime_to_timestamp(offset_date),
|
||||||
offset_id=0,
|
offset_id=0,
|
||||||
|
@ -42,9 +42,9 @@ class GetDialogsCount:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if pinned_only:
|
if pinned_only:
|
||||||
return len((await self.send(raw.functions.messages.GetPinnedDialogs(folder_id=0))).dialogs)
|
return len((await self.invoke(raw.functions.messages.GetPinnedDialogs(folder_id=0))).dialogs)
|
||||||
else:
|
else:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetDialogs(
|
raw.functions.messages.GetDialogs(
|
||||||
offset_date=0,
|
offset_date=0,
|
||||||
offset_id=0,
|
offset_id=0,
|
||||||
|
@ -49,7 +49,7 @@ class GetNearbyChats:
|
|||||||
print(chats)
|
print(chats)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.contacts.GetLocated(
|
raw.functions.contacts.GetLocated(
|
||||||
geo_point=raw.types.InputGeoPoint(
|
geo_point=raw.types.InputGeoPoint(
|
||||||
lat=latitude,
|
lat=latitude,
|
||||||
|
@ -43,7 +43,7 @@ class GetSendAsChats:
|
|||||||
chats = app.get_send_as_chats(chat_id)
|
chats = app.get_send_as_chats(chat_id)
|
||||||
print(chats)
|
print(chats)
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.GetSendAs(
|
raw.functions.channels.GetSendAs(
|
||||||
peer=await self.resolve_peer(chat_id)
|
peer=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
|
@ -57,7 +57,7 @@ class IterDialogs:
|
|||||||
offset_peer = raw.types.InputPeerEmpty()
|
offset_peer = raw.types.InputPeerEmpty()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
r = (await self.send(
|
r = (await self.invoke(
|
||||||
raw.functions.messages.GetDialogs(
|
raw.functions.messages.GetDialogs(
|
||||||
offset_date=offset_date,
|
offset_date=offset_date,
|
||||||
offset_id=offset_id,
|
offset_id=offset_id,
|
||||||
|
@ -53,7 +53,7 @@ class JoinChat:
|
|||||||
match = self.INVITE_LINK_RE.match(str(chat_id))
|
match = self.INVITE_LINK_RE.match(str(chat_id))
|
||||||
|
|
||||||
if match:
|
if match:
|
||||||
chat = await self.send(
|
chat = await self.invoke(
|
||||||
raw.functions.messages.ImportChatInvite(
|
raw.functions.messages.ImportChatInvite(
|
||||||
hash=match.group(1)
|
hash=match.group(1)
|
||||||
)
|
)
|
||||||
@ -63,7 +63,7 @@ class JoinChat:
|
|||||||
elif isinstance(chat.chats[0], raw.types.Channel):
|
elif isinstance(chat.chats[0], raw.types.Channel):
|
||||||
return types.Chat._parse_channel_chat(self, chat.chats[0])
|
return types.Chat._parse_channel_chat(self, chat.chats[0])
|
||||||
else:
|
else:
|
||||||
chat = await self.send(
|
chat = await self.invoke(
|
||||||
raw.functions.channels.JoinChannel(
|
raw.functions.channels.JoinChannel(
|
||||||
channel=await self.resolve_peer(chat_id)
|
channel=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
|
@ -51,13 +51,13 @@ class LeaveChat:
|
|||||||
peer = await self.resolve_peer(chat_id)
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChannel):
|
if isinstance(peer, raw.types.InputPeerChannel):
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.channels.LeaveChannel(
|
raw.functions.channels.LeaveChannel(
|
||||||
channel=await self.resolve_peer(chat_id)
|
channel=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif isinstance(peer, raw.types.InputPeerChat):
|
elif isinstance(peer, raw.types.InputPeerChat):
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.DeleteChatUser(
|
raw.functions.messages.DeleteChatUser(
|
||||||
chat_id=peer.chat_id,
|
chat_id=peer.chat_id,
|
||||||
user_id=raw.types.InputUserSelf()
|
user_id=raw.types.InputUserSelf()
|
||||||
@ -65,7 +65,7 @@ class LeaveChat:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if delete:
|
if delete:
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.DeleteHistory(
|
raw.functions.messages.DeleteHistory(
|
||||||
peer=peer,
|
peer=peer,
|
||||||
max_id=0
|
max_id=0
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.raw import functions
|
from pyrogram import raw
|
||||||
|
|
||||||
|
|
||||||
class MarkChatUnread:
|
class MarkChatUnread:
|
||||||
@ -37,8 +37,8 @@ class MarkChatUnread:
|
|||||||
``bool``: On success, True is returned.
|
``bool``: On success, True is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
functions.messages.MarkDialogUnread(
|
raw.functions.messages.MarkDialogUnread(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
unread=True
|
unread=True
|
||||||
)
|
)
|
||||||
|
@ -61,7 +61,7 @@ class PinChatMessage:
|
|||||||
# Pin without notification
|
# Pin without notification
|
||||||
app.pin_chat_message(chat_id, message_id, disable_notification=True)
|
app.pin_chat_message(chat_id, message_id, disable_notification=True)
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.UpdatePinnedMessage(
|
raw.functions.messages.UpdatePinnedMessage(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
id=message_id,
|
id=message_id,
|
||||||
|
@ -57,7 +57,7 @@ class PromoteChatMember:
|
|||||||
chat_id = await self.resolve_peer(chat_id)
|
chat_id = await self.resolve_peer(chat_id)
|
||||||
user_id = await self.resolve_peer(user_id)
|
user_id = await self.resolve_peer(user_id)
|
||||||
|
|
||||||
raw_chat_member = (await self.send(
|
raw_chat_member = (await self.invoke(
|
||||||
raw.functions.channels.GetParticipant(
|
raw.functions.channels.GetParticipant(
|
||||||
channel=chat_id,
|
channel=chat_id,
|
||||||
participant=user_id
|
participant=user_id
|
||||||
@ -68,7 +68,7 @@ class PromoteChatMember:
|
|||||||
if isinstance(raw_chat_member, raw.types.ChannelParticipantAdmin):
|
if isinstance(raw_chat_member, raw.types.ChannelParticipantAdmin):
|
||||||
rank = raw_chat_member.rank
|
rank = raw_chat_member.rank
|
||||||
|
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.EditAdmin(
|
raw.functions.channels.EditAdmin(
|
||||||
channel=chat_id,
|
channel=chat_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
|
@ -72,7 +72,7 @@ class RestrictChatMember:
|
|||||||
# Chat member can only send text messages
|
# Chat member can only send text messages
|
||||||
app.restrict_chat_member(chat_id, user_id, ChatPermissions(can_send_messages=True))
|
app.restrict_chat_member(chat_id, user_id, ChatPermissions(can_send_messages=True))
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.EditBanned(
|
raw.functions.channels.EditBanned(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
participant=await self.resolve_peer(user_id),
|
participant=await self.resolve_peer(user_id),
|
||||||
|
@ -57,7 +57,7 @@ class SetAdministratorTitle:
|
|||||||
chat_id = await self.resolve_peer(chat_id)
|
chat_id = await self.resolve_peer(chat_id)
|
||||||
user_id = await self.resolve_peer(user_id)
|
user_id = await self.resolve_peer(user_id)
|
||||||
|
|
||||||
r = (await self.send(
|
r = (await self.invoke(
|
||||||
raw.functions.channels.GetParticipant(
|
raw.functions.channels.GetParticipant(
|
||||||
channel=chat_id,
|
channel=chat_id,
|
||||||
participant=user_id
|
participant=user_id
|
||||||
@ -71,7 +71,7 @@ class SetAdministratorTitle:
|
|||||||
else:
|
else:
|
||||||
raise ValueError("Custom titles can only be applied to owners or administrators of supergroups")
|
raise ValueError("Custom titles can only be applied to owners or administrators of supergroups")
|
||||||
|
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.EditAdmin(
|
raw.functions.channels.EditAdmin(
|
||||||
channel=chat_id,
|
channel=chat_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
|
@ -52,7 +52,7 @@ class SetChatDescription:
|
|||||||
peer = await self.resolve_peer(chat_id)
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if isinstance(peer, (raw.types.InputPeerChannel, raw.types.InputPeerChat)):
|
if isinstance(peer, (raw.types.InputPeerChannel, raw.types.InputPeerChat)):
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.EditChatAbout(
|
raw.functions.messages.EditChatAbout(
|
||||||
peer=peer,
|
peer=peer,
|
||||||
about=description
|
about=description
|
||||||
|
@ -62,7 +62,7 @@ class SetChatPermissions:
|
|||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.EditChatDefaultBannedRights(
|
raw.functions.messages.EditChatDefaultBannedRights(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
banned_rights=raw.types.ChatBannedRights(
|
banned_rights=raw.types.ChatBannedRights(
|
||||||
|
@ -100,14 +100,14 @@ class SetChatPhoto:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChat):
|
if isinstance(peer, raw.types.InputPeerChat):
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.EditChatPhoto(
|
raw.functions.messages.EditChatPhoto(
|
||||||
chat_id=peer.chat_id,
|
chat_id=peer.chat_id,
|
||||||
photo=photo,
|
photo=photo,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif isinstance(peer, raw.types.InputPeerChannel):
|
elif isinstance(peer, raw.types.InputPeerChannel):
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.EditPhoto(
|
raw.functions.channels.EditPhoto(
|
||||||
channel=peer,
|
channel=peer,
|
||||||
photo=photo
|
photo=photo
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.raw import functions
|
from pyrogram import raw
|
||||||
|
|
||||||
|
|
||||||
class SetChatProtectedContent:
|
class SetChatProtectedContent:
|
||||||
@ -41,8 +41,8 @@ class SetChatProtectedContent:
|
|||||||
``bool``: On success, True is returned.
|
``bool``: On success, True is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
await self.send(
|
await self.invoke(
|
||||||
functions.messages.ToggleNoForwards(
|
raw.functions.messages.ToggleNoForwards(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
enabled=enabled
|
enabled=enabled
|
||||||
)
|
)
|
||||||
|
@ -57,14 +57,14 @@ class SetChatTitle:
|
|||||||
peer = await self.resolve_peer(chat_id)
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChat):
|
if isinstance(peer, raw.types.InputPeerChat):
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.EditChatTitle(
|
raw.functions.messages.EditChatTitle(
|
||||||
chat_id=peer.chat_id,
|
chat_id=peer.chat_id,
|
||||||
title=title
|
title=title
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif isinstance(peer, raw.types.InputPeerChannel):
|
elif isinstance(peer, raw.types.InputPeerChannel):
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.EditTitle(
|
raw.functions.channels.EditTitle(
|
||||||
channel=peer,
|
channel=peer,
|
||||||
title=title
|
title=title
|
||||||
|
@ -55,7 +55,7 @@ class SetChatUsername:
|
|||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChannel):
|
if isinstance(peer, raw.types.InputPeerChannel):
|
||||||
return bool(
|
return bool(
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.UpdateUsername(
|
raw.functions.channels.UpdateUsername(
|
||||||
channel=peer,
|
channel=peer,
|
||||||
username=username or ""
|
username=username or ""
|
||||||
|
@ -47,7 +47,7 @@ class SetSendAsChat:
|
|||||||
|
|
||||||
app.set_send_as_chat(chat_id, send_as_chat_id)
|
app.set_send_as_chat(chat_id, send_as_chat_id)
|
||||||
"""
|
"""
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.messages.SaveDefaultSendAs(
|
raw.functions.messages.SaveDefaultSendAs(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
send_as=await self.resolve_peer(send_as_chat_id)
|
send_as=await self.resolve_peer(send_as_chat_id)
|
||||||
|
@ -51,7 +51,7 @@ class SetSlowMode:
|
|||||||
app.set_slow_mode(chat_id, None)
|
app.set_slow_mode(chat_id, None)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.ToggleSlowMode(
|
raw.functions.channels.ToggleSlowMode(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
seconds=seconds or 0
|
seconds=seconds or 0
|
||||||
|
@ -60,7 +60,7 @@ class UnarchiveChats:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.folders.EditPeerFolders(
|
raw.functions.folders.EditPeerFolders(
|
||||||
folder_peers=folder_peers
|
folder_peers=folder_peers
|
||||||
)
|
)
|
||||||
|
@ -49,7 +49,7 @@ class UnbanChatMember:
|
|||||||
# Unban chat member right now
|
# Unban chat member right now
|
||||||
app.unban_chat_member(chat_id, user_id)
|
app.unban_chat_member(chat_id, user_id)
|
||||||
"""
|
"""
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.channels.EditBanned(
|
raw.functions.channels.EditBanned(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
participant=await self.resolve_peer(user_id),
|
participant=await self.resolve_peer(user_id),
|
||||||
|
@ -44,7 +44,7 @@ class UnpinAllChatMessages:
|
|||||||
# Unpin all chat messages
|
# Unpin all chat messages
|
||||||
app.unpin_all_chat_messages(chat_id)
|
app.unpin_all_chat_messages(chat_id)
|
||||||
"""
|
"""
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.UnpinAllMessages(
|
raw.functions.messages.UnpinAllMessages(
|
||||||
peer=await self.resolve_peer(chat_id)
|
peer=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
|
@ -48,7 +48,7 @@ class UnpinChatMessage:
|
|||||||
|
|
||||||
app.unpin_chat_message(chat_id, message_id)
|
app.unpin_chat_message(chat_id, message_id)
|
||||||
"""
|
"""
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.UpdatePinnedMessage(
|
raw.functions.messages.UpdatePinnedMessage(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
id=message_id,
|
id=message_id,
|
||||||
|
@ -60,7 +60,7 @@ class AddContact:
|
|||||||
app.add_contact(12345678, "Foo")
|
app.add_contact(12345678, "Foo")
|
||||||
app.add_contact("username", "Bar")
|
app.add_contact("username", "Bar")
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.contacts.AddContact(
|
raw.functions.contacts.AddContact(
|
||||||
id=await self.resolve_peer(user_id),
|
id=await self.resolve_peer(user_id),
|
||||||
first_name=first_name,
|
first_name=first_name,
|
||||||
|
@ -50,7 +50,7 @@ class DeleteContacts:
|
|||||||
if not is_user_ids_list:
|
if not is_user_ids_list:
|
||||||
user_ids = [user_ids]
|
user_ids = [user_ids]
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.contacts.DeleteContacts(
|
raw.functions.contacts.DeleteContacts(
|
||||||
id=[await self.resolve_peer(i) for i in user_ids]
|
id=[await self.resolve_peer(i) for i in user_ids]
|
||||||
)
|
)
|
||||||
|
@ -41,5 +41,5 @@ class GetContacts:
|
|||||||
contacts = app.get_contacts()
|
contacts = app.get_contacts()
|
||||||
print(contacts)
|
print(contacts)
|
||||||
"""
|
"""
|
||||||
contacts = await self.send(raw.functions.contacts.GetContacts(hash=0))
|
contacts = await self.invoke(raw.functions.contacts.GetContacts(hash=0))
|
||||||
return types.List(types.User._parse(self, user) for user in contacts.users)
|
return types.List(types.User._parse(self, user) for user in contacts.users)
|
||||||
|
@ -36,4 +36,4 @@ class GetContactsCount:
|
|||||||
print(count)
|
print(count)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return len((await self.send(raw.functions.contacts.GetContacts(hash=0))).contacts)
|
return len((await self.invoke(raw.functions.contacts.GetContacts(hash=0))).contacts)
|
||||||
|
@ -47,7 +47,7 @@ class ImportContacts:
|
|||||||
InputPhoneContact("+1-456-789-0123", "Bar"),
|
InputPhoneContact("+1-456-789-0123", "Bar"),
|
||||||
InputPhoneContact("+1-789-012-3456", "Baz")])
|
InputPhoneContact("+1-789-012-3456", "Baz")])
|
||||||
"""
|
"""
|
||||||
imported_contacts = await self.send(
|
imported_contacts = await self.invoke(
|
||||||
raw.functions.contacts.ImportContacts(
|
raw.functions.contacts.ImportContacts(
|
||||||
contacts=contacts
|
contacts=contacts
|
||||||
)
|
)
|
||||||
|
@ -44,7 +44,7 @@ class ApproveChatJoinRequest:
|
|||||||
Returns:
|
Returns:
|
||||||
``bool``: True on success.
|
``bool``: True on success.
|
||||||
"""
|
"""
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.HideChatJoinRequest(
|
raw.functions.messages.HideChatJoinRequest(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
user_id=await self.resolve_peer(user_id),
|
user_id=await self.resolve_peer(user_id),
|
||||||
|
@ -72,7 +72,7 @@ class CreateChatInviteLink:
|
|||||||
# Create a new link for up to 7 new users
|
# Create a new link for up to 7 new users
|
||||||
link = app.create_chat_invite_link(chat_id, member_limit=7)
|
link = app.create_chat_invite_link(chat_id, member_limit=7)
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.ExportChatInvite(
|
raw.functions.messages.ExportChatInvite(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
expire_date=utils.datetime_to_timestamp(expire_date),
|
expire_date=utils.datetime_to_timestamp(expire_date),
|
||||||
|
@ -44,7 +44,7 @@ class DeclineChatJoinRequest:
|
|||||||
Returns:
|
Returns:
|
||||||
``bool``: True on success.
|
``bool``: True on success.
|
||||||
"""
|
"""
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.HideChatJoinRequest(
|
raw.functions.messages.HideChatJoinRequest(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
user_id=await self.resolve_peer(user_id),
|
user_id=await self.resolve_peer(user_id),
|
||||||
|
@ -44,7 +44,7 @@ class DeleteChatAdminInviteLinks:
|
|||||||
``bool``: On success ``True`` is returned.
|
``bool``: On success ``True`` is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.messages.DeleteRevokedExportedChatInvites(
|
raw.functions.messages.DeleteRevokedExportedChatInvites(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
admin_id=await self.resolve_peer(admin_id),
|
admin_id=await self.resolve_peer(admin_id),
|
||||||
|
@ -42,7 +42,7 @@ class DeleteChatInviteLink:
|
|||||||
``bool``: On success ``True`` is returned.
|
``bool``: On success ``True`` is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return await self.send(
|
return await self.invoke(
|
||||||
raw.functions.messages.DeleteExportedChatInvite(
|
raw.functions.messages.DeleteExportedChatInvite(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
link=invite_link,
|
link=invite_link,
|
||||||
|
@ -74,7 +74,7 @@ class EditChatInviteLink:
|
|||||||
# Set no expiration date of a link
|
# Set no expiration date of a link
|
||||||
link = app.edit_chat_invite_link(chat_id, invite_link, expire_date=0)
|
link = app.edit_chat_invite_link(chat_id, invite_link, expire_date=0)
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.EditExportedChatInvite(
|
raw.functions.messages.EditExportedChatInvite(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
link=invite_link,
|
link=invite_link,
|
||||||
|
@ -53,7 +53,7 @@ class ExportChatInviteLink:
|
|||||||
# Generate a new primary link
|
# Generate a new primary link
|
||||||
link = app.export_chat_invite_link(chat_id)
|
link = app.export_chat_invite_link(chat_id)
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.ExportChatInvite(
|
raw.functions.messages.ExportChatInvite(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
legacy_revoke_permanent=True
|
legacy_revoke_permanent=True
|
||||||
|
@ -70,7 +70,7 @@ class GetChatAdminInviteLinks:
|
|||||||
offset_link = None
|
offset_link = None
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetExportedChatInvites(
|
raw.functions.messages.GetExportedChatInvites(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
admin_id=await self.resolve_peer(admin_id),
|
admin_id=await self.resolve_peer(admin_id),
|
||||||
|
@ -48,7 +48,7 @@ class GetChatAdminInviteLinksCount:
|
|||||||
Returns:
|
Returns:
|
||||||
``int``: On success, the invite links count is returned.
|
``int``: On success, the invite links count is returned.
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetExportedChatInvites(
|
raw.functions.messages.GetExportedChatInvites(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
admin_id=await self.resolve_peer(admin_id),
|
admin_id=await self.resolve_peer(admin_id),
|
||||||
|
@ -40,7 +40,7 @@ class GetChatAdminsWithInviteLinks:
|
|||||||
List of :obj:`~pyrogram.types.ChatAdminWithInviteLink`: On success, the list of admins that have exported
|
List of :obj:`~pyrogram.types.ChatAdminWithInviteLink`: On success, the list of admins that have exported
|
||||||
invite links is returned.
|
invite links is returned.
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetAdminsWithInvites(
|
raw.functions.messages.GetAdminsWithInvites(
|
||||||
peer=await self.resolve_peer(chat_id)
|
peer=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
|
@ -42,7 +42,7 @@ class GetChatInviteLink:
|
|||||||
Returns:
|
Returns:
|
||||||
:obj:`~pyrogram.types.ChatInviteLink`: On success, the invite link is returned.
|
:obj:`~pyrogram.types.ChatInviteLink`: On success, the invite link is returned.
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetExportedChatInvite(
|
raw.functions.messages.GetExportedChatInvite(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
link=invite_link
|
link=invite_link
|
||||||
|
@ -58,7 +58,7 @@ class GetChatInviteLinkMembers:
|
|||||||
offset_user = raw.types.InputUserEmpty()
|
offset_user = raw.types.InputUserEmpty()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetChatInviteImporters(
|
raw.functions.messages.GetChatInviteImporters(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
link=invite_link,
|
link=invite_link,
|
||||||
|
@ -41,7 +41,7 @@ class GetChatInviteLinkMembersCount:
|
|||||||
Returns:
|
Returns:
|
||||||
``int``: On success, the joined chat members count is returned.
|
``int``: On success, the joined chat members count is returned.
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetChatInviteImporters(
|
raw.functions.messages.GetChatInviteImporters(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
link=invite_link,
|
link=invite_link,
|
||||||
|
@ -47,7 +47,7 @@ class RevokeChatInviteLink:
|
|||||||
:obj:`~pyrogram.types.ChatInviteLink`: On success, the invite link object is returned.
|
:obj:`~pyrogram.types.ChatInviteLink`: On success, the invite link object is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.EditExportedChatInvite(
|
raw.functions.messages.EditExportedChatInvite(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
link=invite_link,
|
link=invite_link,
|
||||||
|
@ -109,7 +109,7 @@ class CopyMediaGroup:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.SendMultiMedia(
|
raw.functions.messages.SendMultiMedia(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
multi_media=multi_media,
|
multi_media=multi_media,
|
||||||
|
@ -66,14 +66,14 @@ class DeleteMessages:
|
|||||||
message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids]
|
message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids]
|
||||||
|
|
||||||
if isinstance(peer, raw.types.InputPeerChannel):
|
if isinstance(peer, raw.types.InputPeerChannel):
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.channels.DeleteMessages(
|
raw.functions.channels.DeleteMessages(
|
||||||
channel=peer,
|
channel=peer,
|
||||||
id=message_ids
|
id=message_ids
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.DeleteMessages(
|
raw.functions.messages.DeleteMessages(
|
||||||
id=message_ids,
|
id=message_ids,
|
||||||
revoke=revoke or None
|
revoke=revoke or None
|
||||||
|
@ -179,7 +179,7 @@ class EditInlineMedia:
|
|||||||
|
|
||||||
session = await get_session(self, dc_id)
|
session = await get_session(self, dc_id)
|
||||||
|
|
||||||
return await session.send(
|
return await session.invoke(
|
||||||
raw.functions.messages.EditInlineBotMessage(
|
raw.functions.messages.EditInlineBotMessage(
|
||||||
id=unpacked,
|
id=unpacked,
|
||||||
media=media,
|
media=media,
|
||||||
|
@ -58,7 +58,7 @@ class EditInlineReplyMarkup:
|
|||||||
|
|
||||||
session = await get_session(self, dc_id)
|
session = await get_session(self, dc_id)
|
||||||
|
|
||||||
return await session.send(
|
return await session.invoke(
|
||||||
raw.functions.messages.EditInlineBotMessage(
|
raw.functions.messages.EditInlineBotMessage(
|
||||||
id=unpacked,
|
id=unpacked,
|
||||||
reply_markup=await reply_markup.write(self) if reply_markup else None,
|
reply_markup=await reply_markup.write(self) if reply_markup else None,
|
||||||
|
@ -75,7 +75,7 @@ class EditInlineText:
|
|||||||
|
|
||||||
session = await get_session(self, dc_id)
|
session = await get_session(self, dc_id)
|
||||||
|
|
||||||
return await session.send(
|
return await session.invoke(
|
||||||
raw.functions.messages.EditInlineBotMessage(
|
raw.functions.messages.EditInlineBotMessage(
|
||||||
id=unpacked,
|
id=unpacked,
|
||||||
no_webpage=disable_web_page_preview or None,
|
no_webpage=disable_web_page_preview or None,
|
||||||
|
@ -87,7 +87,7 @@ class EditMessageMedia:
|
|||||||
|
|
||||||
if isinstance(media, types.InputMediaPhoto):
|
if isinstance(media, types.InputMediaPhoto):
|
||||||
if os.path.isfile(media.media):
|
if os.path.isfile(media.media):
|
||||||
media = await self.send(
|
media = await self.invoke(
|
||||||
raw.functions.messages.UploadMedia(
|
raw.functions.messages.UploadMedia(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
media=raw.types.InputMediaUploadedPhoto(
|
media=raw.types.InputMediaUploadedPhoto(
|
||||||
@ -111,7 +111,7 @@ class EditMessageMedia:
|
|||||||
media = utils.get_input_media_from_file_id(media.media, FileType.PHOTO)
|
media = utils.get_input_media_from_file_id(media.media, FileType.PHOTO)
|
||||||
elif isinstance(media, types.InputMediaVideo):
|
elif isinstance(media, types.InputMediaVideo):
|
||||||
if os.path.isfile(media.media):
|
if os.path.isfile(media.media):
|
||||||
media = await self.send(
|
media = await self.invoke(
|
||||||
raw.functions.messages.UploadMedia(
|
raw.functions.messages.UploadMedia(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
media=raw.types.InputMediaUploadedDocument(
|
media=raw.types.InputMediaUploadedDocument(
|
||||||
@ -148,7 +148,7 @@ class EditMessageMedia:
|
|||||||
media = utils.get_input_media_from_file_id(media.media, FileType.VIDEO)
|
media = utils.get_input_media_from_file_id(media.media, FileType.VIDEO)
|
||||||
elif isinstance(media, types.InputMediaAudio):
|
elif isinstance(media, types.InputMediaAudio):
|
||||||
if os.path.isfile(media.media):
|
if os.path.isfile(media.media):
|
||||||
media = await self.send(
|
media = await self.invoke(
|
||||||
raw.functions.messages.UploadMedia(
|
raw.functions.messages.UploadMedia(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
media=raw.types.InputMediaUploadedDocument(
|
media=raw.types.InputMediaUploadedDocument(
|
||||||
@ -184,7 +184,7 @@ class EditMessageMedia:
|
|||||||
media = utils.get_input_media_from_file_id(media.media, FileType.AUDIO)
|
media = utils.get_input_media_from_file_id(media.media, FileType.AUDIO)
|
||||||
elif isinstance(media, types.InputMediaAnimation):
|
elif isinstance(media, types.InputMediaAnimation):
|
||||||
if os.path.isfile(media.media):
|
if os.path.isfile(media.media):
|
||||||
media = await self.send(
|
media = await self.invoke(
|
||||||
raw.functions.messages.UploadMedia(
|
raw.functions.messages.UploadMedia(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
media=raw.types.InputMediaUploadedDocument(
|
media=raw.types.InputMediaUploadedDocument(
|
||||||
@ -222,7 +222,7 @@ class EditMessageMedia:
|
|||||||
media = utils.get_input_media_from_file_id(media.media, FileType.ANIMATION)
|
media = utils.get_input_media_from_file_id(media.media, FileType.ANIMATION)
|
||||||
elif isinstance(media, types.InputMediaDocument):
|
elif isinstance(media, types.InputMediaDocument):
|
||||||
if os.path.isfile(media.media):
|
if os.path.isfile(media.media):
|
||||||
media = await self.send(
|
media = await self.invoke(
|
||||||
raw.functions.messages.UploadMedia(
|
raw.functions.messages.UploadMedia(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
media=raw.types.InputMediaUploadedDocument(
|
media=raw.types.InputMediaUploadedDocument(
|
||||||
@ -252,7 +252,7 @@ class EditMessageMedia:
|
|||||||
else:
|
else:
|
||||||
media = utils.get_input_media_from_file_id(media.media, FileType.DOCUMENT)
|
media = utils.get_input_media_from_file_id(media.media, FileType.DOCUMENT)
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.EditMessage(
|
raw.functions.messages.EditMessage(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
id=message_id,
|
id=message_id,
|
||||||
|
@ -58,7 +58,7 @@ class EditMessageReplyMarkup:
|
|||||||
InlineKeyboardMarkup([[
|
InlineKeyboardMarkup([[
|
||||||
InlineKeyboardButton("New button", callback_data="new_data")]]))
|
InlineKeyboardButton("New button", callback_data="new_data")]]))
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.EditMessage(
|
raw.functions.messages.EditMessage(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
id=message_id,
|
id=message_id,
|
||||||
|
@ -77,7 +77,7 @@ class EditMessageText:
|
|||||||
disable_web_page_preview=True)
|
disable_web_page_preview=True)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.EditMessage(
|
raw.functions.messages.EditMessage(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
id=message_id,
|
id=message_id,
|
||||||
|
@ -79,7 +79,7 @@ class ForwardMessages:
|
|||||||
is_iterable = not isinstance(message_ids, int)
|
is_iterable = not isinstance(message_ids, int)
|
||||||
message_ids = list(message_ids) if is_iterable else [message_ids]
|
message_ids = list(message_ids) if is_iterable else [message_ids]
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.ForwardMessages(
|
raw.functions.messages.ForwardMessages(
|
||||||
to_peer=await self.resolve_peer(chat_id),
|
to_peer=await self.resolve_peer(chat_id),
|
||||||
from_peer=await self.resolve_peer(from_chat_id),
|
from_peer=await self.resolve_peer(from_chat_id),
|
||||||
|
@ -49,7 +49,7 @@ class GetDiscussionMessage:
|
|||||||
# Comment to the post by replying
|
# Comment to the post by replying
|
||||||
m.reply("comment")
|
m.reply("comment")
|
||||||
"""
|
"""
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetDiscussionMessage(
|
raw.functions.messages.GetDiscussionMessage(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
msg_id=message_id
|
msg_id=message_id
|
||||||
|
@ -86,7 +86,7 @@ class GetHistory:
|
|||||||
|
|
||||||
messages = await utils.parse_messages(
|
messages = await utils.parse_messages(
|
||||||
self,
|
self,
|
||||||
await self.send(
|
await self.invoke(
|
||||||
raw.functions.messages.GetHistory(
|
raw.functions.messages.GetHistory(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
offset_id=offset_id,
|
offset_id=offset_id,
|
||||||
|
@ -51,7 +51,7 @@ class GetHistoryCount:
|
|||||||
app.get_history_count(chat_id)
|
app.get_history_count(chat_id)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
r = await self.send(
|
r = await self.invoke(
|
||||||
raw.functions.messages.GetHistory(
|
raw.functions.messages.GetHistory(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
offset_id=0,
|
offset_id=0,
|
||||||
|
@ -111,7 +111,7 @@ class GetMessages:
|
|||||||
else:
|
else:
|
||||||
rpc = raw.functions.messages.GetMessages(id=ids)
|
rpc = raw.functions.messages.GetMessages(id=ids)
|
||||||
|
|
||||||
r = await self.send(rpc, sleep_threshold=-1)
|
r = await self.invoke(rpc, sleep_threshold=-1)
|
||||||
|
|
||||||
messages = await utils.parse_messages(self, r, replies=replies)
|
messages = await utils.parse_messages(self, r, replies=replies)
|
||||||
|
|
||||||
|
@ -40,14 +40,14 @@ async def get_session(client: "pyrogram.Client", dc_id: int):
|
|||||||
await session.start()
|
await session.start()
|
||||||
|
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
exported_auth = await client.send(
|
exported_auth = await client.invoke(
|
||||||
raw.functions.auth.ExportAuthorization(
|
raw.functions.auth.ExportAuthorization(
|
||||||
dc_id=dc_id
|
dc_id=dc_id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await session.send(
|
await session.invoke(
|
||||||
raw.functions.auth.ImportAuthorization(
|
raw.functions.auth.ImportAuthorization(
|
||||||
id=exported_auth.id,
|
id=exported_auth.id,
|
||||||
bytes=exported_auth.bytes
|
bytes=exported_auth.bytes
|
||||||
|
@ -66,6 +66,6 @@ class ReadHistory:
|
|||||||
max_id=max_id
|
max_id=max_id
|
||||||
)
|
)
|
||||||
|
|
||||||
await self.send(q)
|
await self.invoke(q)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user