diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-02-28 21:39:55 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-02-28 21:39:55 +0100 |
| commit | 35585cf63627fae82ae0659752c48e3e588470f2 (patch) | |
| tree | 42f49f21540a02f2a3778d7403ede065063e7a0e | |
| download | tg-35585cf63627fae82ae0659752c48e3e588470f2.tar.gz | |
basic one-on-one chat
| -rw-r--r-- | main.py | 35 | ||||
| -rw-r--r-- | requirements.txt | 2 |
2 files changed, 37 insertions, 0 deletions
@@ -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()) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5bbbe19 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +aioconsole==0.3.1 +Telethon==1.20 |
