skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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)
            pass
        pass
    
    def GetListPics(InImages):
        L_Out = []
        for img in InImages:
            L_Out.append(InputMediaPhoto(img))
            pass
        return L_Out
        pass
    
    Pics = GetListPics(['pic_01.jpg', 'pic_02.jpg', 'pic_03.jpg'])
    SendMsg(Pics, NextTime)
    

  2. Not sure why you would need Python when you can simply schedule a message via the app (unless you are trying to schedule with multiple recepients). If that is the case and you want to use Python, I believe you will need to use a bot. If you go down this route, look into JobQueues in the python-telegram-bot package. Here is the link to the job queues wiki for more information. Hope this helps!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search