Reputation: 8538
I am using Telethon package in Python to search for unique message from a channel. I am using the following code to search from the channel I am subscribed to:
for index, x in enumerate(client.iter_messages(group_name, search='New York')): TODO
As you can notice, I am searching for a single keyword "New York". I would like to search for multiple keywords using Logical Operator like "New York or Miami or Dallas or Houston"
Any idea how to do it ?
Upvotes: 0
Views: 2077
Reputation: 13
You can define new function to "merge" multiple words if any and then it will work pretty well. E.g. like here:
def search_line_update(search_hashtag, search_serie_number):
search_line = ( str(search_hashtag) + str(search_serie_number) )
return search_line
# Search for particular episod and download it
def downloader():
client.start()
serie_number_to_update=0
for message in client.iter_messages(search_channel, search=search_line_update(search_hashtag, search_serie_number)):
print(message.id, message.text, '\n\n###\n')
Upvotes: 0
Reputation: 1237
When you use the parameter search= you are using the messages.search
request from the API which does the search server side so you can't use logical operations.
To use logical operations you could use iter_messages and get all messages then get their .text and search in those.
Upvotes: 1