mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +03:00
Update usage of deprecated methods in the docs
This commit is contained in:
parent
387a255221
commit
5d9cf513bd
|
@ -48,7 +48,7 @@ Basic Usage
|
||||||
|
|
||||||
# Retrieving messages from a chat
|
# Retrieving messages from a chat
|
||||||
from telethon import utils
|
from telethon import utils
|
||||||
for message in client.get_message_history('username', limit=10):
|
for message in client.iter_messages('username', limit=10):
|
||||||
print(utils.get_display_name(message.sender), message.message)
|
print(utils.get_display_name(message.sender), message.message)
|
||||||
|
|
||||||
# Listing all the dialogs (conversations you have open)
|
# Listing all the dialogs (conversations you have open)
|
||||||
|
@ -60,7 +60,7 @@ Basic Usage
|
||||||
|
|
||||||
# Once you have a message with .media (if message.media)
|
# Once you have a message with .media (if message.media)
|
||||||
# you can download it using client.download_media():
|
# you can download it using client.download_media():
|
||||||
messages = client.get_message_history('username')
|
messages = client.get_messages('username')
|
||||||
client.download_media(messages[0])
|
client.download_media(messages[0])
|
||||||
|
|
||||||
**More details**: :ref:`telegram-client`
|
**More details**: :ref:`telegram-client`
|
||||||
|
|
|
@ -67,7 +67,7 @@ Many other common methods for quick scripts are also available:
|
||||||
|
|
||||||
# The utils package has some goodies, like .get_display_name()
|
# The utils package has some goodies, like .get_display_name()
|
||||||
from telethon import utils
|
from telethon import utils
|
||||||
for message in client.get_message_history('username', limit=10):
|
for message in client.iter_messages('username', limit=10):
|
||||||
print(utils.get_display_name(message.sender), message.message)
|
print(utils.get_display_name(message.sender), message.message)
|
||||||
|
|
||||||
# Dialogs are the conversations you have open
|
# Dialogs are the conversations you have open
|
||||||
|
|
|
@ -288,7 +288,7 @@ use :tl:`GetMessagesViewsRequest`, setting ``increment=True``:
|
||||||
|
|
||||||
|
|
||||||
# Obtain `channel' through dialogs or through client.get_entity() or anyhow.
|
# Obtain `channel' through dialogs or through client.get_entity() or anyhow.
|
||||||
# Obtain `msg_ids' through `.get_message_history()` or anyhow. Must be a list.
|
# Obtain `msg_ids' through `.get_messages()` or anyhow. Must be a list.
|
||||||
|
|
||||||
client(GetMessagesViewsRequest(
|
client(GetMessagesViewsRequest(
|
||||||
peer=channel,
|
peer=channel,
|
||||||
|
|
|
@ -207,7 +207,7 @@ class InteractiveTelegramClient(TelegramClient):
|
||||||
# History
|
# History
|
||||||
elif msg == '!h':
|
elif msg == '!h':
|
||||||
# First retrieve the messages and some information
|
# First retrieve the messages and some information
|
||||||
messages = self.get_message_history(entity, limit=10)
|
messages = self.get_messages(entity, limit=10)
|
||||||
|
|
||||||
# Iterate over all (in reverse order so the latest appear
|
# Iterate over all (in reverse order so the latest appear
|
||||||
# the last in the console) and print them with format:
|
# the last in the console) and print them with format:
|
||||||
|
@ -216,7 +216,7 @@ class InteractiveTelegramClient(TelegramClient):
|
||||||
# Note that the .sender attribute is only there for
|
# Note that the .sender attribute is only there for
|
||||||
# convenience, the API returns it differently. But
|
# convenience, the API returns it differently. But
|
||||||
# this shouldn't concern us. See the documentation
|
# this shouldn't concern us. See the documentation
|
||||||
# for .get_message_history() for more information.
|
# for .iter_messages() for more information.
|
||||||
name = get_display_name(msg.sender)
|
name = get_display_name(msg.sender)
|
||||||
|
|
||||||
# Format the message content
|
# Format the message content
|
||||||
|
|
|
@ -34,7 +34,7 @@ class HigherLevelTests(unittest.TestCase):
|
||||||
progress_callback=lambda c, t:
|
progress_callback=lambda c, t:
|
||||||
print('test_cdn_download:uploading {:.2%}...'.format(c/t))
|
print('test_cdn_download:uploading {:.2%}...'.format(c/t))
|
||||||
)
|
)
|
||||||
msg = client.get_message_history(me)[1][0]
|
msg = client.get_messages(me)[1][0]
|
||||||
|
|
||||||
out = BytesIO()
|
out = BytesIO()
|
||||||
client.download_media(msg, out)
|
client.download_media(msg, out)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user