-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathStringGen.py
78 lines (67 loc) · 2.58 KB
/
StringGen.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyleft (c) 2020 Mr.Miss, All wrongs reserved.
#
# Redistribution and use in source with or
# without modufication, are permitted.
import time
from telethon.sync import TelegramClient
from telethon.sessions import StringSession
from pyrogram import Client
select = " "
docs = """Generate your Telegram String Session
P -->> Pyrogram [https://docs.pyrogram.org]
T -->> Telethon [https://docs.telethon.dev]
"""
tutor = """
~ 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
"""
template = """
UserBot support: @userbotindo
<code>STRING_SESSION</code>: <code>{}</code>
⚠️ <b>Please be carefull to pass this value to third parties</b>"""
print(docs)
while select != ("p", "t"):
select = input("Enter your required client < p / t > : ").lower()
if select == "t":
print("""\nTelethon selected\nRunning script...""")
time.sleep(1)
print(tutor)
API_KEY = int(input("Enter API_KEY here: "))
API_HASH = input("Enter API_HASH here: ")
with TelegramClient(StringSession(), API_KEY, API_HASH) as client:
session_string = client.session.save()
saved_messages_template = "Telethon session" + template.format(
session_string)
print("\nGenerating String Session...\n")
client.send_message("me",
saved_messages_template,
parse_mode="html")
time.sleep(1)
print(
"Your STRING_SESSION value have been sent to your Telegram Saved Messages"
)
break
elif select == "p":
print("""\nPyrogram selected.\nRunning script...""")
time.sleep(1)
print(tutor)
with Client("UserBot",
api_id=int(input("Enter API ID: ")),
api_hash=input("Enter API HASH: ")) as pyrogram:
saved_messages_template = "Pyrogram session" + template.format(
pyrogram.export_session_string())
print("\nGenerating String session...\n")
pyrogram.send_message("me",
saved_messages_template,
parse_mode="html")
time.sleep(1)
print(
"Your STRING_SESSION value have been sent to your Telegram Saved Messages"
)
break
else:
print("\nPlease only select P or T\n")
time.sleep(1.5)