mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 20:50:22 +03:00
Improve code exapmle in "Doing stuff" section
I noticed that there is no initialization of `me` variable. But finally I decided to copy the whole example from docs because it contains more useful code and comments.
This commit is contained in:
parent
06bc761a5b
commit
582ca2ead2
23
README.rst
23
README.rst
|
@ -46,12 +46,29 @@ Doing stuff
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
print(me.stringify())
|
# Getting information about yourself
|
||||||
|
print(client.get_me().stringify())
|
||||||
|
|
||||||
client.send_message('username', 'Hello! Talking to you from Telethon')
|
# Sending a message (you can use 'me' or 'self' to message yourself)
|
||||||
|
client.send_message('username', 'Hello World from Telethon!')
|
||||||
|
|
||||||
|
# Sending a file
|
||||||
client.send_file('username', '/home/myself/Pictures/holidays.jpg')
|
client.send_file('username', '/home/myself/Pictures/holidays.jpg')
|
||||||
|
|
||||||
client.download_profile_photo(me)
|
# Retrieving messages from a chat
|
||||||
|
from telethon import utils
|
||||||
|
for message in client.get_message_history('username', limit=10):
|
||||||
|
print(utils.get_display_name(message.sender), message.message)
|
||||||
|
|
||||||
|
# Listing all the dialogs (conversations you have open)
|
||||||
|
for dialog in client.get_dialogs(limit=10):
|
||||||
|
print(utils.get_display_name(dialog.entity), dialog.draft.message)
|
||||||
|
|
||||||
|
# Downloading profile photos (default path is the working directory)
|
||||||
|
client.download_profile_photo('username')
|
||||||
|
|
||||||
|
# Once you have a message with .media (if message.media)
|
||||||
|
# you can download it using client.download_media():
|
||||||
messages = client.get_message_history('username')
|
messages = client.get_message_history('username')
|
||||||
client.download_media(messages[0])
|
client.download_media(messages[0])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user