pythontelegrammessageschedule

How can I create a schedule message in Telegram from myself without a bot with Python?


I want to create a schedule message from me in Telegram to another user with using python. I just want to automate the sending of my messages. Just administration.

I don't need a bot, I don't need to create a bot and communicate with the father of bots. I will be running my script once a day to create a schedule messages.

enter image description here

Please, any information. Unfortunately, my Google searches didn't help me. I am offered to create a bot, but I do not need a bot.


Solution

  • For future generations. I used pyrogram library on python. https://docs.pyrogram.org/intro/quickstart

    from datetime import datetime, timedelta
    from pyrogram import Client
    from pyrogram.types import Message, InputMediaPhoto
    
    api_id = 12345
    api_hash = "0123456789abcdef0123456789abcdef"
    PostChannel = '@mytest'
    
    NextTime = datetime.now() + timedelta(hours=3, minutes=40)
    print(NextTime)
    
    app = Client("my_account", api_id, api_hash)
    
    def SendMsg(InMedia, InScheduleDate):
        with app:
            app.send_media_group(chat_id = PostChannel, media = InMedia, schedule_date = InScheduleDate)
    
    
    def GetListPics(InImages):
        L_Out = []
        for img in InImages:
            L_Out.append(InputMediaPhoto(img))
            
        return L_Out
        
    
    Pics = GetListPics(['pic_01.jpg', 'pic_02.jpg', 'pic_03.jpg'])
    SendMsg(Pics, NextTime)