Skip to content

Commit 823ae48

Browse files
committed
pyrofork: Fix critical issue
Signed-off-by: wulan17 <wulan17@nusantararom.org>
1 parent 86b9143 commit 823ae48

File tree

20 files changed

+124
-46
lines changed

20 files changed

+124
-46
lines changed

compiler/api/compiler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,12 @@ def start(format: bool = False):
442442
references, count = get_references(c.qualname, "constructors")
443443

444444
if references:
445-
docstring += f"\n Functions:\n This object can be returned by " \
445+
docstring += "\n Functions:\n This object can be returned by " \
446446
f"{count} function{'s' if count > 1 else ''}.\n\n" \
447-
f" .. currentmodule:: pyrogram.raw.functions\n\n" \
448-
f" .. autosummary::\n" \
449-
f" :nosignatures:\n\n" \
450-
f" " + references
447+
" .. currentmodule:: pyrogram.raw.functions\n\n" \
448+
" .. autosummary::\n" \
449+
" :nosignatures:\n\n" \
450+
" " + references
451451

452452
write_types = read_types = "" if c.has_flags else "# No flags\n "
453453

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
FriendlyStyle.background_color = "#f3f2f1"
3030

3131
project = "Pyrofork"
32-
copyright = f"2022-present, Mayuri-Chan"
32+
copyright = "2022-present, Mayuri-Chan"
3333
author = "Mayuri-Chan"
3434

3535
version = ".".join(__version__.split(".")[:-1])

pyrogram/__init__.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
# You should have received a copy of the GNU Lesser General Public License
1818
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
1919

20+
from concurrent.futures.thread import ThreadPoolExecutor
21+
22+
from . import raw, types, filters, handlers, emoji, enums
23+
from .client import Client
24+
from .sync import idle, compose
25+
2026
__fork_name__ = "PyroFork"
2127
__version__ = "2.3.59"
2228
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
2329
__copyright__ = "Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>"
2430

25-
from concurrent.futures.thread import ThreadPoolExecutor
26-
2731

2832
class StopTransmission(Exception):
2933
pass
@@ -36,9 +40,20 @@ class StopPropagation(StopAsyncIteration):
3640
class ContinuePropagation(StopAsyncIteration):
3741
pass
3842

39-
40-
from . import raw, types, filters, handlers, emoji, enums
41-
from .client import Client
42-
from .sync import idle, compose
43-
4443
crypto_executor = ThreadPoolExecutor(1, thread_name_prefix="CryptoWorker")
44+
45+
__all__ = [
46+
"Client",
47+
"idle",
48+
"compose",
49+
"crypto_executor",
50+
"StopTransmission",
51+
"StopPropagation",
52+
"ContinuePropagation",
53+
"raw",
54+
"types",
55+
"filters",
56+
"handlers",
57+
"emoji",
58+
"enums",
59+
]

pyrogram/client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from io import StringIO, BytesIO
3434
from mimetypes import MimeTypes
3535
from pathlib import Path
36-
from typing import Union, List, Optional, Callable, AsyncGenerator, Type, Tuple
36+
from typing import Union, List, Optional, Callable, AsyncGenerator, Tuple
3737

3838
import pyrogram
3939
from pyrogram import __version__, __license__
@@ -51,24 +51,26 @@
5151
from pyrogram.methods import Methods
5252
from pyrogram.session import Auth, Session
5353
from pyrogram.storage import FileStorage, MemoryStorage, Storage
54-
try:
55-
import pymongo
56-
except Exception:
57-
pass
58-
else:
59-
from pyrogram.storage import MongoStorage
6054
from pyrogram.types import User, TermsOfService
6155
from pyrogram.utils import ainput
6256
from .connection import Connection
63-
from .connection.transport import TCP, TCPAbridged
57+
from .connection.transport import TCPAbridged
6458
from .dispatcher import Dispatcher
6559
from .file_id import FileId, FileType, ThumbnailSource
66-
from .filters import Filter
6760
from .mime_types import mime_types
6861
from .parser import Parser
6962
from .session.internals import MsgId
7063

7164
log = logging.getLogger(__name__)
65+
MONGO_AVAIL = False
66+
67+
try:
68+
import pymongo
69+
except Exception:
70+
pass
71+
else:
72+
from pyrogram.storage import MongoStorage
73+
MONGO_AVAIL = True
7274

7375

7476
class Client(Methods):
@@ -316,9 +318,7 @@ def __init__(
316318
elif self.in_memory:
317319
self.storage = MemoryStorage(self.name)
318320
elif self.mongodb:
319-
try:
320-
import pymongo
321-
except Exception:
321+
if not MONGO_AVAIL:
322322
log.warning(
323323
"pymongo is missing! "
324324
"Using MemoryStorage as session storage"
@@ -953,7 +953,7 @@ def load_plugins(self):
953953
)
954954

955955
count += 1
956-
except Exception as e:
956+
except Exception:
957957
pass
958958
else:
959959
for path, handlers in include:

pyrogram/connection/transport/tcp/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@
2323
from .tcp_full import TCPFull
2424
from .tcp_intermediate import TCPIntermediate
2525
from .tcp_intermediate_o import TCPIntermediateO
26+
27+
__all__ = [
28+
"TCP",
29+
"Proxy",
30+
"TCPAbridged",
31+
"TCPAbridgedO",
32+
"TCPFull",
33+
"TCPIntermediate",
34+
"TCPIntermediateO"
35+
]

pyrogram/crypto/mtproto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ def unpack(
7171
message = Message.read(data)
7272
except KeyError as e:
7373
if e.args[0] == 0:
74-
raise ConnectionError(f"Received empty data. Check your internet connection.")
74+
raise ConnectionError("Received empty data. Check your internet connection.")
7575

7676
left = data.read().hex()
7777

7878
left = [left[i:i + 64] for i in range(0, len(left), 64)]
7979
left = [[left[i:i + 8] for i in range(0, len(left), 8)] for left in left]
8080
left = "\n".join(" ".join(x for x in left) for left in left)
8181

82-
raise ValueError(f"The server sent an unknown constructor: {hex(e.args[0])}\n{left}")
82+
raise ValueError("The server sent an unknown constructor: {hex(e.args[0])}\n{left}")
8383

8484
# https://core.telegram.org/mtproto/security_guidelines#checking-sha256-hash-value-of-msg-key
8585
# 96 = 88 + 8 (incoming message)

pyrogram/handlers/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,31 @@
4242
from .message_reaction_count_updated_handler import MessageReactionCountUpdatedHandler
4343
from .pre_checkout_query_handler import PreCheckoutQueryHandler
4444
from .shipping_query_handler import ShippingQueryHandler
45+
46+
__all__ = [
47+
"BotBusinessConnectHandler",
48+
"BotBusinessMessageHandler",
49+
"CallbackQueryHandler",
50+
"ChatJoinRequestHandler",
51+
"ChatMemberUpdatedHandler",
52+
"ConversationHandler",
53+
"ChosenInlineResultHandler",
54+
"DeletedMessagesHandler",
55+
"DeletedBotBusinessMessagesHandler",
56+
"DisconnectHandler",
57+
"EditedMessageHandler",
58+
"EditedBotBusinessMessageHandler",
59+
"ErrorHandler",
60+
"InlineQueryHandler",
61+
"MessageHandler",
62+
"PollHandler",
63+
"PreCheckoutQueryHandler",
64+
"PurchasedPaidMediaHandler",
65+
"RawUpdateHandler",
66+
"UserStatusHandler",
67+
"StoryHandler",
68+
"MessageReactionUpdatedHandler",
69+
"MessageReactionCountUpdatedHandler",
70+
"PreCheckoutQueryHandler",
71+
"ShippingQueryHandler",
72+
]

pyrogram/helpers/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def kb(rows=None, **kwargs):
101101
line = []
102102
for button in row:
103103
button_type = type(button)
104-
if button_type == str:
104+
if isinstance(button_type, str):
105105
button = KeyboardButton(button)
106-
elif button_type == dict:
106+
elif isinstance(button_type, dict):
107107
button = KeyboardButton(**button)
108108

109109
line.append(button)

pyrogram/methods/chats/hide_general_topic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
1818
import pyrogram
1919
from pyrogram import raw
20-
from pyrogram import types
2120
from typing import Union
2221

2322

pyrogram/methods/decorators/on_shipping_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import Callable, Optional, Union
19+
from typing import Callable
2020

2121
import pyrogram
2222
from pyrogram.filters import Filter

0 commit comments

Comments
 (0)