mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-24 16:24:15 +03:00
Remove usage of the main group username in the docs
This commit is contained in:
parent
accb2142e7
commit
bc799fd82c
|
@ -41,7 +41,7 @@ use these if possible.
|
||||||
# ...to your contacts
|
# ...to your contacts
|
||||||
await client.send_message('+34600123123', 'Hello, friend!')
|
await client.send_message('+34600123123', 'Hello, friend!')
|
||||||
# ...or even to any username
|
# ...or even to any username
|
||||||
await client.send_message('TelethonChat', 'Hello, Telethon!')
|
await client.send_message('username', 'Testing Telethon!')
|
||||||
|
|
||||||
# You can, of course, use markdown in your messages:
|
# You can, of course, use markdown in your messages:
|
||||||
message = await client.send_message(
|
message = await client.send_message(
|
||||||
|
|
|
@ -310,27 +310,26 @@ you can run requests in parallel:
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
last, sent, download_path = await asyncio.gather(
|
last, sent, download_path = await asyncio.gather(
|
||||||
client.get_messages('TelethonChat', 10),
|
client.get_messages('telegram', 10),
|
||||||
client.send_message('TelethonOfftopic', 'Hey guys!'),
|
client.send_message('me', 'Using asyncio!'),
|
||||||
client.download_profile_photo('TelethonChat')
|
client.download_profile_photo('telegram')
|
||||||
)
|
)
|
||||||
|
|
||||||
loop.run_until_complete(main())
|
loop.run_until_complete(main())
|
||||||
|
|
||||||
|
|
||||||
This code will get the 10 last messages from `@TelethonChat
|
This code will get the 10 last messages from `@telegram
|
||||||
<https://t.me/TelethonChat>`_, send one to `@TelethonOfftopic
|
<https://t.me/telegram>`_, send one to the chat with yourself, and also
|
||||||
<https://t.me/TelethonOfftopic>`_, and also download the profile
|
download the profile photo of the channel. `asyncio` will run all these
|
||||||
photo of the main group. `asyncio` will run all these three tasks
|
three tasks at the same time. You can run all the tasks you want this way.
|
||||||
at the same time. You can run all the tasks you want this way.
|
|
||||||
|
|
||||||
A different way would be:
|
A different way would be:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
loop.create_task(client.get_messages('TelethonChat', 10))
|
loop.create_task(client.get_messages('telegram', 10))
|
||||||
loop.create_task(client.send_message('TelethonOfftopic', 'Hey guys!'))
|
loop.create_task(client.send_message('me', 'Using asyncio!'))
|
||||||
loop.create_task(client.download_profile_photo('TelethonChat'))
|
loop.create_task(client.download_profile_photo('telegram'))
|
||||||
|
|
||||||
They will run in the background as long as the loop is running too.
|
They will run in the background as long as the loop is running too.
|
||||||
|
|
||||||
|
|
|
@ -296,10 +296,10 @@ applications"? Now do the same with the library. Use what applies:
|
||||||
await client.get_dialogs()
|
await client.get_dialogs()
|
||||||
|
|
||||||
# Are they participant of some group? Get them.
|
# Are they participant of some group? Get them.
|
||||||
await client.get_participants('TelethonChat')
|
await client.get_participants('username')
|
||||||
|
|
||||||
# Is the entity the original sender of a forwarded message? Get it.
|
# Is the entity the original sender of a forwarded message? Get it.
|
||||||
await client.get_messages('TelethonChat', 100)
|
await client.get_messages('username', 100)
|
||||||
|
|
||||||
# NOW you can use the ID, anywhere!
|
# NOW you can use the ID, anywhere!
|
||||||
await client.send_message(123456, 'Hi!')
|
await client.send_message(123456, 'Hi!')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user