skip to Main Content

I tried it with different videos and it won’t work. :/

In the docs they clearly say I should do:

await client.send_file(entity = "chat", file="C:\Usersfoldtovideo.mp4", video_note = True)

But it won’t work. :/

2

Answers


  1. entity should be the phone number or userid of the recipient.

    Login or Signup to reply.
  2. To make a long story short.
    The code explanes itself.
    And, of course, your video must be of the appropriate format.

    from telethon import TelegramClient, sync, events
    
    api_id = xxx
    api_hash = 'xxx'
    
    client = TelegramClient('session', api_id, api_hash)
    
    # send any message to your bot
    @client.on(events.NewMessage())
    async def my_event_handler(event):
        
        # the telethon bot can be subscribed to your channel
        if event.message.peer_id.to_dict()['_'] == 'PeerChannel':
            actual_id = event.message.peer_id.to_dict()['channel_id']
        if event.message.peer_id.to_dict()['_'] == 'PeerUser':
            actual_id = event.message.peer_id.to_dict()['user_id']
        
        await client.send_message(actual_id, message = 'Here we go')
    
        file_path = 'C:/Users/fold/to/video.mp4' # make sure the path exists
    
        await client.send_file(actual_id, file=file_path, video_note=True)
            
    client.start()
    client.run_until_disconnected()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search