mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Add missing awaits
This commit is contained in:
parent
353811ebd3
commit
8e9a7a33bd
@ -23,7 +23,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class AddChatMembers(BaseClient):
|
class AddChatMembers(BaseClient):
|
||||||
def add_chat_members(
|
async def add_chat_members(
|
||||||
self,
|
self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
user_ids: Union[Union[int, str], List[Union[int, str]]],
|
user_ids: Union[Union[int, str], List[Union[int, str]]],
|
||||||
@ -60,26 +60,26 @@ class AddChatMembers(BaseClient):
|
|||||||
# Change forward_limit (for basic groups only)
|
# Change forward_limit (for basic groups only)
|
||||||
app.add_chat_members(chat_id, user_id, forward_limit=25)
|
app.add_chat_members(chat_id, user_id, forward_limit=25)
|
||||||
"""
|
"""
|
||||||
peer = self.resolve_peer(chat_id)
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if not isinstance(user_ids, list):
|
if not isinstance(user_ids, list):
|
||||||
user_ids = [user_ids]
|
user_ids = [user_ids]
|
||||||
|
|
||||||
if isinstance(peer, types.InputPeerChat):
|
if isinstance(peer, types.InputPeerChat):
|
||||||
for user_id in user_ids:
|
for user_id in user_ids:
|
||||||
self.send(
|
await self.send(
|
||||||
functions.messages.AddChatUser(
|
functions.messages.AddChatUser(
|
||||||
chat_id=peer.chat_id,
|
chat_id=peer.chat_id,
|
||||||
user_id=self.resolve_peer(user_id),
|
user_id=await self.resolve_peer(user_id),
|
||||||
fwd_limit=forward_limit
|
fwd_limit=forward_limit
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.send(
|
await self.send(
|
||||||
functions.channels.InviteToChannel(
|
functions.channels.InviteToChannel(
|
||||||
channel=peer,
|
channel=peer,
|
||||||
users=[
|
users=[
|
||||||
self.resolve_peer(user_id)
|
await self.resolve_peer(user_id)
|
||||||
for user_id in user_ids
|
for user_id in user_ids
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class CreateChannel(BaseClient):
|
class CreateChannel(BaseClient):
|
||||||
def create_channel(
|
async def create_channel(
|
||||||
self,
|
self,
|
||||||
title: str,
|
title: str,
|
||||||
description: str = ""
|
description: str = ""
|
||||||
@ -44,7 +44,7 @@ class CreateChannel(BaseClient):
|
|||||||
|
|
||||||
app.create_channel("Channel Title", "Channel Description")
|
app.create_channel("Channel Title", "Channel Description")
|
||||||
"""
|
"""
|
||||||
r = self.send(
|
r = await self.send(
|
||||||
functions.channels.CreateChannel(
|
functions.channels.CreateChannel(
|
||||||
title=title,
|
title=title,
|
||||||
about=description,
|
about=description,
|
||||||
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class CreateGroup(BaseClient):
|
class CreateGroup(BaseClient):
|
||||||
def create_group(
|
async def create_group(
|
||||||
self,
|
self,
|
||||||
title: str,
|
title: str,
|
||||||
users: Union[Union[int, str], List[Union[int, str]]]
|
users: Union[Union[int, str], List[Union[int, str]]]
|
||||||
@ -55,10 +55,10 @@ class CreateGroup(BaseClient):
|
|||||||
if not isinstance(users, list):
|
if not isinstance(users, list):
|
||||||
users = [users]
|
users = [users]
|
||||||
|
|
||||||
r = self.send(
|
r = await self.send(
|
||||||
functions.messages.CreateChat(
|
functions.messages.CreateChat(
|
||||||
title=title,
|
title=title,
|
||||||
users=[self.resolve_peer(u) for u in users]
|
users=[await self.resolve_peer(u) for u in users]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class CreateSupergroup(BaseClient):
|
class CreateSupergroup(BaseClient):
|
||||||
def create_supergroup(
|
async def create_supergroup(
|
||||||
self,
|
self,
|
||||||
title: str,
|
title: str,
|
||||||
description: str = ""
|
description: str = ""
|
||||||
@ -48,7 +48,7 @@ class CreateSupergroup(BaseClient):
|
|||||||
|
|
||||||
app.create_supergroup("Supergroup Title", "Supergroup Description")
|
app.create_supergroup("Supergroup Title", "Supergroup Description")
|
||||||
"""
|
"""
|
||||||
r = self.send(
|
r = await self.send(
|
||||||
functions.channels.CreateChannel(
|
functions.channels.CreateChannel(
|
||||||
title=title,
|
title=title,
|
||||||
about=description,
|
about=description,
|
||||||
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class DeleteChannel(BaseClient):
|
class DeleteChannel(BaseClient):
|
||||||
def delete_channel(self, chat_id: Union[int, str]) -> bool:
|
async def delete_channel(self, chat_id: Union[int, str]) -> bool:
|
||||||
"""Delete a channel.
|
"""Delete a channel.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
@ -39,9 +39,9 @@ class DeleteChannel(BaseClient):
|
|||||||
|
|
||||||
app.delete_channel(channel_id)
|
app.delete_channel(channel_id)
|
||||||
"""
|
"""
|
||||||
self.send(
|
await self.send(
|
||||||
functions.channels.DeleteChannel(
|
functions.channels.DeleteChannel(
|
||||||
channel=self.resolve_peer(chat_id)
|
channel=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class DeleteSupergroup(BaseClient):
|
class DeleteSupergroup(BaseClient):
|
||||||
def delete_supergroup(self, chat_id: Union[int, str]) -> bool:
|
async def delete_supergroup(self, chat_id: Union[int, str]) -> bool:
|
||||||
"""Delete a supergroup.
|
"""Delete a supergroup.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
@ -39,9 +39,9 @@ class DeleteSupergroup(BaseClient):
|
|||||||
|
|
||||||
app.delete_supergroup(supergroup_id)
|
app.delete_supergroup(supergroup_id)
|
||||||
"""
|
"""
|
||||||
self.send(
|
await self.send(
|
||||||
functions.channels.DeleteChannel(
|
functions.channels.DeleteChannel(
|
||||||
channel=self.resolve_peer(chat_id)
|
channel=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class SetChatPermissions(BaseClient):
|
|||||||
|
|
||||||
r = await self.send(
|
r = await self.send(
|
||||||
functions.messages.EditChatDefaultBannedRights(
|
functions.messages.EditChatDefaultBannedRights(
|
||||||
peer=self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
banned_rights=types.ChatBannedRights(
|
banned_rights=types.ChatBannedRights(
|
||||||
until_date=0,
|
until_date=0,
|
||||||
send_messages=send_messages,
|
send_messages=send_messages,
|
||||||
|
@ -24,7 +24,7 @@ from pyrogram.client.ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class SendPoll(BaseClient):
|
class SendPoll(BaseClient):
|
||||||
def send_poll(
|
async def send_poll(
|
||||||
self,
|
self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
question: str,
|
question: str,
|
||||||
@ -75,9 +75,9 @@ class SendPoll(BaseClient):
|
|||||||
|
|
||||||
app.send_poll(chat_id, "Is this a poll question?", ["Yes", "No", "Maybe"])
|
app.send_poll(chat_id, "Is this a poll question?", ["Yes", "No", "Maybe"])
|
||||||
"""
|
"""
|
||||||
r = self.send(
|
r = await self.send(
|
||||||
functions.messages.SendMedia(
|
functions.messages.SendMedia(
|
||||||
peer=self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
media=types.InputMediaPoll(
|
media=types.InputMediaPoll(
|
||||||
poll=types.Poll(
|
poll=types.Poll(
|
||||||
id=0,
|
id=0,
|
||||||
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class GetCommonChats(BaseClient):
|
class GetCommonChats(BaseClient):
|
||||||
def get_common_chats(self, user_id: Union[int, str]) -> list:
|
async def get_common_chats(self, user_id: Union[int, str]) -> list:
|
||||||
"""Get the common chats you have with a user.
|
"""Get the common chats you have with a user.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
@ -46,10 +46,10 @@ class GetCommonChats(BaseClient):
|
|||||||
print(common)
|
print(common)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
peer = self.resolve_peer(user_id)
|
peer = await self.resolve_peer(user_id)
|
||||||
|
|
||||||
if isinstance(peer, types.InputPeerUser):
|
if isinstance(peer, types.InputPeerUser):
|
||||||
r = self.send(
|
r = await self.send(
|
||||||
functions.messages.GetCommonChats(
|
functions.messages.GetCommonChats(
|
||||||
user_id=peer,
|
user_id=peer,
|
||||||
max_id=0,
|
max_id=0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user