TypeError: Cannot cast NoneType to any kind of Peer.
@client.on(events.NewMessage(chats=[ids]))
async def my_event_handler(event):
me = await client.get_me()
username = me.username
try:
from_ = await event.client.get_entity(event.from_id)
except ValueError:
pass
if event.file:
path = await client.download_media(event.media, "./media/")
if event.file.name == None:
await client.send_message("me", f"{from_.username}: (File name is None)")
await client.send_message("me", f"auto-downloader: (File name is None) saved to ./media/")
print(f"file | | (File name is None) downloaded")
else:
await client.send_message("me", f"{from_.username}: {event.file.name}")
await client.send_message("me", f"auto-downloader: {event.file.name} saved to ./media/")
print(f"file | | {event.file.name} downloaded")
else:
await client.send_message("me", f"{from_.username}: {event.text}")
print(f"msg | {from_.username} | {event.text}")
@client.on(events.NewMessage(chats=[ids]))
async def my_event_handler(event):
me = await client.get_me()
username = me.username
try:
from_ = await event.client.get_entity(event.from_id)
if event.from_id is not None:
from_ = await event.client.get_entity(event.from_id)
except ValueError:
pass
if event.file:
path = await client.download_media(event.media, "./media/")
if event.file.name == None:
await client.send_message("me", f"{from_.username}: (File name is None)")
await client.send_message("me", f"auto-downloader: (File name is None) saved to ./media/")
print(f"file | | (File name is None) downloaded")
else:
await client.send_message("me", f"{from_.username}: {event.file.name}")
await client.send_message("me", f"auto-downloader: {event.file.name} saved to ./media/")
print(f"file | | {event.file.name} downloaded")
else:
await client.send_message("me", f"{from_.username}: {event.text}")
print(f"msg | {from_.username} | {event.text}")