I have this function code, when I call it, output is my list printed but this list doesn't return.
from pyrogram import Client
from pyrogram import enums
async def search_for_deals(message_to_search):
async with client:
async for message in client.search_global(query=message_to_search, limit=40):
if message.from_user.username not in filter_list:
try:
filter_list.append(message.from_user.username)
message_list.append(message.text+'\n\n'+'@'+message.from_user.username+'\n'+str(message.date)+
f'\n[Link to offer [{message.chat.title}]](https://t.me/{message.chat.username}/{message.id})')
except Exception as error:
print(error)
continue
print(message_list) #output1
return message_list
api_id = 'xxxxxx'
api_hash = 'xxxxxxx'
client = Client("mybot", api_id=api_id, api_hash=api_hash)
filter_list, message_list = [], []
list = client.run(search_for_deals(str(input())))
print(list) # needed output2
Output:
[1,2,3,4,5]
None
I still can't figure out how to return from this function.