mirror of https://github.com/coddrago/Heroku
Fix initial setup (pass auth)
parent
8e838ffb7a
commit
0b3a19fe90
|
@ -215,7 +215,7 @@ def get_callback_handlers(mod):
|
|||
class Modules:
|
||||
"""Stores all registered modules"""
|
||||
|
||||
def __init__(self, use_inline=True):
|
||||
def __init__(self):
|
||||
self.commands = {}
|
||||
self.aliases = {}
|
||||
self.modules = [] # skipcq: PTC-W0052
|
||||
|
@ -225,7 +225,6 @@ class Modules:
|
|||
self.client = None
|
||||
self._initial_registration = True
|
||||
self.added_modules = None
|
||||
self.use_inline = use_inline
|
||||
|
||||
def register_all(self, mods=None):
|
||||
"""Load all modules in the module directory"""
|
||||
|
@ -420,9 +419,7 @@ class Modules:
|
|||
# can access its `init_complete`
|
||||
inline_manager = inline.InlineManager(client, db, self)
|
||||
|
||||
# Register only if it is not disabled
|
||||
if self.use_inline:
|
||||
await inline_manager._register_manager()
|
||||
await inline_manager._register_manager()
|
||||
|
||||
# We save it to `Modules` attribute, so not to re-init
|
||||
# it everytime module is loaded. Then we can just
|
||||
|
|
|
@ -143,7 +143,6 @@ def parse_arguments():
|
|||
parser.add_argument("--phone", "-p", action="append")
|
||||
parser.add_argument("--token", "-t", action="append", dest="tokens")
|
||||
parser.add_argument("--no-nickname", "-nn", dest="no_nickname", action="store_true")
|
||||
parser.add_argument("--no-inline", dest="use_inline", action="store_false")
|
||||
parser.add_argument("--hosting", "-lh", dest="hosting", action="store_true")
|
||||
parser.add_argument("--web-only", dest="web_only", action="store_true")
|
||||
parser.add_argument("--no-web", dest="web", action="store_false")
|
||||
|
@ -510,7 +509,7 @@ class Hikka:
|
|||
|
||||
async def _handle_setup(self, client, db) -> None:
|
||||
await db.init()
|
||||
modules = loader.Modules(self.arguments.use_inline)
|
||||
modules = loader.Modules()
|
||||
babelfish = Translator([], [], self.arguments.data_root)
|
||||
await babelfish.init(client)
|
||||
|
||||
|
|
|
@ -206,18 +206,29 @@ class Web:
|
|||
ops = []
|
||||
|
||||
for user in self.client_data.values():
|
||||
bot = user[0].inline.bot
|
||||
msg = await bot.send_message(
|
||||
(await user[1].get_me()).id,
|
||||
(
|
||||
"👩🎤🔐 <b>Click button below to confirm web application ops</b>\n\n"
|
||||
"<i>If you did not request any codes, simply ignore this message</i>"
|
||||
),
|
||||
parse_mode="HTML",
|
||||
disable_web_page_preview=True,
|
||||
reply_markup=markup,
|
||||
)
|
||||
ops += [bot.delete_message(msg.chat.id, msg.message_id)]
|
||||
try:
|
||||
bot = user[0].inline.bot
|
||||
msg = await bot.send_message(
|
||||
(await user[1].get_me()).id,
|
||||
(
|
||||
"👩🎤🔐 <b>Click button below to confirm web application ops</b>\n\n"
|
||||
"<i>If you did not request any codes, simply ignore this message</i>"
|
||||
),
|
||||
parse_mode="HTML",
|
||||
disable_web_page_preview=True,
|
||||
reply_markup=markup,
|
||||
)
|
||||
ops += [bot.delete_message(msg.chat.id, msg.message_id)]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
session = f"hikka_{rand(16)}"
|
||||
|
||||
if not ops:
|
||||
# If no auth message was sent, just leave it empty
|
||||
# probably, request was a bug and user doesn't have
|
||||
# inline bot or did not authorize any sessions
|
||||
return web.Response(body=session)
|
||||
|
||||
if not await main.hikka.wait_for_web_auth(token):
|
||||
return web.Response(body="TIMEOUT")
|
||||
|
@ -225,8 +236,6 @@ class Web:
|
|||
for op in ops:
|
||||
await op
|
||||
|
||||
session = f"hikka_{rand(16)}"
|
||||
|
||||
self._sessions += [session]
|
||||
|
||||
return web.Response(body=session)
|
||||
|
|
Loading…
Reference in New Issue