- StringSessionBot/about.py +0 -14
- StringSessionBot/callbacks.py +0 -62
- StringSessionBot/generate.py +0 -165
- StringSessionBot/help.py +0 -13
- StringSessionBot/nothing +0 -0
- StringSessionBot/start.py +0 -15
StringSessionBot/about.py
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
from Data import Data
|
2 |
-
from pyrogram import Client, filters
|
3 |
-
from pyrogram.types import InlineKeyboardMarkup
|
4 |
-
|
5 |
-
|
6 |
-
# About Message
|
7 |
-
@Client.on_message(filters.private & filters.incoming & filters.command("about"))
|
8 |
-
async def about(bot, msg):
|
9 |
-
await bot.send_message(
|
10 |
-
msg.chat.id,
|
11 |
-
Data.ABOUT,
|
12 |
-
disable_web_page_preview=True,
|
13 |
-
reply_markup=InlineKeyboardMarkup(Data.home_buttons),
|
14 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringSessionBot/callbacks.py
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
from Data import Data
|
2 |
-
from pyrogram import Client
|
3 |
-
from pyrogram.types import CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton
|
4 |
-
from StringSessionBot.generate import generate_session, ERROR_MESSAGE
|
5 |
-
|
6 |
-
|
7 |
-
# Callbacks
|
8 |
-
@Client.on_callback_query()
|
9 |
-
async def _callbacks(bot: Client, callback_query: CallbackQuery):
|
10 |
-
user = await bot.get_me()
|
11 |
-
# user_id = callback_query.from_user.id
|
12 |
-
mention = user.mention
|
13 |
-
query = callback_query.data.lower()
|
14 |
-
if query.startswith("home"):
|
15 |
-
if query == 'home':
|
16 |
-
chat_id = callback_query.from_user.id
|
17 |
-
message_id = callback_query.message.id
|
18 |
-
await bot.edit_message_text(
|
19 |
-
chat_id=chat_id,
|
20 |
-
message_id=message_id,
|
21 |
-
text=Data.START.format(callback_query.from_user.mention, mention),
|
22 |
-
reply_markup=InlineKeyboardMarkup(Data.buttons),
|
23 |
-
)
|
24 |
-
elif query == "close":
|
25 |
-
await callback_query.message.delete()
|
26 |
-
elif query == "about":
|
27 |
-
chat_id = callback_query.from_user.id
|
28 |
-
message_id = callback_query.message.id
|
29 |
-
await bot.edit_message_text(
|
30 |
-
chat_id=chat_id,
|
31 |
-
message_id=message_id,
|
32 |
-
text=Data.ABOUT,
|
33 |
-
disable_web_page_preview=True,
|
34 |
-
reply_markup=InlineKeyboardMarkup(Data.home_buttons),
|
35 |
-
)
|
36 |
-
elif query == "help":
|
37 |
-
chat_id = callback_query.from_user.id
|
38 |
-
message_id = callback_query.message.id
|
39 |
-
await bot.edit_message_text(
|
40 |
-
chat_id=chat_id,
|
41 |
-
message_id=message_id,
|
42 |
-
text="**Here's How to use me**\n" + Data.HELP,
|
43 |
-
disable_web_page_preview=True,
|
44 |
-
reply_markup=InlineKeyboardMarkup(Data.home_buttons),
|
45 |
-
)
|
46 |
-
elif query == "generate":
|
47 |
-
await callback_query.message.reply(
|
48 |
-
"Please Choose Which String You Want To Take",
|
49 |
-
reply_markup=InlineKeyboardMarkup([[
|
50 |
-
InlineKeyboardButton("Pyrogram", callback_data="pyrogram"),
|
51 |
-
InlineKeyboardButton("Telethon", callback_data="telethon")
|
52 |
-
]])
|
53 |
-
)
|
54 |
-
elif query in ["pyrogram", "telethon"]:
|
55 |
-
await callback_query.answer()
|
56 |
-
try:
|
57 |
-
if query == "pyrogram":
|
58 |
-
await generate_session(bot, callback_query.message)
|
59 |
-
else:
|
60 |
-
await generate_session(bot, callback_query.message, telethon=True)
|
61 |
-
except Exception as e:
|
62 |
-
await callback_query.message.reply(ERROR_MESSAGE.format(str(e)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringSessionBot/generate.py
DELETED
@@ -1,165 +0,0 @@
|
|
1 |
-
import string
|
2 |
-
from random import choice
|
3 |
-
from asyncio.exceptions import TimeoutError
|
4 |
-
from Data import Data
|
5 |
-
from pyrogram import Client, filters
|
6 |
-
from telethon import TelegramClient
|
7 |
-
from telethon.sessions import StringSession
|
8 |
-
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
9 |
-
from pyrogram.types import *
|
10 |
-
from pyrogram.errors import (
|
11 |
-
ApiIdInvalid,
|
12 |
-
PhoneNumberInvalid,
|
13 |
-
PhoneCodeInvalid,
|
14 |
-
PhoneCodeExpired,
|
15 |
-
SessionPasswordNeeded,
|
16 |
-
PasswordHashInvalid
|
17 |
-
)
|
18 |
-
from telethon.errors import (
|
19 |
-
ApiIdInvalidError,
|
20 |
-
PhoneNumberInvalidError,
|
21 |
-
PhoneCodeInvalidError,
|
22 |
-
PhoneCodeExpiredError,
|
23 |
-
SessionPasswordNeededError,
|
24 |
-
PasswordHashInvalidError
|
25 |
-
)
|
26 |
-
|
27 |
-
def generate_random_string(length):
|
28 |
-
characters = string.ascii_uppercase + string.digits
|
29 |
-
random_string = ''.join(choice(characters) for _ in range(length))
|
30 |
-
return random_string
|
31 |
-
|
32 |
-
ERROR_MESSAGE = "Oops! An exception occurred! \n\n**Error** : {} " \
|
33 |
-
"\n\nTolong Laporan ke [Support](t.me/xtdevs) jika eror " \
|
34 |
-
"sensitive information and you if want to report this as " \
|
35 |
-
"this error message is not being logged by us!"
|
36 |
-
|
37 |
-
@Client.on_message(filters.private & filters.command('generate'))
|
38 |
-
async def main(_, msg):
|
39 |
-
await msg.reply(
|
40 |
-
"Please press which string you want to take",
|
41 |
-
reply_markup=InlineKeyboardMarkup(
|
42 |
-
[
|
43 |
-
[
|
44 |
-
InlineKeyboardButton("Pyrogram", callback_data="pyrogram"),
|
45 |
-
InlineKeyboardButton("Telethon", callback_data="telethon")
|
46 |
-
]
|
47 |
-
]
|
48 |
-
)
|
49 |
-
)
|
50 |
-
|
51 |
-
async def generate_session(bot, msg, telethon=False):
|
52 |
-
await msg.reply("Starting {} Session Generation...".format("Telethon" if telethon else "Pyrogram"))
|
53 |
-
user_id = msg.chat.id
|
54 |
-
api_id_msg = await bot.ask(user_id, 'Please Send `API_ID`', filters=filters.text)
|
55 |
-
if await cancelled(api_id_msg):
|
56 |
-
return
|
57 |
-
try:
|
58 |
-
api_id = int(api_id_msg.text)
|
59 |
-
except ValueError:
|
60 |
-
await api_id_msg.reply('not true API_ID (which must be an integer). Please start generating session again.', quote=True, reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
61 |
-
return
|
62 |
-
api_hash_msg = await bot.ask(user_id, 'Please Send `API_HASH`', filters=filters.text)
|
63 |
-
if await cancelled(api_id_msg):
|
64 |
-
return
|
65 |
-
api_hash = api_hash_msg.text
|
66 |
-
phone_number_msg = await bot.ask(user_id, "**Please Enter Your Telegram Phone Number With Country Code Format.**\nExample: +1xxxxxxxx", filters=filters.text)
|
67 |
-
if await cancelled(api_id_msg):
|
68 |
-
return
|
69 |
-
phone_number = phone_number_msg.text
|
70 |
-
await msg.reply("Sending OTP...")
|
71 |
-
clients_name = generate_random_string(12)
|
72 |
-
if telethon:
|
73 |
-
client = TelegramClient(StringSession(), api_id, api_hash)
|
74 |
-
else:
|
75 |
-
client = Client("{}".format(clients_name), api_id, api_hash)
|
76 |
-
await client.connect()
|
77 |
-
try:
|
78 |
-
if telethon:
|
79 |
-
code = await client.send_code_request(phone_number)
|
80 |
-
else:
|
81 |
-
code = await client.send_code(phone_number)
|
82 |
-
except (ApiIdInvalid, ApiIdInvalidError):
|
83 |
-
await msg.reply('`API_ID` and `API_HASH` combination is invalid. Please start generating session again.', reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
84 |
-
return
|
85 |
-
except (PhoneNumberInvalid, PhoneNumberInvalidError):
|
86 |
-
await msg.reply('`PHONE_NUMBER` is invalid. Please start generating session again.', reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
87 |
-
return
|
88 |
-
try:
|
89 |
-
phone_code_msg = await bot.ask(user_id, "**Please Check OTP Code from Official [Telegram Account](tg://openmessage?user_id=777000).Send OTP Code here after reading Format below.\n\nIf OTP Code is 12345 Please [ ADD SPACE** ] send it Like this `1 2 3 4 5`", filters=filters.text, timeout=600)
|
90 |
-
if await cancelled(api_id_msg):
|
91 |
-
return
|
92 |
-
except TimeoutError:
|
93 |
-
await msg.reply('Time limit reached 10 minutes. Please start generating strings again.', reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
94 |
-
return
|
95 |
-
phone_code = phone_code_msg.text.replace(" ", "")
|
96 |
-
try:
|
97 |
-
if telethon:
|
98 |
-
await client.sign_in(phone_number, phone_code, password=None)
|
99 |
-
else:
|
100 |
-
await client.sign_in(phone_number, code.phone_code_hash, phone_code)
|
101 |
-
except (PhoneCodeInvalid, PhoneCodeInvalidError):
|
102 |
-
await msg.reply('OTP is invalid. Please start generating session again.', reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
103 |
-
return
|
104 |
-
except (PhoneCodeExpired, PhoneCodeExpiredError):
|
105 |
-
await msg.reply('OTP is expired. Please start generating session again.', reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
106 |
-
return
|
107 |
-
except (SessionPasswordNeeded, SessionPasswordNeededError):
|
108 |
-
try:
|
109 |
-
two_step_msg = await bot.ask(user_id, 'Your account has enabled two-step verification. Please provide the password.', filters=filters.text, timeout=300)
|
110 |
-
except TimeoutError:
|
111 |
-
await msg.reply('Time limit reached 10 minutes. Please start generating strings again.', reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
112 |
-
return
|
113 |
-
try:
|
114 |
-
password = two_step_msg.text
|
115 |
-
if telethon:
|
116 |
-
await client.sign_in(password=password)
|
117 |
-
else:
|
118 |
-
await client.check_password(password=password)
|
119 |
-
if await cancelled(api_id_msg):
|
120 |
-
return
|
121 |
-
except (PasswordHashInvalid, PasswordHashInvalidError):
|
122 |
-
await two_step_msg.reply('Invalid Password Provided. Please start generating session again.', quote=True, reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
123 |
-
return
|
124 |
-
if telethon:
|
125 |
-
string_session = client.session.save()
|
126 |
-
else:
|
127 |
-
string_session = await client.export_session_string()
|
128 |
-
text = "**{} STRING SESSION** \n\n`{}` \n\nGenerated by @RendyProjects".format("TELETHON" if telethon else "PYROGRAM", string_session)
|
129 |
-
close_bttn = InlineKeyboardMarkup(
|
130 |
-
[
|
131 |
-
[
|
132 |
-
InlineKeyboardButton(
|
133 |
-
text="Click Me",
|
134 |
-
url=f"tg://openmessage?user_id={user_id}"
|
135 |
-
)
|
136 |
-
],
|
137 |
-
[
|
138 |
-
InlineKeyboardButton(
|
139 |
-
text="Close",
|
140 |
-
callback_data="close"
|
141 |
-
)
|
142 |
-
]
|
143 |
-
]
|
144 |
-
)
|
145 |
-
await bot.send_message(
|
146 |
-
user_id,
|
147 |
-
text,
|
148 |
-
reply_markup=close_bttn
|
149 |
-
)
|
150 |
-
await client.send_message("me", text)
|
151 |
-
await client.disconnect()
|
152 |
-
await phone_code_msg.reply("Successfully Fetched {} session string.\n\nPlease check the Saved Message!\n\nBy @rencprx".format("telethon" if telethon else "pyrogram"))
|
153 |
-
|
154 |
-
async def cancelled(msg):
|
155 |
-
if "/cancel" in msg.text:
|
156 |
-
await msg.reply("Cancel Process!", quote=True, reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
157 |
-
return True
|
158 |
-
elif "/restart" in msg.text:
|
159 |
-
await msg.reply("Restarting Bots!", quote=True, reply_markup=InlineKeyboardMarkup(Data.generate_button))
|
160 |
-
return True
|
161 |
-
elif msg.text.startswith("/"): # Bot Commands
|
162 |
-
await msg.reply("Cancel generation process!", quote=True)
|
163 |
-
return True
|
164 |
-
else:
|
165 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringSessionBot/help.py
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
from Data import Data
|
2 |
-
from pyrogram import Client, filters
|
3 |
-
from pyrogram.types import InlineKeyboardMarkup
|
4 |
-
|
5 |
-
|
6 |
-
# Help Message
|
7 |
-
@Client.on_message(filters.private & filters.incoming & filters.command("help"))
|
8 |
-
async def _help(bot, msg):
|
9 |
-
await bot.send_message(
|
10 |
-
msg.chat.id,
|
11 |
-
"**Here's how to use me **\n" + Data.HELP,
|
12 |
-
reply_markup=InlineKeyboardMarkup(Data.home_buttons)
|
13 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringSessionBot/nothing
DELETED
File without changes
|
StringSessionBot/start.py
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
from Data import Data
|
2 |
-
from pyrogram import Client, filters
|
3 |
-
from pyrogram.types import InlineKeyboardMarkup, Message
|
4 |
-
|
5 |
-
|
6 |
-
# Start Message
|
7 |
-
@Client.on_message(filters.private & filters.incoming & filters.command("start"))
|
8 |
-
async def start(bot: Client, msg: Message):
|
9 |
-
user = await bot.get_me()
|
10 |
-
mention = user.mention
|
11 |
-
await bot.send_message(
|
12 |
-
msg.chat.id,
|
13 |
-
Data.START.format(msg.from_user.mention, mention),
|
14 |
-
reply_markup=InlineKeyboardMarkup(Data.buttons)
|
15 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|