blob: b56a692380ee7b1dd336a8ed97ada049f6f8222c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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())
'''
|