Browse Source

Inline youtube

TheHamkerCat 5 years ago
parent
commit
8ebdc97b31
4 changed files with 5 additions and 102 deletions
  1. 1 0
      requirements.txt
  2. 0 18
      wbb/modules/inline.py
  3. 0 39
      wbb/modules/userbot.py
  4. 4 45
      wbb/utils/inlinefuncs.py

+ 1 - 0
requirements.txt

@@ -22,3 +22,4 @@ TgCrypto
 telegraph
 uvloop
 youtube_dl
+bs4

+ 0 - 18
wbb/modules/inline.py

@@ -210,24 +210,6 @@ async def inline_query_handler(client, query):
                 results=answerss
             )
 
-        elif text.split()[0] == "eval":
-            if len(text.split()) < 2:
-                await client.answer_inline_query(
-                    query.id,
-                    results=answers,
-                    switch_pm_text='Evaluate Code | eval [CODE]',
-                    switch_pm_parameter='inline',
-                )
-                return
-            user_id = query.from_user.id
-            tex = text.split(None, 1)[1].strip()
-            answerss = await eval_func(answers, tex, user_id)
-            await client.answer_inline_query(
-                query.id,
-                results=answerss,
-                cache_time=2
-            )
-
         elif text.split()[0] == "gh_user":
             if len(text.split()) < 2:
                 await client.answer_inline_query(

+ 0 - 39
wbb/modules/userbot.py

@@ -162,42 +162,3 @@ async def shellrunner(client, message):
         await edit_or_reply(
             message,
             text=f'**INPUT:**\n```{text}```\n\n**OUTPUT: **\n`No output`')
-
-""" The code below is for inline eval"""
-
-
-async def aexec2(code, client):
-    exec(
-        "async def __aexecc(client): "
-        + "".join(f"\n {a}" for a in code.split("\n"))
-    )
-    return await locals()["__aexecc"](client)
-
-
-async def eval_executer_func(code):
-    old_stderr = sys.stderr
-    old_stdout = sys.stdout
-    redirected_output = sys.stdout = StringIO()
-    redirected_error = sys.stderr = StringIO()
-    stdout, stderr, exc = None, None, None
-    try:
-        await aexec2(code, app)
-    except Exception:
-        exc = traceback.format_exc()
-    stdout = redirected_output.getvalue()
-    stderr = redirected_error.getvalue()
-    sys.stdout = old_stdout
-    sys.stderr = old_stderr
-    evaluation = ""
-    if exc:
-        evaluation = exc
-    elif stderr:
-        evaluation = stderr
-    elif stdout:
-        evaluation = stdout
-    else:
-        evaluation = "Success"
-    output = evaluation.strip()
-    final_output = (
-        f"**INPUT:**\n```{code}```\n\n**OUTPUT**:\n```{output}```")
-    return [final_output, output]

+ 4 - 45
wbb/utils/inlinefuncs.py

@@ -44,7 +44,6 @@ from time import time, ctime
 from random import randint
 from wbb.utils.fetch import fetch
 from wbb.modules.user_info import get_user_info
-from wbb.modules.userbot import eval_executer_func
 from wbb.modules.music import download_youtube_audio
 from wbb.utils.functions import test_speedtest, get_http_status_code, make_carbon
 from wbb.utils.formatter import convert_seconds_to_minutes as time_convert
@@ -62,7 +61,7 @@ async def inline_help_func(__HELP__):
     keywords_list = [
         "alive", "ping", "tr", "ud", "google", "bitly",
         "wall", "yt", "torrent", "lyrics", "wiki",
-        "speedtest", "eval", "music", "saavn", "deezer",
+        "speedtest", "music", "saavn", "deezer",
         "gh_repo", "gh_user", "search", "pastebin",
         "nsfw_scan", "ytmusic", "carbon", "info"
     ]
@@ -421,49 +420,6 @@ async def lyrics_func(answers, text):
     return answers
 
 
-async def eval_func(answers, text, user_id):
-    if user_id not in SUDOERS:
-        msg = "**ERROR**\n__THIS FEATURE IS ONLY FOR SUDO USERS__"
-        answers.append(
-            InlineQueryResultArticle(
-                title="ERROR",
-                description="THIS FEATURE IS ONLY FOR SUDO USERS",
-                input_message_content=InputTextMessageContent(msg)
-            ))
-        return answers
-    if str(text)[-1] != ":":
-        msg = "**ERROR**\n__Put A ':' After The Code To Execute It__"
-        answers.append(
-            InlineQueryResultArticle(
-                title="ERROR",
-                description="Put A ':' After The Code To Execute It",
-                input_message_content=InputTextMessageContent(msg)
-            ))
-
-        return answers
-    text = text[0:-1]
-    result = await eval_executer_func(text)
-    res = result[0]
-    output = result[1]
-    time_taken = result[2]
-    msg = f"{res}"
-    button = InlineKeyboard(row_width=1)
-    button.add(
-        InlineKeyboardButton(
-            text=f"{time_taken} Seconds",
-            callback_data="ok_lol"
-        )
-    )
-    answers.append(
-        InlineQueryResultArticle(
-            title=f"Took {time_taken} Seconds.",
-            description=output,
-            reply_markup=button,
-            input_message_content=InputTextMessageContent(msg)
-        ))
-    return answers
-
-
 async def github_user_func(answers, text):
     URL = f"https://api.github.com/users/{text}"
     result = await fetch(URL)
@@ -840,6 +796,9 @@ async def yt_music_func(answers, url, user_id):
                 input_message_content=InputTextMessageContent(msg)
             ))
         return answers
+    if "http" not in url:
+        url = await arq.youtube(url)[0]
+        url = f"https://youtube.com{url.url_suffix}"
     title, performer, duration, audio, thumbnail = await download_youtube_audio(url)
     m = await app.send_audio(
         MESSAGE_DUMP_CHAT,