mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-12 15:38:03 +03:00
Rename is_connected as connected
Since it makes more sense this way, because the former sounds like a method when it's not.
This commit is contained in:
parent
6d4c8ba8ff
commit
f9ca17c99f
|
@ -45,7 +45,7 @@ Base
|
||||||
|
|
||||||
connect
|
connect
|
||||||
disconnect
|
disconnect
|
||||||
is_connected
|
connected
|
||||||
disconnected
|
disconnected
|
||||||
loop
|
loop
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
|
||||||
async def _start(
|
async def _start(
|
||||||
self, phone, password, bot_token, force_sms,
|
self, phone, password, bot_token, force_sms,
|
||||||
code_callback, first_name, last_name, max_attempts):
|
code_callback, first_name, last_name, max_attempts):
|
||||||
if not self.is_connected:
|
if not self.connected:
|
||||||
await self.connect()
|
await self.connect()
|
||||||
|
|
||||||
if await self.is_user_authorized():
|
if await self.is_user_authorized():
|
||||||
|
|
|
@ -432,20 +432,18 @@ class TelegramBaseClient(abc.ABC):
|
||||||
self._updates_handle = self._loop.create_task(self._update_loop())
|
self._updates_handle = self._loop.create_task(self._update_loop())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connected(self: 'TelegramClient') -> bool:
|
def connected(self: 'TelegramClient') -> bool:
|
||||||
"""
|
"""
|
||||||
Returns ``True`` if the user has connected.
|
Property which is ``True`` if the user has connected.
|
||||||
|
|
||||||
This method is **not** asynchronous (don't use ``await`` on it).
|
|
||||||
|
|
||||||
Example
|
Example
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
while client.is_connected:
|
while client.connected:
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
"""
|
"""
|
||||||
sender = getattr(self, '_sender', None)
|
sender = getattr(self, '_sender', None)
|
||||||
return sender and sender.is_connected
|
return sender and sender.connected
|
||||||
|
|
||||||
def disconnect(self: 'TelegramClient'):
|
def disconnect(self: 'TelegramClient'):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -323,7 +323,7 @@ class UpdateMethods(UserMethods):
|
||||||
async def _update_loop(self: 'TelegramClient'):
|
async def _update_loop(self: 'TelegramClient'):
|
||||||
# Pings' ID don't really need to be secure, just "random"
|
# Pings' ID don't really need to be secure, just "random"
|
||||||
rnd = lambda: random.randrange(-2**63, 2**63)
|
rnd = lambda: random.randrange(-2**63, 2**63)
|
||||||
while self.is_connected:
|
while self.connected:
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(
|
await asyncio.wait_for(
|
||||||
self.disconnected, timeout=60, loop=self._loop
|
self.disconnected, timeout=60, loop=self._loop
|
||||||
|
@ -425,7 +425,7 @@ class UpdateMethods(UserMethods):
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not isinstance(e, asyncio.CancelledError) or self.is_connected:
|
if not isinstance(e, asyncio.CancelledError) or self.connected:
|
||||||
name = getattr(callback, '__name__', repr(callback))
|
name = getattr(callback, '__name__', repr(callback))
|
||||||
self._log[__name__].exception('Unhandled exception on %s',
|
self._log[__name__].exception('Unhandled exception on %s',
|
||||||
name)
|
name)
|
||||||
|
|
|
@ -123,7 +123,7 @@ class MTProtoSender:
|
||||||
self._user_connected = True
|
self._user_connected = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connected(self):
|
def connected(self):
|
||||||
return self._user_connected
|
return self._user_connected
|
||||||
|
|
||||||
async def disconnect(self):
|
async def disconnect(self):
|
||||||
|
|
|
@ -228,7 +228,7 @@ class App(tkinter.Tk):
|
||||||
"""
|
"""
|
||||||
Sends a message. Does nothing if the client is not connected.
|
Sends a message. Does nothing if the client is not connected.
|
||||||
"""
|
"""
|
||||||
if not self.cl.is_connected:
|
if not self.cl.connected:
|
||||||
return
|
return
|
||||||
|
|
||||||
# The user needs to configure a chat where the message should be sent.
|
# The user needs to configure a chat where the message should be sent.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user