This commit is contained in:
Lonami 2018-01-27 16:08:09 +00:00 committed by GitHub
commit 92795440d6
2 changed files with 21 additions and 27 deletions

View File

@ -68,7 +68,7 @@ class TelegramBareClient:
# region Initialization # region Initialization
def __init__(self, session, api_id, api_hash, def __init__(self, session, api_id, api_hash,
connection_mode=ConnectionMode.TCP_FULL, connection_mode=ConnectionMode.TCP_FULL, *,
use_ipv6=False, use_ipv6=False,
proxy=None, proxy=None,
update_workers=None, update_workers=None,
@ -592,7 +592,7 @@ class TelegramBareClient:
warnings.warn( warnings.warn(
"You have not setup any workers, so you won't receive updates." "You have not setup any workers, so you won't receive updates."
" Pass update_workers=4 when creating the TelegramClient," " Pass update_workers=4 when creating the TelegramClient,"
" or set client.self.updates.workers = 4" " or set client.updates.workers = 4"
) )
self.updates.handlers.append(handler) self.updates.handlers.append(handler)

View File

@ -141,7 +141,7 @@ class TelegramClient(TelegramBareClient):
# region Initialization # region Initialization
def __init__(self, session, api_id, api_hash, def __init__(self, session, api_id, api_hash,
connection_mode=ConnectionMode.TCP_FULL, connection_mode=ConnectionMode.TCP_FULL, *,
use_ipv6=False, use_ipv6=False,
proxy=None, proxy=None,
update_workers=None, update_workers=None,
@ -203,8 +203,8 @@ class TelegramClient(TelegramBareClient):
def start(self, def start(self,
phone=lambda: input('Please enter your phone: '), phone=lambda: input('Please enter your phone: '),
password=None, bot_token=None, password=None, *,
force_sms=False, code_callback=None): bot_token=None, force_sms=False, code_callback=None):
""" """
Convenience method to interactively connect and sign in if required, Convenience method to interactively connect and sign in if required,
also taking into consideration that 2FA may be enabled in the account. also taking into consideration that 2FA may be enabled in the account.
@ -308,7 +308,7 @@ class TelegramClient(TelegramBareClient):
return self return self
def sign_in(self, phone=None, code=None, def sign_in(self, phone=None, code=None,
password=None, bot_token=None, phone_code_hash=None): password=None, *, bot_token=None, phone_code_hash=None):
""" """
Starts or completes the sign in process with the given phone number Starts or completes the sign in process with the given phone number
or code that Telegram sent. or code that Telegram sent.
@ -438,7 +438,7 @@ class TelegramClient(TelegramBareClient):
# region Dialogs ("chats") requests # region Dialogs ("chats") requests
def get_dialogs(self, limit=10, offset_date=None, offset_id=0, def get_dialogs(self, limit=10, *, offset_date=None, offset_id=0,
offset_peer=InputPeerEmpty()): offset_peer=InputPeerEmpty()):
""" """
Gets N "dialogs" (open "chats" or conversations with other people). Gets N "dialogs" (open "chats" or conversations with other people).
@ -549,8 +549,8 @@ class TelegramClient(TelegramBareClient):
if update.message.id == msg_id: if update.message.id == msg_id:
return update.message return update.message
def send_message(self, entity, message, reply_to=None, parse_mode=None, def send_message(self, entity, message, *,
link_preview=True): reply_to=None, parse_mode=None, link_preview=True):
""" """
Sends the given message to the specified entity (user/chat/channel). Sends the given message to the specified entity (user/chat/channel).
@ -645,7 +645,7 @@ class TelegramClient(TelegramBareClient):
else: else:
return self(messages.DeleteMessagesRequest(message_ids, revoke=revoke)) return self(messages.DeleteMessagesRequest(message_ids, revoke=revoke))
def get_message_history(self, entity, limit=20, offset_date=None, def get_message_history(self, entity, limit=20, *, offset_date=None,
offset_id=0, max_id=0, min_id=0, add_offset=0): offset_id=0, max_id=0, min_id=0, add_offset=0):
""" """
Gets the message history for the specified entity Gets the message history for the specified entity
@ -767,8 +767,8 @@ class TelegramClient(TelegramBareClient):
return messages return messages
def send_read_acknowledge(self, entity, message=None, max_id=None, def send_read_acknowledge(self, entity, message=None, *,
clear_mentions=False): max_id=None, clear_mentions=False):
""" """
Sends a "read acknowledge" (i.e., notifying the given peer that we've Sends a "read acknowledge" (i.e., notifying the given peer that we've
read their messages, also known as the "double check"). read their messages, also known as the "double check").
@ -837,7 +837,7 @@ class TelegramClient(TelegramBareClient):
# region Uploading files # region Uploading files
def send_file(self, entity, file, caption='', def send_file(self, entity, file, caption='', *,
force_document=False, progress_callback=None, force_document=False, progress_callback=None,
reply_to=None, reply_to=None,
attributes=None, attributes=None,
@ -1013,15 +1013,15 @@ class TelegramClient(TelegramBareClient):
return msg return msg
def send_voice_note(self, entity, file, caption='', progress_callback=None, def send_voice_note(self, entity, file, caption='', *,
reply_to=None): progress_callback=None, reply_to=None):
"""Wrapper method around .send_file() with is_voice_note=()""" """Wrapper method around .send_file() with is_voice_note=()"""
return self.send_file(entity, file, caption, return self.send_file(entity, file, caption,
progress_callback=progress_callback, progress_callback=progress_callback,
reply_to=reply_to, reply_to=reply_to,
is_voice_note=()) # empty tuple is enough is_voice_note=()) # empty tuple is enough
def _send_album(self, entity, files, caption='', def _send_album(self, entity, files, caption='', *,
progress_callback=None, reply_to=None): progress_callback=None, reply_to=None):
"""Specialized version of .send_file for albums""" """Specialized version of .send_file for albums"""
# We don't care if the user wants to avoid cache, we will use it # We don't care if the user wants to avoid cache, we will use it
@ -1055,11 +1055,8 @@ class TelegramClient(TelegramBareClient):
if isinstance(update, UpdateMessageID) if isinstance(update, UpdateMessageID)
] ]
def upload_file(self, def upload_file(self, file, *,
file, part_size_kb=None, file_name=None, use_cache=None,
part_size_kb=None,
file_name=None,
use_cache=None,
progress_callback=None): progress_callback=None):
""" """
Uploads the specified file and returns a handle (an instance of Uploads the specified file and returns a handle (an instance of
@ -1281,7 +1278,7 @@ class TelegramClient(TelegramBareClient):
return None return None
return file return file
def download_media(self, message, file=None, progress_callback=None): def download_media(self, message, file=None, *, progress_callback=None):
""" """
Downloads the given media, or the media from a specified Message. Downloads the given media, or the media from a specified Message.
@ -1479,11 +1476,8 @@ class TelegramClient(TelegramBareClient):
return result return result
i += 1 i += 1
def download_file(self, def download_file(self, input_location, file, *,
input_location, part_size_kb=None, file_size=None,
file,
part_size_kb=None,
file_size=None,
progress_callback=None): progress_callback=None):
""" """
Downloads the given input location to a file. Downloads the given input location to a file.