Last active
March 9, 2020 11:27
-
-
Save vrumger/4fca9cee2c692b64d15cda3caadfebc6 to your computer and use it in GitHub Desktop.
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
from telethon import TelegramClient, events | |
import asyncio | |
client = TelegramClient(name, api_id, api_hash) | |
client.start(phone_number) | |
@client.on(events.NewMessage(pattern='(?i)!type (.+)')) | |
async def typewriter(event): | |
sleep_time = 0.3 | |
text = event.pattern_match.group(1) | |
index = 1 | |
old_text = '' | |
msg = await event.reply('|') | |
await asyncio.sleep(sleep_time) | |
while old_text != text: | |
old_text = text[:index] | |
index += 1 | |
await msg.edit('`%s`' % (old_text + '|')) | |
await asyncio.sleep(sleep_time); | |
await msg.edit('`%s`' % (old_text.strip())) | |
await asyncio.sleep(sleep_time) | |
client.run_until_disconnected() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment