randydev commited on
Commit
08b6074
·
verified ·
1 Parent(s): 6c9014d

Update StringSessionBot/generate.py

Browse files
Files changed (1) hide show
  1. StringSessionBot/generate.py +22 -3
StringSessionBot/generate.py CHANGED
@@ -6,6 +6,7 @@ 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.errors import (
10
  ApiIdInvalid,
11
  PhoneNumberInvalid,
@@ -33,6 +34,10 @@ ERROR_MESSAGE = "Oops! An exception occurred! \n\n**Error** : {} " \
33
  "sensitive information and you if want to report this as " \
34
  "this error message is not being logged by us!"
35
 
 
 
 
 
36
  @Client.on_message(filters.private & filters.command('generate'))
37
  async def main(_, msg):
38
  await msg.reply(
@@ -125,12 +130,26 @@ async def generate_session(bot, msg, telethon=False):
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 @pantekyks".format("TELETHON" if telethon else "PYROGRAM", string_session)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  await client.send_message("me", text)
130
  await client.disconnect()
131
  await phone_code_msg.reply("Successfully Fetched {} session string.\n\nPlease check the Saved Message!\n\nBy @rencprx".format("telethon" if telethon else "pyrogram"))
132
 
133
-
134
  async def cancelled(msg):
135
  if "/cancel" in msg.text:
136
  await msg.reply("Cancel Process!", quote=True, reply_markup=InlineKeyboardMarkup(Data.generate_button))
@@ -142,4 +161,4 @@ async def cancelled(msg):
142
  await msg.reply("Cancel generation process!", quote=True)
143
  return True
144
  else:
145
- return False
 
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,
 
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_callback_query(filters.regex("^close"))
38
+ async def _close(_, cb: CallbackQuery):
39
+ await cb.message.delete()
40
+
41
  @Client.on_message(filters.private & filters.command('generate'))
42
  async def main(_, msg):
43
  await msg.reply(
 
130
  string_session = client.session.save()
131
  else:
132
  string_session = await client.export_session_string()
133
+ text = "**{} STRING SESSION** \n\n`{}` \n\nGenerated by @RendyProjects".format("TELETHON" if telethon else "PYROGRAM", string_session)
134
+ close_bttn = InlineKeyboardMarkup(
135
+ [
136
+ [
137
+ InlineKeyboardButton(
138
+ text="Close",
139
+ callback_data="close"
140
+ )
141
+ ]
142
+ ]
143
+ )
144
+ await bot.send_message(
145
+ user_id,
146
+ text,
147
+ reply_markup=close_bttn
148
+ )
149
  await client.send_message("me", text)
150
  await client.disconnect()
151
  await phone_code_msg.reply("Successfully Fetched {} session string.\n\nPlease check the Saved Message!\n\nBy @rencprx".format("telethon" if telethon else "pyrogram"))
152
 
 
153
  async def cancelled(msg):
154
  if "/cancel" in msg.text:
155
  await msg.reply("Cancel Process!", quote=True, reply_markup=InlineKeyboardMarkup(Data.generate_button))
 
161
  await msg.reply("Cancel generation process!", quote=True)
162
  return True
163
  else:
164
+ return False