Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/api/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
SECTION_RE = re.compile(r"---(\w+)---")
LAYER_RE = re.compile(r"//\sLAYER\s(\d+)")
COMBINATOR_RE = re.compile(r"^([\w.]+)#([0-9a-f]+)\s(?:.*)=\s([\w<>.]+);(?: // Docs: (.+))?$", re.MULTILINE)
ARGS_RE = re.compile("[^{](\w+):([\w?!.<>#]+)")
ARGS_RE = re.compile(r"[^{](\w+):([\w?!.<>#]+)")
FLAGS_RE = re.compile(r"flags\.(\d+)\?")
FLAGS_RE_2 = re.compile(r"flags\.(\d+)\?([\w<>.]+)")
FLAGS_RE_3 = re.compile(r"flags:#")
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- Install requirements.
- Install `pandoc` and `latexmk`.
- HTML: `make html`
- HTML: `make html`
- PDF: `make latexpdf`

TODO: Explain better
2 changes: 1 addition & 1 deletion pyrogram/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ def resolve_peer(self, peer_id: Union[int, str]):
try:
return self.storage.get_peer_by_id(peer_id)
except KeyError:
if type(peer_id) is str:
if isinstance(peer_id, str):
if peer_id in ("self", "me"):
return types.InputPeerSelf()

Expand Down
14 changes: 7 additions & 7 deletions pyrogram/client/filters/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Filters:

from_scheduled = create(lambda _, m: bool(m.from_scheduled), "FromScheduledFilter")
"""Filter new automatically sent messages that were previously scheduled."""

# Messages from linked channels are forwarded automatically by Telegram and have no sender (from_user is None).
linked_channel = create(lambda _, m: bool(m.forward_from_chat and not m.from_user), "LinkedChannelFilter")
"""Filter messages that are automatically forwarded from the linked channel to the group chat."""
Expand Down Expand Up @@ -277,11 +277,11 @@ def func(flt, message):

return False

commands = commands if type(commands) is list else [commands]
commands = commands if isinstance(commands, list) else [commands]
commands = {c if case_sensitive else c.lower() for c in commands}

prefixes = [] if prefixes is None else prefixes
prefixes = prefixes if type(prefixes) is list else [prefixes]
prefixes = prefixes if isinstance(prefixes, list) else [prefixes]
prefixes = set(prefixes) if prefixes else {""}

return create(
Expand Down Expand Up @@ -345,11 +345,11 @@ class user(Filter, set):
"""

def __init__(self, users: int or str or list = None):
users = [] if users is None else users if type(users) is list else [users]
users = [] if users is None else users if isinstance(users, list) else [users]

super().__init__(
"me" if u in ["me", "self"]
else u.lower().strip("@") if type(u) is str
else u.lower().strip("@") if isinstance(u, str)
else u for u in users
)

Expand All @@ -376,11 +376,11 @@ class chat(Filter, set):
"""

def __init__(self, chats: int or str or list = None):
chats = [] if chats is None else chats if type(chats) is list else [chats]
chats = [] if chats is None else chats if isinstance(chats, list) else [chats]

super().__init__(
"me" if c in ["me", "self"]
else c.lower().strip("@") if type(c) is str
else c.lower().strip("@") if isinstance(c, str)
else c for c in chats
)

Expand Down
2 changes: 1 addition & 1 deletion pyrogram/client/methods/chats/delete_user_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from typing import Union

from pyrogram.api import functions, types
from pyrogram.api import functions
from pyrogram.client.ext import BaseClient


Expand Down
2 changes: 0 additions & 2 deletions pyrogram/client/methods/chats/get_chat_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

import logging
import time
from typing import Union, List

import pyrogram
from pyrogram.api import functions, types
from pyrogram.errors import FloodWait
from ...ext import BaseClient

log = logging.getLogger(__name__)
Expand Down
2 changes: 0 additions & 2 deletions pyrogram/client/methods/chats/get_dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

import logging
import time
from typing import List

import pyrogram
from pyrogram.api import functions, types
from pyrogram.errors import FloodWait
from ...ext import BaseClient, utils

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion pyrogram/client/methods/chats/set_chat_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def set_chat_photo(
photo (``str``):
New chat photo. You can pass a :obj:`Photo` file_id or a file path to upload a new photo from your local
machine.

file_ref (``str``, *optional*):
A valid file reference obtained by a recently fetched media message.
To be used in combination with a file id in case a file reference is needed.
Expand Down
2 changes: 1 addition & 1 deletion pyrogram/client/methods/chats/update_chat_username.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def update_chat_username(
username: Union[str, None]
) -> bool:
"""Update a channel or a supergroup username.

To update your own username (for users only, not bots) you can use :meth:`~Client.update_username`.

Parameters:
Expand Down
2 changes: 0 additions & 2 deletions pyrogram/client/methods/messages/get_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

import logging
import time
from typing import Union, List

import pyrogram
from pyrogram.api import functions
from pyrogram.client.ext import utils
from pyrogram.errors import FloodWait
from ...ext import BaseClient

log = logging.getLogger(__name__)
Expand Down
2 changes: 0 additions & 2 deletions pyrogram/client/methods/messages/get_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

import logging
import time
from typing import Union, Iterable, List

import pyrogram
from pyrogram.api import functions, types
from pyrogram.errors import FloodWait
from ...ext import BaseClient, utils

log = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/client/methods/users/get_common_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_common_chats(self, user_id: Union[int, str]) -> list:

Returns:
List of :obj:`Chat`: On success, a list of the common chats is returned.

Raises:
ValueError: If the user_id doesn't belong to a user.

Expand All @@ -58,5 +58,5 @@ def get_common_chats(self, user_id: Union[int, str]) -> list:
)

return pyrogram.List([pyrogram.Chat._parse_chat(self, x) for x in r.chats])

raise ValueError('The user_id "{}" doesn\'t belong to a user'.format(user_id))
16 changes: 8 additions & 8 deletions pyrogram/client/methods/users/update_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,33 @@ def update_profile(
bio: str = None
) -> bool:
"""Update your profile details such as first name, last name and bio.

You can omit the parameters you don't want to change.

Parameters:
first_name (``str``, *optional*):
The new first name.

last_name (``str``, *optional*):
The new last name.
Pass "" (empty string) to remove it.

bio (``str``, *optional*):
The new bio, also known as "about". Max 70 characters.
Pass "" (empty string) to remove it.

Returns:
``bool``: True on success.

Example:
.. code-block:: python

# Update your first name only
app.update_profile(first_name="Pyrogram")

# Update first name and bio
app.update_profile(first_name="Pyrogram", bio="https://docs.pyrogram.org/")

# Remove the last name
app.update_profile(last_name="")
"""
Expand Down
2 changes: 1 addition & 1 deletion pyrogram/client/methods/users/update_username.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def update_username(
username: Union[str, None]
) -> bool:
"""Update your own username.

This method only works for users, not bots. Bot usernames must be changed via Bot Support or by recreating
them from scratch using BotFather. To update a channel or supergroup username you can use
:meth:`~Client.update_chat_username`.
Expand Down
2 changes: 0 additions & 2 deletions pyrogram/client/types/inline_mode/chosen_inline_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@

from base64 import b64encode
from struct import pack
from typing import Union

import pyrogram
from pyrogram.api import types
from pyrogram.client.types.object import Object
from pyrogram.client.types.update import Update
from pyrogram.client.types.user_and_chats import User
from pyrogram.client.types.messages_and_media import Location
from pyrogram.client.ext import utils


class ChosenInlineResult(Object, Update):
Expand Down
5 changes: 0 additions & 5 deletions pyrogram/client/types/messages_and_media/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from struct import pack
from typing import List

import pyrogram
from pyrogram.api import types
from .thumbnail import Thumbnail
from ..object import Object
from ...ext.utils import encode_file_id, encode_file_ref


class Dice(Object):
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/client/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2964,7 +2964,7 @@ def retract_vote(
chat_id=message.chat.id,
message_id=message_id,
)

Example:
.. code-block:: python

Expand Down Expand Up @@ -3074,7 +3074,7 @@ def vote(
Parameters:
option (``int``):
Index of the poll option you want to vote for (0 to 9).

Returns:
:obj:`Poll`: On success, the poll with the chosen option is returned.

Expand Down
4 changes: 2 additions & 2 deletions pyrogram/session/internals/msg_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .msg_id import MsgId
from .seq_no import SeqNo

not_content_related = [Ping, HttpWait, MsgsAck, MsgContainer]
not_content_related = (Ping, HttpWait, MsgsAck, MsgContainer)


class MsgFactory:
Expand All @@ -34,6 +34,6 @@ def __call__(self, body: TLObject) -> Message:
return Message(
body,
MsgId(),
self.seq_no(type(body) not in not_content_related),
self.seq_no(not isinstance(body, not_content_related)),
len(body)
)