Language - python, I'm using tdjson.
That's what I'm doing.
First I call
td_send({'@type': 'searchPublicChat', 'username': channelName})
it returns event "chat" with chat_id and supergroup_id.
After I call with chat_id
td_send({'@type': 'searchChatMessages',
'chat_id': chat_id,
'query':"",
'sender_user': 0,
'from_message_id': 0,
'limit': 100,
'offset': 0
})
and I'm getting event "messages", where total_count = 0 and empty list of messages.
but, I know that channel has messages. Please tell me, what I'm doing wrong.
You've tried to search messages using an empty search text, which will always return no messages. You should use getChatHistory instead of search to get the list of all chat messages.
Do not use an empty string to search for messages. At least in this case.
It's interesting to look at the empty messages in the channel.
Please send a screen or log. Thanks.
Leo getChatHistory needs some kind of alias. Many love the intuitive way. But I do not insist on this.
But in no case do you remove getChatHistory. Old people will not understand. Especially the great guys who do Telegram X.
P.S.
Add liberties to the library
Thanks for help! @isopen My problem that sometimes I need to get filtered messages by content type(in my case - Audio). And I don't really care about query particular string. I need all messages with specified content type. I tried using getChatHistory, but it hasn't argument to filter by content type. Is any way to achieve this, or better way to get all messages and after filter them?
@sapelkinAV If you will specify searchMessagesFilterAudio as filter to searchChatMessages, you can leave query empty.
@levlam thank you. But can you suggest how to pass Filter object to tdlibjson from python?
td_send({'@type': 'searchChatMessages',
'chat_id': int(indexedChannels[randomNumber]['id']),
'query': "",
'sender_user': 0,
'from_message_id': 0,
'limit': 100,
'offset': 0,
'filter': 'searchMessagesFilterAudio'
})
this code produces error
[ 1][t 0][1524426929.428133249][ClientJson.cpp:76][&status.is_error()] Failed to parse [request:{\0042@type\0042: \0042searchChatMessages\0042, \0042chat_id\0042: -1001144342523, \0042query\0042: \0042\0042, \0042sender_user\0042: 0, \0042from_message_id\0042: 0, \0042limit\0042: 100, \0042offset\0042: 0, \0042filter\0042: \0042searchMessagesFilterAudio\0042}] [Error : 0 : Expected object, got JsonString]
I read docs and know that I should pass pointer for object somehow, but don't know how to do this in python
'filter':{'@type': 'searchMessagesFilterAudio'}
Thanks everyone!
@levlam is there some way to retrieve all messages (not for a specific chat) something like searchMessages but without query?
No, there is no such way. You need to separately call getChatHistory for every interesting chat.
@levlam thanks!