diff --git a/readthedocs/basic/quick-start.rst b/readthedocs/basic/quick-start.rst index 30cf0ea4..91481983 100644 --- a/readthedocs/basic/quick-start.rst +++ b/readthedocs/basic/quick-start.rst @@ -47,7 +47,7 @@ use these if possible. message = await client.send_message( 'me', 'This message has **bold**, `code`, __italics__ and ' - 'a [nice website](https://lonamiwebs.github.io)!', + 'a [nice website](https://example.com)!', link_preview=False ) diff --git a/readthedocs/concepts/asyncio.rst b/readthedocs/concepts/asyncio.rst index 4a617080..03ffd198 100644 --- a/readthedocs/concepts/asyncio.rst +++ b/readthedocs/concepts/asyncio.rst @@ -360,6 +360,6 @@ Where can I read more? ====================== `Check out my blog post -`_ about `asyncio`, which +`_ about `asyncio`, which has some more examples and pictures to help you understand what happens when the loop runs. diff --git a/readthedocs/concepts/entities.rst b/readthedocs/concepts/entities.rst index 1a680e51..491c8c1e 100644 --- a/readthedocs/concepts/entities.rst +++ b/readthedocs/concepts/entities.rst @@ -112,9 +112,9 @@ you're able to just do this: dialogs = await client.get_dialogs() # All of these work and do the same. - lonami = await client.get_entity('lonami') - lonami = await client.get_entity('t.me/lonami') - lonami = await client.get_entity('https://telegram.dog/lonami') + username = await client.get_entity('username') + username = await client.get_entity('t.me/username') + username = await client.get_entity('https://telegram.dog/username') # Other kind of entities. channel = await client.get_entity('telegram.me/joinchat/AAAAAEkk2WdoDrB4-Q8-gg') @@ -142,7 +142,7 @@ you're able to just do this: All methods in the :ref:`telethon-client` call `.get_input_entity() ` prior to sending the request to save you from the hassle of doing so manually. -That way, convenience calls such as `client.send_message('lonami', 'hi!') +That way, convenience calls such as `client.send_message('username', 'hi!') ` become possible. diff --git a/readthedocs/concepts/strings.rst b/readthedocs/concepts/strings.rst index c0687fd9..dee48c80 100644 --- a/readthedocs/concepts/strings.rst +++ b/readthedocs/concepts/strings.rst @@ -8,82 +8,70 @@ does a result have? Well, the easiest thing to do is printing it: .. code-block:: python - user = await client.get_entity('Lonami') - print(user) + entity = await client.get_entity('username') + print(entity) That will show a huge **string** similar to the following: .. code-block:: python - User(id=10885151, is_self=False, contact=False, mutual_contact=False, deleted=False, bot=False, bot_chat_history=False, bot_nochats=False, verified=False, restricted=False, min=False, bot_inline_geo=False, access_hash=123456789012345678, first_name='Lonami', last_name=None, username='Lonami', phone=None, photo=UserProfilePhoto(photo_id=123456789012345678, photo_small=FileLocation(dc_id=4, volume_id=1234567890, local_id=1234567890, secret=123456789012345678), photo_big=FileLocation(dc_id=4, volume_id=1234567890, local_id=1234567890, secret=123456789012345678)), status=UserStatusOffline(was_online=datetime.datetime(2018, 1, 2, 3, 4, 5, tzinfo=datetime.timezone.utc)), bot_info_version=None, restriction_reason=None, bot_inline_placeholder=None, lang_code=None) + Channel(id=1066197625, title='Telegram Usernames', photo=ChatPhotoEmpty(), date=datetime.datetime(2016, 12, 16, 15, 15, 43, tzinfo=datetime.timezone.utc), version=0, creator=False, left=True, broadcast=True, verified=True, megagroup=False, restricted=False, signatures=False, min=False, scam=False, has_link=False, has_geo=False, slowmode_enabled=False, access_hash=-6309373984955162244, username='username', restriction_reason=[], admin_rights=None, banned_rights=None, default_banned_rights=None, participants_count=None) That's a lot of text. But as you can see, all the properties are there. -So if you want the username you **don't use regex** or anything like -splitting ``str(user)`` to get what you want. You just access the +So if you want the title you **don't use regex** or anything like +splitting ``str(entity)`` to get what you want. You just access the attribute you need: .. code-block:: python - username = user.username + title = entity.title Can we get better than the shown string, though? Yes! .. code-block:: python - print(user.stringify()) + print(entity.stringify()) Will show a much better: .. code-block:: python - User( - id=10885151, - is_self=False, - contact=False, - mutual_contact=False, - deleted=False, - bot=False, - bot_chat_history=False, - bot_nochats=False, - verified=False, + Channel( + id=1066197625, + title='Telegram Usernames', + photo=ChatPhotoEmpty( + ), + date=datetime.datetime(2016, 12, 16, 15, 15, 43, tzinfo=datetime.timezone.utc), + version=0, + creator=False, + left=True, + broadcast=True, + verified=True, + megagroup=False, restricted=False, + signatures=False, min=False, - bot_inline_geo=False, - access_hash=123456789012345678, - first_name='Lonami', - last_name=None, - username='Lonami', - phone=None, - photo=UserProfilePhoto( - photo_id=123456789012345678, - photo_small=FileLocation( - dc_id=4, - volume_id=123456789, - local_id=123456789, - secret=-123456789012345678 - ), - photo_big=FileLocation( - dc_id=4, - volume_id=123456789, - local_id=123456789, - secret=123456789012345678 - ) - ), - status=UserStatusOffline( - was_online=datetime.datetime(2018, 1, 2, 3, 4, 5, tzinfo=datetime.timezone.utc) - ), - bot_info_version=None, - restriction_reason=None, - bot_inline_placeholder=None, - lang_code=None + scam=False, + has_link=False, + has_geo=False, + slowmode_enabled=False, + access_hash=-6309373984955162244, + username='username', + restriction_reason=[ + ], + admin_rights=None, + banned_rights=None, + default_banned_rights=None, + participants_count=None ) + Now it's easy to see how we could get, for example, -the ``was_online`` time. It's inside ``status``: +the ``year`` value. It's inside ``date``: .. code-block:: python - online_at = user.status.was_online + channel_year = entity.date.year You don't need to print everything to see what all the possible values can be. You can just search in http://tl.telethon.dev/. @@ -96,5 +84,5 @@ to check the type of something. For example: from telethon import types - if isinstance(user.status, types.UserStatusOffline): - print(user.status.was_online) + if isinstance(entity.photo, types.ChatPhotoEmpty): + print('Channel has no photo') diff --git a/readthedocs/examples/projects-using-telethon.rst b/readthedocs/examples/projects-using-telethon.rst index 681e0074..7ba4f998 100644 --- a/readthedocs/examples/projects-using-telethon.rst +++ b/readthedocs/examples/projects-using-telethon.rst @@ -25,7 +25,7 @@ telethon_examples/ ================== `telethon_examples `_ / -`LonamiWebs' site `_ +`Lonami's site `_ This documentation is not the only place where you can find useful code snippets using the library. The main repository also has a folder with diff --git a/readthedocs/misc/changelog.rst b/readthedocs/misc/changelog.rst index 3b24b785..8dcb39f5 100644 --- a/readthedocs/misc/changelog.rst +++ b/readthedocs/misc/changelog.rst @@ -1995,7 +1995,7 @@ Internal changes ~~~~~~~~~~~~~~~~ - ``libssl`` is no longer an optional dependency. Use ``cryptg`` instead, - which you can find on https://github.com/Lonami/cryptg. + which you can find on https://pypi.org/project/cryptg/. diff --git a/telethon/client/dialogs.py b/telethon/client/dialogs.py index 4bb74c27..34173c4c 100644 --- a/telethon/client/dialogs.py +++ b/telethon/client/dialogs.py @@ -569,10 +569,10 @@ class DialogMethods: # Your name didn't have any letters! Try again conv.send_message("Your name didn't have any letters! Try again") - # Lonami + # Human name = conv.get_response().raw_text - # Thanks Lonami! + # Thanks Human! conv.send_message('Thanks {}!'.format(name)) """ return custom.Conversation( diff --git a/telethon/client/messages.py b/telethon/client/messages.py index 2e15ebd6..5c263edc 100644 --- a/telethon/client/messages.py +++ b/telethon/client/messages.py @@ -634,7 +634,7 @@ class MessageMethods: .. code-block:: python # Markdown is the default - await client.send_message('lonami', 'Thanks for the **Telethon** library!') + await client.send_message('me', 'Hello **world**!') # Default to another parse mode client.parse_mode = 'html' @@ -668,7 +668,7 @@ class MessageMethods: # Matrix of inline buttons await client.send_message(chat, 'Pick one from this grid', buttons=[ [Button.inline('Left'), Button.inline('Right')], - [Button.url('Check this site!', 'https://lonamiwebs.github.io')] + [Button.url('Check this site!', 'https://example.com')] ]) # Reply keyboard