Rename invoke to __call__

This commit is contained in:
Lonami Exo 2017-10-01 16:04:14 +02:00
parent 36dabc4928
commit c61e168de4

View File

@ -406,7 +406,7 @@ class TelegramBareClient:
# region Invoking Telegram requests
def invoke(self, *requests, retries=5):
def __call__(self, *requests, retries=5):
"""Invokes (sends) a MTProtoRequest and returns (receives) its result.
The invoke will be retried up to 'retries' times before raising
@ -441,6 +441,9 @@ class TelegramBareClient:
if sender != self._sender:
sender.disconnect() # Close temporary connections
# Let people use client.invoke(SomeRequest()) instead client(...)
invoke = __call__
def _invoke(self, sender, call_receive, *requests):
try:
# Ensure that we start with no previous errors (i.e. resending)
@ -524,9 +527,6 @@ class TelegramBareClient:
self.disconnect()
raise
# Let people use client(SomeRequest()) instead client.invoke(...)
__call__ = invoke
# Some really basic functionality
def is_user_authorized(self):