-
-
Save muhammedfurkan/8d39d7205c5313fe807fe3bbf6ecba47 to your computer and use it in GitHub Desktop.
schedules in telethon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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