My goal is to have this code repeat, i'm using the schedule module with telethon. Using a variation of different methods from both libraries, the close I get is this, but when trying to get the scheduled message to repeat, it gets error: "RuntimeWarning: coroutine 'main' was never awaited self._run_job(job) RuntimeWarning: Enable tracemalloc to get the object allocation traceback"
from telethon import TelegramClient
from telethon.tl.types import InputPeerChannel
from datetime import timedelta
import schedule
import time
api_id = 12345
api_hash = 'xxxxxxxxxxxxx'
client = TelegramClient('user', api_id, api_hash).start()
channel = InputPeerChannel = [09876poiuy, 12345qwert]
async def main():
for channel in InputPeerChannel:
await client.send_file(channel, 'img_url', caption="It's me!", schedule=timedelta(minutes=1))
with client:
client.loop.run_until_complete(main())
schedule.every(30).seconds.do(main)
while True:
schedule.run_pending()
time.sleep(1)
Alternatively, I've tried with same result :
@repeat(every(10).minutes)
async def main():
for channel in InputPeerChannel:
await client.send_file(channel, 'img_url', caption="It's me!")
with client:
client.loop.run_until_complete(main())
while True:
run_pending()
time.sleep(1)
I've tried adding await, changing the order of code, but i can't figure out a solution. Any insight would be appreciated!