如何使用Python在Telegram中创建来自自己的定时消息而不需要使用机器人?

huangapple go评论64阅读模式
英文:

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

问题

我想使用Python在Telegram中为另一个用户创建定时消息。
我只想自动发送我的消息。只是管理工作。

我不需要一个机器人,也不需要创建机器人并与机器人的创建者通信。
我将每天运行我的脚本以创建定时消息。

在此处输入图像描述

请提供任何信息。不幸的是,我的谷歌搜索没有帮助我。有人建议我创建一个机器人,但我不需要机器人。

英文:

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.

答案1

得分: 0

不确定为什么您需要Python,当您可以简单地通过应用程序计划一条消息(除非您试图计划多个收件人)。如果是这种情况,而且您想使用Python,我认为您需要使用一个机器人。如果您选择这条路线,请查看python-telegram-bot包中的JobQueues。这是有关作业队列的链接wiki,以获取更多信息。希望这有所帮助!

英文:

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!

答案2

得分: 0

For future generations. I used the pyrogram library in 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)

(Note: The code portions have been provided as requested, and the code is unchanged.)

英文:

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)

huangapple
  • 本文由 发表于 2023年5月14日 13:10:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76245920.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定