Skip to content

Instantly share code, notes, and snippets.

@muhammedfurkan
Forked from x0x8x/aioschedule_telethon.py
Created April 25, 2020 19:57
Show Gist options
  • Save muhammedfurkan/8d39d7205c5313fe807fe3bbf6ecba47 to your computer and use it in GitHub Desktop.
Save muhammedfurkan/8d39d7205c5313fe807fe3bbf6ecba47 to your computer and use it in GitHub Desktop.
schedules in telethon
import aioschedule as schedule
import asyncio
from telethon import TelegramClient
with TelegramClient(
os.path.abspath(fileName),
config.getint("api", "api_id"),
config.get("api", "api_hash"),
connection_retries=15,
retry_delay=3,
auto_reconnect=True,
) as client:
print("Activated")
def send_message_to_me():
client.send_message("me", "some string")
schedule.every(10).seconds.do(send_message_to_me)
loop = asyncio.get_event_loop()
client.run_until_disconnected()
while True:
loop.run_until_complete(schedule.run_pending())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment