forked from KoyoTeam/Alphonse
-
Notifications
You must be signed in to change notification settings - Fork 1
/
string_session.py
28 lines (22 loc) · 945 Bytes
/
string_session.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
#!/usr/bin/env python3
# (c) https://t.me/TelethonChat/37677 and SpEcHiDe
from telethon.sessions import StringSession
from telethon.sync import TelegramClient
print(
"""Please go-to my.telegram.org
Login using your Telegram account
Click on API Development Tools
Create a new application, by entering the required details
Check your Telegram saved messages section to copy the STRING_SESSION"""
)
API_KEY = int(input("Enter APP_ID (the shorter one): "))
API_HASH = input("Enter API_HASH (the longer one): ")
with TelegramClient(StringSession(), API_KEY, API_HASH) as client:
print("Check your Saved Messages in Telegram!")
session_string = client.session.save()
saved_messages_template = """Support: @AlphonseSupport
<code>STRING_SESSION</code>: <code>{}</code>
⚠️ <i>Do NOT send this to anyone else!</i>""".format(
session_string
)
client.send_message("me", saved_messages_template, parse_mode="html")