summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rw-r--r--main.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..8ab18f2
--- /dev/null
+++ b/main.py
@@ -0,0 +1,35 @@
+import aioconsole
+import logging
+import telethon
+
+import credentials
+
+logging.basicConfig(
+ format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s',
+ level=logging.WARNING
+)
+client = telethon.TelegramClient(
+ "first_test",
+ credentials.API_ID,
+ credentials.API_HASH
+)
+
+
+@client.on(telethon.events.NewMessage)
+async def new_message(event):
+ print(event.raw_text)
+
+
+async def send_lines(recipient):
+ while True:
+ line = await aioconsole.ainput()
+ await client.send_message(recipient, line)
+
+
+async def main():
+ await send_lines(recipient=input("Phone number to chat with: "))
+
+
+with client:
+ client.start()
+ client.loop.run_until_complete(main())