Update to v1.0

This commit is contained in:
Lonami Exo
2018-06-27 13:05:19 +02:00
parent a1799ee74b
commit 72835dfb44
13 changed files with 156 additions and 29 deletions

View File

@@ -17,6 +17,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
self,
phone=lambda: input('Please enter your phone: '),
password=lambda: getpass.getpass('Please enter your password: '),
*,
bot_token=None, force_sms=False, code_callback=None,
first_name='New User', last_name='', max_attempts=3):
"""
@@ -193,7 +194,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
return self
async def sign_in(
self, phone=None, code=None, password=None,
self, phone=None, *, code=None, password=None,
bot_token=None, phone_code_hash=None):
"""
Starts or completes the sign in process with the given phone number
@@ -325,7 +326,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
self._authorized = True
return result.user
async def send_code_request(self, phone, force_sms=False):
async def send_code_request(self, phone, *, force_sms=False):
"""
Sends a code request to the specified phone number.
@@ -382,8 +383,8 @@ class AuthMethods(MessageParseMethods, UserMethods):
return True
async def edit_2fa(
self, current_password=None, new_password=None, hint='',
email=None):
self, current_password=None, new_password=None,
*, hint='', email=None):
"""
Changes the 2FA settings of the logged in user, according to the
passed parameters. Take note of the parameter explanations.

View File

@@ -13,7 +13,7 @@ class ChatMethods(UserMethods):
@async_generator
async def iter_participants(
self, entity, limit=None, search='',
self, entity, limit=None, *, search='',
filter=None, aggressive=False, _total=None):
"""
Iterator over the participants belonging to the specified chat.

View File

@@ -14,7 +14,7 @@ class DialogMethods(UserMethods):
@async_generator
async def iter_dialogs(
self, limit=None, offset_date=None, offset_id=0,
self, limit=None, *, offset_date=None, offset_id=0,
offset_peer=types.InputPeerEmpty(), ignore_migrated=False,
_total=None):
"""

View File

@@ -16,7 +16,7 @@ class DownloadMethods(UserMethods):
# region Public methods
async def download_profile_photo(
self, entity, file=None, download_big=True):
self, entity, file=None, *, download_big=True):
"""
Downloads the profile photo of the given entity (user/chat/channel).
@@ -91,7 +91,8 @@ class DownloadMethods(UserMethods):
# Until there's a report for chats, no need to.
return None
async def download_media(self, message, file=None, progress_callback=None):
async def download_media(self, message, file=None,
*, progress_callback=None):
"""
Downloads the given media, or the media from a specified Message.
@@ -141,7 +142,7 @@ class DownloadMethods(UserMethods):
)
async def download_file(
self, input_location, file=None, part_size_kb=None,
self, input_location, file=None, *, part_size_kb=None,
file_size=None, progress_callback=None):
"""
Downloads the given input location to a file.

View File

@@ -22,7 +22,7 @@ class MessageMethods(UploadMethods, MessageParseMethods):
@async_generator
async def iter_messages(
self, entity, limit=None, offset_date=None, offset_id=0,
self, entity, limit=None, *, offset_date=None, offset_id=0,
max_id=0, min_id=0, add_offset=0, search=None, filter=None,
from_user=None, batch_size=100, wait_time=None, ids=None,
_total=None):
@@ -285,7 +285,7 @@ class MessageMethods(UploadMethods, MessageParseMethods):
# region Message sending/editing/deleting
async def send_message(
self, entity, message='', reply_to=None,
self, entity, message='', *, reply_to=None,
parse_mode=utils.Default, link_preview=True, file=None,
force_document=False, clear_draft=False):
"""
@@ -403,7 +403,7 @@ class MessageMethods(UploadMethods, MessageParseMethods):
return self._get_response_message(request, result, entity)
async def forward_messages(self, entity, messages, from_peer=None):
async def forward_messages(self, entity, messages, *, from_peer=None):
"""
Forwards the given message(s) to the specified entity.
@@ -469,8 +469,8 @@ class MessageMethods(UploadMethods, MessageParseMethods):
return result[0] if single else result
async def edit_message(
self, entity, message=None, text=None, parse_mode=utils.Default,
link_preview=True, file=None):
self, entity, message=None, text=None,
*, parse_mode=utils.Default, link_preview=True, file=None):
"""
Edits the given message ID (to change its contents or disable preview).
@@ -542,7 +542,7 @@ class MessageMethods(UploadMethods, MessageParseMethods):
self._cache_media(msg, file, file_handle)
return msg
async def delete_messages(self, entity, message_ids, revoke=True):
async def delete_messages(self, entity, message_ids, *, revoke=True):
"""
Deletes a message from a chat, optionally "for everyone".
@@ -586,8 +586,8 @@ class MessageMethods(UploadMethods, MessageParseMethods):
# region Miscellaneous
async def send_read_acknowledge(self, entity, message=None, max_id=None,
clear_mentions=False):
async def send_read_acknowledge(
self, entity, message=None, *, max_id=None, clear_mentions=False):
"""
Sends a "read acknowledge" (i.e., notifying the given peer that we've
read their messages, also known as the "double check").

View File

@@ -27,7 +27,7 @@ class UploadMethods(MessageParseMethods, UserMethods):
# region Public methods
async def send_file(
self, entity, file, caption='', force_document=False,
self, entity, file, *, caption='', force_document=False,
progress_callback=None, reply_to=None, attributes=None,
thumb=None, allow_cache=True, parse_mode=utils.Default,
voice_note=False, video_note=False, **kwargs):
@@ -221,7 +221,7 @@ class UploadMethods(MessageParseMethods, UserMethods):
]
async def upload_file(
self, file, part_size_kb=None, file_name=None, use_cache=None,
self, file, *, part_size_kb=None, file_name=None, use_cache=None,
progress_callback=None):
"""
Uploads the specified file and returns a handle (an instance of

View File

@@ -14,7 +14,7 @@ class MessageRead(EventBuilder):
messages the event will be fired. By default (``False``) only
when messages you sent are read by someone else will fire it.
"""
def __init__(self, inbox=False, chats=None, blacklist_chats=None):
def __init__(self, chats=None, *, blacklist_chats=None, inbox=False):
super().__init__(chats, blacklist_chats)
self.inbox = inbox

View File

@@ -82,7 +82,7 @@ class UserUpdate(EventBuilder):
contact (`bool`):
``True`` if what's being uploaded (selected) is a contact.
"""
def __init__(self, user_id, status=None, typing=None):
def __init__(self, user_id, *, status=None, typing=None):
super().__init__(types.PeerUser(user_id))
self.online = None if status is None else \

View File

@@ -1,3 +1,3 @@
# Versions should comply with PEP440.
# This line is parsed in setup.py:
__version__ = '1.0-rc1'
__version__ = '1.0'