Answer the question
In order to leave comments, you need to log in
How to interpret messages.search Telegram API response?
The task is to get the texts of the channel's messages in Telegram.
I use a ready-made library for python - https://github.com/LonamiWebs/Telethon
Specifically, I use the method to search for messages - telethon.readthedocs.io/en/latest/extra/examples/w...
from telethon.tl.functions.messages import SearchRequest
from telethon.tl.types import InputMessagesFilterEmpty
filter = InputMessagesFilterEmpty()
result = client(SearchRequest(
peer=client.get_input_entity("channel_name"), # On which chat/conversation
q='me', # What to search for // link to "t.me/"
filter=filter, # Filter to use (maybe filter for media)
min_date=None, # Minimum date
max_date=None, # Maximum date
offset_id=0, # ID of the message to use as offset
add_offset=0, # Additional offset
limit=10, # How many results
max_id=0, # Maximum message ID
min_id=0, # Minimum message ID
from_id=None # Who must have sent the message (peer)
))
print(result.stringify())
returns an error:Traceback (most recent call last):
File "telegram.py", line 55, in <module>
print(result)
File "D:\Progs\Puthon3\lib\encodings\cp1251.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 1011-1013: character maps to <undefined>
result
through dir()
, I also did not find anything similar to the text. pprint(result)
displaystelethon.tl.types.messages.ChannelMessages object at 0x05E287F0
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question