from pyrogram import Client,filters
from re import match
from traceback import format_exc
import datetime
import pytz
app = Client("bot",8,"7245de8e747a0d6fbe11f7cc14fcc0bb")
@app.on_message(filters.me)
async def handler(c,m):
try:
text = m.text
ltext = text.lower()
replyid = m.reply_to_message_id
chat_id = m.chat.id
if ltext in ('/start','ping'):
await m.edit('✅️ ربات آنلاین است')
elif (mc := match('(?ism)^set\s+(\d+)\s+(.+)',text)) and replyid:
gm = await c.get_messages(chat_id,replyid)
sec = int(mc.group(1))
chat = int(mc.group(2)) if mc.group(2).strip('-').isnumeric() else mc.group(2)
utc_now = datetime.datetime.utcnow()
iran_tz = pytz.timezone('Asia/Tehran')
iran_now = utc_now.astimezone(iran_tz)
for _ in range(5):
sec+=sec
iran = iran_now + datetime.timedelta(seconds=sec)
obj = datetime.datetime.strptime(str(iran), "%Y-%m-%d %H:%M:%S.%f%z")
await gm.copy(chat,schedule_date=obj)
await m.edit("✅️ 100 پیام با فاصله {} ثانیه برای {} زمان بندی شد".format(mc.group(1),mc.group(2)))
except Exception:
await m.edit(format_exc())
app.run()