-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdates.py
51 lines (39 loc) · 1.31 KB
/
updates.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from telethon import TelegramClient, sync
from telethon import TelegramClient, events
from Crypto.Cipher import AES
import base64
from time import sleep
import sys
from pyfiglet import Figlet
f = Figlet(font='slant')
print(f.renderText('TG-Encrypter'))
## Use your own api id and hash
api_id = 123456
api_hash = 'abcdef01234567890'
key = '1234567890123456'
cipher = AES.new(key, AES.MODE_ECB)
try:
client = TelegramClient('rec_session', api_id, api_hash)
client.start()
me = client.get_me()
user = client.get_entity(sys.argv[1])
def receive():
@client.on(events.NewMessage)
async def my_event_handler(event):
if(event.original_update.user_id == user.id):
raw = event.raw_text
decoded = cipher.decrypt(base64.b64decode(raw))
msg = decoded.decode('utf-8').lstrip()
if(event.message.out == False):
print(user.username+"<< "+msg)
else:
print(me.username+">> "+msg)
#if msg == "{quit}":
# print(user.username +" left the conversation, Exiting!! ")
# client.disconnect()
# quit()
client.start()
client.run_until_disconnected()
receive()
finally:
client.disconnect()