2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Merge develop -> asyncio

This commit is contained in:
Dan 2019-09-09 16:00:38 +02:00
commit b10817ec29
10 changed files with 21 additions and 29 deletions

View File

@ -184,6 +184,7 @@ def pyrogram_api():
unban_chat_member
restrict_chat_member
promote_chat_member
set_administrator_title
export_chat_invite_link
set_chat_photo
delete_chat_photo

View File

@ -1433,10 +1433,7 @@ class Client(Methods, BaseClient):
self.api_id = parser.getint("pyrogram", "api_id")
self.api_hash = parser.get("pyrogram", "api_hash")
else:
raise AttributeError(
"No API Key found. "
"More info: https://docs.pyrogram.org/intro/setup#configuration"
)
raise AttributeError("No API Key found. More info: https://docs.pyrogram.org/intro/setup")
for option in ["app_version", "device_model", "system_version", "lang_code"]:
if getattr(self, option):

View File

@ -40,11 +40,11 @@ from .leave_chat import LeaveChat
from .pin_chat_message import PinChatMessage
from .promote_chat_member import PromoteChatMember
from .restrict_chat_member import RestrictChatMember
from .set_administrator_title import SetAdministratorTitle
from .set_chat_description import SetChatDescription
from .set_chat_permissions import SetChatPermissions
from .set_chat_photo import SetChatPhoto
from .set_chat_title import SetChatTitle
from .set_custom_title import SetCustomTitle
from .unarchive_chats import UnarchiveChats
from .unban_chat_member import UnbanChatMember
from .unpin_chat_message import UnpinChatMessage
@ -84,6 +84,6 @@ class Chats(
DeleteChannel,
DeleteSupergroup,
GetNearbyChats,
SetCustomTitle
SetAdministratorTitle
):
pass

View File

@ -30,7 +30,7 @@ class CreateChannel(BaseClient):
"""Create a new broadcast channel.
Parameters:
title (``title``):
title (``str``):
The channel title.
description (``str``, *optional*):

View File

@ -36,7 +36,7 @@ class CreateGroup(BaseClient):
If you want to create a new supergroup, use :meth:`~pyrogram.Client.create_supergroup` instead.
Parameters:
title (``title``):
title (``str``):
The group title.
users (``int`` | ``str`` | List of ``int`` or ``str``):

View File

@ -34,7 +34,7 @@ class CreateSupergroup(BaseClient):
If you want to create a new basic group, use :meth:`~pyrogram.Client.create_group` instead.
Parameters:
title (``title``):
title (``str``):
The supergroup title.
description (``str``, *optional*):

View File

@ -18,9 +18,9 @@
from typing import Generator, Optional
import pyrogram
from async_generator import async_generator, yield_
import pyrogram
from ...ext import BaseClient
@ -38,7 +38,7 @@ class IterDialogs(BaseClient):
single call.
Parameters:
limit (``str``, *optional*):
limit (``int``, *optional*):
Limits the number of dialogs to be retrieved.
By default, no limit is applied and all dialogs are returned.

View File

@ -58,20 +58,9 @@ class JoinChat(BaseClient):
elif isinstance(chat.chats[0], types.Channel):
return pyrogram.Chat._parse_channel_chat(self, chat.chats[0])
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(
functions.channels.JoinChannel(
channel=channel
channel=await self.resolve_peer(chat_id)
)
)

View File

@ -22,14 +22,17 @@ from pyrogram.api import functions, types
from ...ext import BaseClient
class SetCustomTitle(BaseClient):
async def set_custom_title(
class SetAdministratorTitle(BaseClient):
async def set_administrator_title(
self,
chat_id: Union[int, str],
user_id: Union[int, str],
title: str,
) -> 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:
chat_id (``int`` | ``str``):
@ -49,8 +52,7 @@ class SetCustomTitle(BaseClient):
Example:
.. code-block:: python
# Set custom titles to owners or administrators of supergroups
app.set_custom_title(chat_id, user_id, "Custom Title")
app.set_administrator_title(chat_id, user_id, "ฅ^•ﻌ•^ฅ")
"""
chat_id = await self.resolve_peer(chat_id)
user_id = await self.resolve_peer(user_id)

View File

@ -108,7 +108,10 @@ class FileStorage(MemoryStorage):
self.create()
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):
os.remove(self.database)