mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-07 13:34:59 +03:00
fixed pr
This commit is contained in:
parent
696648536e
commit
4330a8b44f
109
.gitignore
vendored
109
.gitignore
vendored
|
@ -1,109 +0,0 @@
|
|||
# Docs
|
||||
_build/
|
||||
docs/
|
||||
|
||||
# Generated code
|
||||
telethon/tl/functions/
|
||||
telethon/tl/types/
|
||||
telethon/tl/patched/
|
||||
telethon/tl/alltlobjects.py
|
||||
telethon/errors/rpcerrorlist.py
|
||||
|
||||
# User session
|
||||
*.session
|
||||
usermedia/
|
||||
|
||||
# Quick tests should live in this file
|
||||
example.py
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
.idea/
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# IPython Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# dotenv
|
||||
.env
|
||||
|
||||
# virtualenv
|
||||
.venv/
|
||||
venv/
|
||||
ENV/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
|
@ -662,7 +662,7 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
reply_markup=self.build_reply_markup(buttons)
|
||||
)
|
||||
msg = self._get_response_message(request, await self(request), entity)
|
||||
self._cache_media(msg, file, file_handle)
|
||||
await self._cache_media(msg, file, file_handle)
|
||||
return msg
|
||||
|
||||
async def delete_messages(self, entity, message_ids, *, revoke=True):
|
||||
|
|
|
@ -196,7 +196,7 @@ class TelegramBaseClient(abc.ABC):
|
|||
DEFAULT_IPV6_IP if self._use_ipv6 else DEFAULT_IPV4_IP,
|
||||
DEFAULT_PORT
|
||||
)
|
||||
|
||||
self.flood_sleep_threshold = flood_sleep_threshold
|
||||
self.session = AsyncClassWrapper(session)
|
||||
self.api_id = int(api_id)
|
||||
self.api_hash = api_hash
|
||||
|
@ -329,7 +329,7 @@ class TelegramBaseClient(abc.ABC):
|
|||
await self._disconnect()
|
||||
if getattr(self, 'session', None):
|
||||
if getattr(self, '_state', None):
|
||||
f = await self.session.set_update_state(0, self._state)
|
||||
await self.session.set_update_state(0, self._state)
|
||||
await self.session.close()
|
||||
|
||||
async def _disconnect(self):
|
||||
|
@ -471,7 +471,7 @@ class TelegramBaseClient(abc.ABC):
|
|||
session = self._exported_sessions.get(cdn_redirect.dc_id)
|
||||
if not session:
|
||||
dc = await self._get_dc(cdn_redirect.dc_id, cdn=True)
|
||||
session = await self.session.clone()
|
||||
session = self.session.clone()
|
||||
session.set_dc(dc.id, dc.ip_address, dc.port)
|
||||
self._exported_sessions[cdn_redirect.dc_id] = session
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
|||
entities=msg_entities, reply_markup=markup, silent=silent
|
||||
)
|
||||
msg = self._get_response_message(request, await self(request), entity)
|
||||
self._cache_media(msg, file, file_handle, force_document=force_document)
|
||||
await self._cache_media(msg, file, file_handle, force_document=force_document)
|
||||
|
||||
return msg
|
||||
|
||||
|
|
|
@ -7,5 +7,5 @@ from .authenticator import do_authentication
|
|||
from .mtprotosender import MTProtoSender
|
||||
from .connection import (
|
||||
ConnectionTcpFull, ConnectionTcpAbridged, ConnectionTcpObfuscated,
|
||||
ConnectionTcpIntermediate, ConnectionHttp,Connection
|
||||
ConnectionTcpIntermediate, ConnectionHttp
|
||||
)
|
||||
|
|
|
@ -16,6 +16,7 @@ from ..tl.types import (
|
|||
MsgsStateInfo, MsgsAllInfo, MsgResendReq, upload
|
||||
)
|
||||
from ..utils import AsyncClassWrapper
|
||||
|
||||
__log__ = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
import inspect
|
||||
import asyncio
|
||||
from telethon.utils import AsyncClassWrapper
|
||||
|
||||
class session:
|
||||
test1='test1'
|
||||
async def test2(self,arg):
|
||||
print(arg)
|
||||
|
||||
def test3(self,arg):
|
||||
print("test3")
|
||||
|
||||
@property
|
||||
def test4(self):
|
||||
return "test4"
|
||||
|
||||
async def t():
|
||||
s = AsyncClassWrapper(session())
|
||||
print(s.test1)
|
||||
await s.test2("test2")
|
||||
await s.test3("k")
|
||||
print(s.test4)
|
||||
s.test5 = "hey"
|
||||
print(s.test5)
|
||||
|
||||
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(t())
|
||||
import inspect
|
||||
import asyncio
|
||||
from telethon.client import TelegramClient
|
||||
|
||||
|
||||
|
||||
api_hash = ""
|
||||
api_id = 12345
|
||||
async def main():
|
||||
client = TelegramClient(None, api_id, api_hash)
|
||||
await client.session.set_dc(2, '149.154.167.40', 443)
|
||||
await client.start(
|
||||
phone='9996621234', code_callback=lambda: '22222'
|
||||
)
|
||||
print(await client.get_dialogs())
|
||||
await client.send_message("me","heyh")
|
||||
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(main())
|
|
@ -972,6 +972,7 @@ def get_appropriated_part_size(file_size):
|
|||
|
||||
raise ValueError('File size too large')
|
||||
|
||||
|
||||
class AsyncClassWrapper:
|
||||
def __init__(self, wrapped):
|
||||
self.wrapped = wrapped
|
||||
|
|
Loading…
Reference in New Issue
Block a user