I’m trying to use search function with iter_messages(search_channel, search=foo)
and do not know how to handle when no results are found.
This is not an error, it is just a valid zero results. My expectation was that .total=None
will do the job, but somehow not. When I run debug, than see .total
is set to None
regardless of messages were found or not, only when it goes down to the for
loop .total
will have correct not None
value.
My code is:
def downloader():
client.start()
allFoundMessages=client.iter_messages(search_channel, search=search_line_update())
if allFoundMessages.total is not None:
for message in allFoundMessages:
print(message.id, message.text, 'nn###n')
break
else:
print("Could not find anything by:", search_line_update(), "in:", search_channel )
exit(0)
My expectation is that I can use total to determine if there are any results in a search or not.