-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
helper_sign_in.py
123 lines (114 loc) · 6.16 KB
/
helper_sign_in.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# thanks to @SpEcHiDe (shriMADhav) for this plugin
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# UniBorg Telegram UseRBot
# Copyright (C) 2020 @UniBorg
# This code is licensed under
# the "you can't use this for anything - public or private,
# unless you know the two prime factors to the number below" license
#
# 76420267623546914285312953847595971404341698667641514250876752277272387319730719447944190236554292723287731288464885804750741761364327420735484520254795074034271100312534358762695139153809201139028342591690162180482749102700757709533577692364027644748874488672927686880394116645482754406114234995849466230628072343395577643542244898329670772406248890522958479425726186109846556166785296629623349390742033833661187669196367578138285625089404848643493377827537273669265993240595087539269421233264244215402846901329418276845584435165797641413600630197168449069124329071377882018664252635437935498247362577995000876370559921979986167467150242719108997966389358573614338347798942075025019524334410765076448079346402255279475454578911100171143362383701997345247071665044229776967047890105530288552675523382282543070978365198408375296102481704475022808512560332288875562645323407287276387630426464690604583020202716621432448074540765228575710411577376747565205168211778277438102839283208230298551765603915629876539090653002258100860161813070337131517342747019595180737118037884721995383231810660641212174692945512923696997890453647367133871298033535417493414711299792390309624922324695948156041420140711933411174201608157710806470205328887
#
# https://github.com/udf/uniborg/raw/kate/stdplugins/sp_lonami_gay.py
# വിവരണം അടിച്ചുമാറ്റിക്കൊണ്ട് പോകുന്നവർ ക്രെഡിറ്റ് വെച്ചാൽ സന്തോഷമേ ഉള്ളു..!
import logging
import secrets
from telethon import TelegramClient
from alchemysession import AlchemySessionContainer
from telethon.errors.rpcerrorlist import (
SessionPasswordNeededError,
PhoneCodeInvalidError
)
async def bleck_megick(event, config_jbo):
bot_me = await event.client.get_me()
print(bot_me.stringify())
if bot_me.username.lower() == config_jbo.TG_BOT_USER_NAME_BF_HER.lower() and int(event.chat_id) == int(config_jbo.SUDO_USERS[0]):
# force int for Type checks
# 🤣🤣 validations
async with event.client.conversation(event.chat_id) as conv:
await conv.send_message(
"welcome **master**\n"
"please send me your Phone Number, to generate "
"`HU_STRING_SESSION` \n"
"Enter the Phone Number that you want to make awesome, "
"powered by @UniBorg"
)
msg2 = await conv.get_response()
logging.info(msg2.stringify())
phone = msg2.message.strip()
container = AlchemySessionContainer(config_jbo.DB_URI)
session_id = str(secrets.randbelow(1000000))
session = container.new_session(session_id)
current_client = TelegramClient(
session,
api_id=config_jbo.APP_ID,
api_hash=config_jbo.API_HASH,
device_model="GNU/Linux nonUI",
app_version="@UniBorg 2.0",
lang_code="ml"
)
await current_client.connect()
sent = await current_client.send_code_request(phone)
logging.info(sent)
if not sent:
await conv.send_message(
"This number is not registered on Telegram. "
"Please check your #karma by reading https://t.me/c/1220993104/28753"
)
return
await conv.send_message(
"This number is registered on Telegram. "
"Please input the verification code "
"that you receive from [Telegram](tg://user?id=777000) "
"seperated by space, "
"else a `PhoneCodeInvalidError` would be raised."
)
msg4 = await conv.get_response()
received_code = msg4.message.strip()
received_tfa_code = None
received_code = "".join(received_code.split(" "))
try:
await current_client.sign_in(
phone,
code=received_code,
password=received_tfa_code
)
except PhoneCodeInvalidError:
await conv.send_message(
"Invalid Code Received. "
"Please re /start"
)
return
except SessionPasswordNeededError:
await conv.send_message(
"The entered Telegram Number is protected with 2FA. "
"Please enter your second factor authentication code.\n"
"__This message "
"will only be used for generating your string session, "
"and will never be used for any other purposes "
"than for which it is asked.__"
"\n\n"
"The code is available for review at "
"https://github.com/SpEcHiDe/UniBorg/raw/master/helper_sign_in.py"
)
msg6 = await conv.get_response()
received_tfa_code = msg6.message.strip()
await current_client.sign_in(password=received_tfa_code)
# all done
# Getting information about yourself
current_client_me = await current_client.get_me()
# "me" is an User object. You can pretty-print
# any Telegram object with the "stringify" method:
logging.info(current_client_me.stringify())
string_session_messeg = await conv.send_message(
f"{session_id}"
)
await string_session_messeg.reply(
"now, "
"please turn of the application "
"and set the above variable to "
"`HU_STRING_SESSION` variable, "
"and restart application."
)
else:
await event.reply("un authorized -_- user(s)")