Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
batreller committed Sep 8, 2024
1 parent e883466 commit 9830dae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion AndroidTelePorter/managers/userconfigmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import base64

from telethon.errors import TypeNotFoundError
from telethon.extensions import BinaryReader
from telethon.tl.types import UserFull, User, UserEmpty

Expand Down Expand Up @@ -38,7 +39,11 @@ def from_base64(cls, data: str) -> 'UserConfigManager':

@classmethod
def from_bytes(cls, data: bytes | bytearray) -> 'UserConfigManager':
user = BinaryReader(data).tgread_object()
bdata = BinaryReader(data)
try:
user = bdata.tgread_object()
except TypeNotFoundError:
raise ValueError(f'Constructor ID {hex(bdata.read_int(signed=False))} not found, run pip install --upgrade git+https://github.com/LonamiWebs/Telethon.git')
if not isinstance(user, (User, UserEmpty, UserFull)):
raise ValueError('Invalid bytes')
return cls(userconfig=user)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Telethon~=1.35.0
telethon
lxml~=5.2.2
opentele~=1.15.1
setuptools~=72.1.0
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
long_description = "\n" + fh.read()

VERSION = '1.1.0'
VERSION = '1.1.1'
DESCRIPTION = 'Serializer and deserializer for mobile telegram session'

setup(
Expand All @@ -21,7 +21,7 @@
url='https://github.com/batreller/AndroidTelePorter',
packages=find_packages(),
license='MIT',
install_requires=['Telethon~=1.35.0', 'lxml~=5.2.2', 'opentele~=1.15.1', 'setuptools~=72.1.0', 'Pyrogram~=2.0.106'],
install_requires=['telethon', 'lxml~=5.2.2', 'opentele~=1.15.1', 'setuptools~=72.1.0', 'Pyrogram~=2.0.106'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
Expand Down

0 comments on commit 9830dae

Please sign in to comment.