Skip to content

Instantly share code, notes, and snippets.

@x0x8x
Created April 21, 2020 03:25
Show Gist options
  • Save x0x8x/75a43842a53e7f5590ccf37f99b5218f to your computer and use it in GitHub Desktop.
Save x0x8x/75a43842a53e7f5590ccf37f99b5218f 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