MCPcopy Create free account
hub / github.com/VJBots/VJ-Forward-Bot / CLIENT

Class CLIENT

plugins/test.py:43–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41# Ask Doubt on telegram @KingVJ01
42
43class CLIENT:
44 def __init__(self):
45 self.api_id = Config.API_ID
46 self.api_hash = Config.API_HASH
47
48 def user_session(self, data):
49 return Client("USERBOT", self.api_id, self.api_hash, session_string=data)
50
51 async def add_bot(self, bot, message):
52 user_id = int(message.from_user.id)
53 msg = await bot.ask(chat_id=user_id, text=BOT_TOKEN_TEXT)
54 if msg.text=='/cancel':
55 return await msg.reply('<b>process cancelled !</b>')
56 elif not msg.forward_date:
57 return await msg.reply_text("<b>This is not a forward message</b>")
58 elif str(msg.forward_from.id) != "93372553":
59 return await msg.reply_text("<b>This message was not forward from bot father</b>")
60 bot_token = re.findall(r'\d[0-9]{8,10}:[0-9A-Za-z_-]{35}', msg.text, re.IGNORECASE)
61 bot_token = bot_token[0] if bot_token else None
62 if not bot_token:
63 return await msg.reply_text("<b>There is no bot token in that message</b>")
64 try:
65 _client = Client("BOT", Config.API_ID, Config.API_HASH, bot_token=bot_token, in_memory=True)
66 client = await _client.start()
67 except Exception as e:
68 await msg.reply_text(f"<b>BOT ERROR:</b> `{e}`")
69 return
70 _bot = _client.me
71 details = {
72 'id': _bot.id,
73 'is_bot': True,
74 'user_id': user_id,
75 'name': _bot.first_name,
76 'token': bot_token,
77 'username': _bot.username
78 }
79 await db.add_bot(details)
80 return True
81
82 async def add_session(self, bot, message):
83 user_id = int(message.from_user.id)
84 text = "<b>⚠️ DISCLAIMER ⚠️</b>\n\n<code>you can use your session for forward message from private chat to another chat.\nPlease add your pyrogram session with your own risk. Their is a chance to ban your account. My developer is not responsible if your account may get banned.</code>"
85 await bot.send_message(user_id, text=text)
86 phone_number_msg = await bot.ask(chat_id=user_id, text="<b>Please send your phone number which includes country code</b>\n<b>Example:</b> <code>+13124562345</code>")
87 if phone_number_msg.text=='/cancel':
88 return await phone_number_msg.reply('<b>process cancelled !</b>')
89 phone_number = phone_number_msg.text
90 client = Client(":memory:", Config.API_ID, Config.API_HASH)
91 await client.connect()
92 await phone_number_msg.reply("Sending OTP...")
93 try:
94 code = await client.send_code(phone_number)
95 phone_code_msg = await bot.ask(user_id, "Please check for an OTP in official telegram account. If you got it, send OTP here after reading the below format. \n\nIf OTP is `12345`, **please send it as** `1 2 3 4 5`.\n\n**Enter /cancel to cancel The Procces**", filters=filters.text, timeout=600)
96 except PhoneNumberInvalid:
97 await phone_number_msg.reply('`PHONE_NUMBER` **is invalid.**')
98 return
99 if phone_code_msg.text=='/cancel':
100 return await phone_code_msg.reply('<b>process cancelled !</b>')

Callers 3

regix.pyFile · 0.85
settings.pyFile · 0.85
unequeify.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected