Starter Gear
Starter Gear

Reputation: 11

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.

Upvotes: 0

Views: 705

Answers (2)

Starter Gear
Starter Gear

Reputation: 11

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)

Upvotes: 0

nb123
nb123

Reputation: 84

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!

Upvotes: 0

Related Questions