mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-03 07:45:14 +00:00
Merge develop -> asyncio
This commit is contained in:
@@ -184,6 +184,7 @@ def pyrogram_api():
|
|||||||
unban_chat_member
|
unban_chat_member
|
||||||
restrict_chat_member
|
restrict_chat_member
|
||||||
promote_chat_member
|
promote_chat_member
|
||||||
|
set_administrator_title
|
||||||
export_chat_invite_link
|
export_chat_invite_link
|
||||||
set_chat_photo
|
set_chat_photo
|
||||||
delete_chat_photo
|
delete_chat_photo
|
||||||
|
@@ -1433,10 +1433,7 @@ class Client(Methods, BaseClient):
|
|||||||
self.api_id = parser.getint("pyrogram", "api_id")
|
self.api_id = parser.getint("pyrogram", "api_id")
|
||||||
self.api_hash = parser.get("pyrogram", "api_hash")
|
self.api_hash = parser.get("pyrogram", "api_hash")
|
||||||
else:
|
else:
|
||||||
raise AttributeError(
|
raise AttributeError("No API Key found. More info: https://docs.pyrogram.org/intro/setup")
|
||||||
"No API Key found. "
|
|
||||||
"More info: https://docs.pyrogram.org/intro/setup#configuration"
|
|
||||||
)
|
|
||||||
|
|
||||||
for option in ["app_version", "device_model", "system_version", "lang_code"]:
|
for option in ["app_version", "device_model", "system_version", "lang_code"]:
|
||||||
if getattr(self, option):
|
if getattr(self, option):
|
||||||
|
@@ -40,11 +40,11 @@ from .leave_chat import LeaveChat
|
|||||||
from .pin_chat_message import PinChatMessage
|
from .pin_chat_message import PinChatMessage
|
||||||
from .promote_chat_member import PromoteChatMember
|
from .promote_chat_member import PromoteChatMember
|
||||||
from .restrict_chat_member import RestrictChatMember
|
from .restrict_chat_member import RestrictChatMember
|
||||||
|
from .set_administrator_title import SetAdministratorTitle
|
||||||
from .set_chat_description import SetChatDescription
|
from .set_chat_description import SetChatDescription
|
||||||
from .set_chat_permissions import SetChatPermissions
|
from .set_chat_permissions import SetChatPermissions
|
||||||
from .set_chat_photo import SetChatPhoto
|
from .set_chat_photo import SetChatPhoto
|
||||||
from .set_chat_title import SetChatTitle
|
from .set_chat_title import SetChatTitle
|
||||||
from .set_custom_title import SetCustomTitle
|
|
||||||
from .unarchive_chats import UnarchiveChats
|
from .unarchive_chats import UnarchiveChats
|
||||||
from .unban_chat_member import UnbanChatMember
|
from .unban_chat_member import UnbanChatMember
|
||||||
from .unpin_chat_message import UnpinChatMessage
|
from .unpin_chat_message import UnpinChatMessage
|
||||||
@@ -84,6 +84,6 @@ class Chats(
|
|||||||
DeleteChannel,
|
DeleteChannel,
|
||||||
DeleteSupergroup,
|
DeleteSupergroup,
|
||||||
GetNearbyChats,
|
GetNearbyChats,
|
||||||
SetCustomTitle
|
SetAdministratorTitle
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
@@ -30,7 +30,7 @@ class CreateChannel(BaseClient):
|
|||||||
"""Create a new broadcast channel.
|
"""Create a new broadcast channel.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
title (``title``):
|
title (``str``):
|
||||||
The channel title.
|
The channel title.
|
||||||
|
|
||||||
description (``str``, *optional*):
|
description (``str``, *optional*):
|
||||||
|
@@ -36,7 +36,7 @@ class CreateGroup(BaseClient):
|
|||||||
If you want to create a new supergroup, use :meth:`~pyrogram.Client.create_supergroup` instead.
|
If you want to create a new supergroup, use :meth:`~pyrogram.Client.create_supergroup` instead.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
title (``title``):
|
title (``str``):
|
||||||
The group title.
|
The group title.
|
||||||
|
|
||||||
users (``int`` | ``str`` | List of ``int`` or ``str``):
|
users (``int`` | ``str`` | List of ``int`` or ``str``):
|
||||||
|
@@ -34,7 +34,7 @@ class CreateSupergroup(BaseClient):
|
|||||||
If you want to create a new basic group, use :meth:`~pyrogram.Client.create_group` instead.
|
If you want to create a new basic group, use :meth:`~pyrogram.Client.create_group` instead.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
title (``title``):
|
title (``str``):
|
||||||
The supergroup title.
|
The supergroup title.
|
||||||
|
|
||||||
description (``str``, *optional*):
|
description (``str``, *optional*):
|
||||||
|
@@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
from typing import Generator, Optional
|
from typing import Generator, Optional
|
||||||
|
|
||||||
import pyrogram
|
|
||||||
from async_generator import async_generator, yield_
|
from async_generator import async_generator, yield_
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from ...ext import BaseClient
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ class IterDialogs(BaseClient):
|
|||||||
single call.
|
single call.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
limit (``str``, *optional*):
|
limit (``int``, *optional*):
|
||||||
Limits the number of dialogs to be retrieved.
|
Limits the number of dialogs to be retrieved.
|
||||||
By default, no limit is applied and all dialogs are returned.
|
By default, no limit is applied and all dialogs are returned.
|
||||||
|
|
||||||
|
@@ -58,20 +58,9 @@ class JoinChat(BaseClient):
|
|||||||
elif isinstance(chat.chats[0], types.Channel):
|
elif isinstance(chat.chats[0], types.Channel):
|
||||||
return pyrogram.Chat._parse_channel_chat(self, chat.chats[0])
|
return pyrogram.Chat._parse_channel_chat(self, chat.chats[0])
|
||||||
else:
|
else:
|
||||||
resolved_peer = await self.send(
|
|
||||||
functions.contacts.ResolveUsername(
|
|
||||||
username=chat_id.lower().strip("@")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
channel = types.InputPeerChannel(
|
|
||||||
channel_id=resolved_peer.chats[0].id,
|
|
||||||
access_hash=resolved_peer.chats[0].access_hash
|
|
||||||
)
|
|
||||||
|
|
||||||
chat = await self.send(
|
chat = await self.send(
|
||||||
functions.channels.JoinChannel(
|
functions.channels.JoinChannel(
|
||||||
channel=channel
|
channel=await self.resolve_peer(chat_id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -22,14 +22,17 @@ from pyrogram.api import functions, types
|
|||||||
from ...ext import BaseClient
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class SetCustomTitle(BaseClient):
|
class SetAdministratorTitle(BaseClient):
|
||||||
async def set_custom_title(
|
async def set_administrator_title(
|
||||||
self,
|
self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
user_id: Union[int, str],
|
user_id: Union[int, str],
|
||||||
title: str,
|
title: str,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Set a custom title to administrators or owners of a supergroup.
|
"""Set a custom title (rank) to an administrator of a supergroup.
|
||||||
|
|
||||||
|
If you are an administrator of a supergroup (i.e. not the owner), you can only set the title of other
|
||||||
|
administrators who have been promoted by you. If you are the owner, you can change every administrator's title.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
chat_id (``int`` | ``str``):
|
chat_id (``int`` | ``str``):
|
||||||
@@ -49,8 +52,7 @@ class SetCustomTitle(BaseClient):
|
|||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# Set custom titles to owners or administrators of supergroups
|
app.set_administrator_title(chat_id, user_id, "ฅ^•ﻌ•^ฅ")
|
||||||
app.set_custom_title(chat_id, user_id, "Custom Title")
|
|
||||||
"""
|
"""
|
||||||
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)
|
@@ -108,7 +108,10 @@ class FileStorage(MemoryStorage):
|
|||||||
self.create()
|
self.create()
|
||||||
|
|
||||||
with self.conn:
|
with self.conn:
|
||||||
self.conn.execute("VACUUM")
|
try: # Python 3.6.0 (exactly this version) is bugged and won't successfully execute the vacuum
|
||||||
|
self.conn.execute("VACUUM")
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
pass
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
os.remove(self.database)
|
os.remove(self.database)
|
||||||
|
Reference in New Issue
Block a user