Feature 'with client:' syntax in the examples

This commit is contained in:
Lonami Exo
2018-06-27 10:03:26 +02:00
parent e604960a1d
commit b834b6c16c
2 changed files with 20 additions and 27 deletions

View File

@@ -10,7 +10,6 @@ This script assumes that you have certain files on the working directory,
such as "xfiles.m4a" or "anytime.png" for some of the automated replies.
"""
import re
import asyncio
from collections import defaultdict
from datetime import datetime, timedelta
from os import environ
@@ -77,8 +76,6 @@ async def my_handler(event: events.NewMessage.Event):
await event.edit(event.text.replace('.shrug', r'¯\_(ツ)_/¯'))
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(client.start(phone=environ.get('TG_PHONE')))
with client.start():
print('(Press Ctrl+C to stop this)')
client.run_until_disconnected()