Skip to content

Commit

Permalink
Merge pull request #83 from n1ret/main
Browse files Browse the repository at this point in the history
Fix auth_session referenced before assignment ToTelethon
  • Loading branch information
thedemons authored Dec 8, 2023
2 parents 5568f74 + 0d258dc commit 16da601
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pathlib
from setuptools import find_packages, setup
from setuptools import setup
import re

README = (pathlib.Path(__file__).parent / "README.md").read_text()
Expand Down Expand Up @@ -40,7 +40,7 @@
"opentele",
],
include_package_data=True,
packages=[PACKAGE_NAME],
packages=[PACKAGE_NAME, PACKAGE_NAME+'.td', PACKAGE_NAME+'.tl'],
package_dir={PACKAGE_NAME: SOURCE_DIRECTORY},
install_requires=requirements,
)
11 changes: 9 additions & 2 deletions src/tl/telethon.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from telethon.tl.types.auth import LoginTokenMigrateTo
import logging
import warnings
from typing import Awaitable


@extend_override_class
Expand Down Expand Up @@ -624,7 +625,9 @@ async def QRLoginToNewClient(

# for the above reason, we should check if we're already authorized
if isinstance(qr_login._resp, types.auth.LoginTokenSuccess):
newClient._on_login(qr_login._resp.authorization.user)
coro = newClient._on_login(qr_login._resp.authorization.user)
if isinstance(coro, Awaitable):
await coro
break

# calculate when will the qr token expire
Expand Down Expand Up @@ -683,7 +686,9 @@ async def QRLoginToNewClient(
)

# successful log in
newClient._on_login(result.user) # type: ignore
coro = newClient._on_login(result.user) # type: ignore
if isinstance(coro, Awaitable):
await coro
break

except PasswordHashInvalidError as e:
Expand Down Expand Up @@ -892,6 +897,8 @@ async def FromTDesktop(
raise TypeError(
"The given session must be a str or a Session instance."
)
else: # session is instance of Session
auth_session = session

auth_session.set_dc(endpoint.id, endpoint.ip, endpoint.port) # type: ignore
auth_session.auth_key = AuthKey(account.authKey.key) # type: ignore
Expand Down

0 comments on commit 16da601

Please sign in to comment.