Quellcode durchsuchen

Removed rose adapter, added inline pastebin

TheHamkerCat vor 5 Jahren
Ursprung
Commit
63905c3d52
3 geänderte Dateien mit 43 neuen und 79 gelöschten Zeilen
  1. 29 14
      wbb/modules/inline.py
  2. 0 65
      wbb/modules/rose_adapter.py
  3. 14 0
      wbb/utils/inlinefuncs.py

+ 29 - 14
wbb/modules/inline.py

@@ -3,24 +3,30 @@ from wbb.utils.inlinefuncs import (
     google_search_func, urban_func, translate_func,
     alive_function, webss, shortify, wall_func,
     saavn_func, deezer_func, inline_help_func,
-    torrent_func, youtube_func, lyrics_func
+    torrent_func, youtube_func, lyrics_func,
+    paste_func
 )
 from pyrogram import filters
 
 __MODULE__ = "Inline"
-__HELP__ = """
-**alive** - __Check Bot's Stats.__
-**tr [LANGUAGE_CODE] [QUERY]** - __Translate Text.__
-**ud [QUERY]** - __Urban Dictionary Query.__
-**google [QUERY]** - __Google Search.__
-**webss [URL]** - __Take Screenshot Of A Website.__
-**bitly [URL]** - __Shorten A Link.__
-**wall [Query]** - __Find Wallpapers.__
-**saavn [SONG_NAME]** - __Get Songs From Saavn.__
-**deezer [SONG_NAME]** - __Get Songs From Deezer.__
-**yt [Query]** - __Youtube Search.__
-**torrent [QUERY]** - __Torrent Search.__
-**lyrics [Query]** - __Lyrics Search.__"""
+__HELP__ = '''```+===============================================================+
+|            Query            |           Function              |
++===============================================================+
+|  alive                      |  Check Bot's Stats.             |
+|  tr [LANGUAGE_CODE] [QUERY] |  Translate Text.                |
+|  ud      [QUERY]            |  Urban Dictionary Query.        |
+|  google  [QUERY]            |  Google Search.                 |
+|  webss   [URL]              |  Take Screenshot Of A Website.  |
+|  bitly   [URL]              |  Shorten A Link.                |
+|  wall    [QUERY]            |  Find Wallpapers.               |
+|  saavn   [SONG_NAME]        |  Get Songs From Saavn.          |
+|  deezer  [SONG_NAME]        |  Get Songs From Deezer.         |
+|  yt      [Query]            |  Youtube Search.                |
+|  torrent [QUERY]            |  Torrent Search.                |
+|  lyrics  [QUERY]            |  Lyrics Search.                 |
+|  paste   [TEXT]             |  Pase Text On Pastebin. <=500   |
++===============================================================+
+```'''
 
 
 @app.on_message(filters.command("inline"))
@@ -135,5 +141,14 @@ async def inline_query_handler(client, query):
                 results=answerss
             )
 
+        elif text.split()[0] == "paste":
+            tex = text.split(None, 1)[1]
+            answerss = await paste_func(answers, tex)
+            await client.answer_inline_query(
+                query.id,
+                results=answerss,
+                cache_time=2
+            )
+
     except (IndexError, TypeError, KeyError, ValueError):
         return

+ 0 - 65
wbb/modules/rose_adapter.py

@@ -1,65 +0,0 @@
-from wbb import app, app2
-from wbb.utils.errors import capture_err
-from pyrogram import filters
-import asyncio
-
-__MODULE__ = "RoseFeds"
-__HELP__ = "/fbanstat [USERNAME|USER_ID]"
-
-miss_rose = "MissRose_bot"
-limit_text = "This command can only be used once every 1 minute."
-
-processing = False
-
-
-@app.on_message(filters.command("fbanstat"))
-@capture_err
-async def fbanstat(_, message):
-    global processing
-    if processing:
-        await message.reply_text("One Query Is Already Going On.")
-        return
-    try:
-        processing = True
-        if len(message.command) == 2 and not message.reply_to_message:
-            user = message.text.strip().split(None, 1)[1]
-        elif len(message.command) == 1 and not message.reply_to_message:
-            user = message.from_user.id
-        elif len(message.command) == 1 and message.reply_to_message:
-            user = message.reply_to_message.from_user.id
-        else:
-            await message.reply_text("**Usage:**\n/fbanstat [USERNAME | USER_ID | REPLY]")
-            return
-        m = await message.reply_text("**Processing**")
-        rose_reply = await app2.ask(miss_rose, f"/fbanstat {user}")
-        rose_reply_text = rose_reply.text
-        rose_reply_message_id = rose_reply.message_id
-        if rose_reply_text.strip() == limit_text:
-            await m.edit(limit_text)
-            processing = False
-            return
-        loop_limit = 0
-        while True:
-            msgg = await app2.get_messages(miss_rose, rose_reply_message_id)
-            if msgg.text == rose_reply_text:
-                await asyncio.sleep(2)
-                if loop_limit > 4:
-                    await m.edit(rose_reply_text)
-                    processing = False
-                    return
-                loop_limit += 1
-                continue
-            rose_reply = msgg.text.markdown
-            if "Looks" in rose_reply:
-                await m.edit("Too Many Fbans, Rose Sent A "
-                             "Fban File, Person Is A Legit Spammer.")
-                processing = False
-                return
-            rose_reply = rose_reply.strip()
-            await m.edit(rose_reply)
-            processing = False
-            return
-    except Exception as e:
-        processing = False
-        await message.reply_text(e)
-        return

+ 14 - 0
wbb/utils/inlinefuncs.py

@@ -381,3 +381,17 @@ async def lyrics_func(answers, text):
             input_message_content=InputTextMessageContent(msg)
         ))
     return answers
+
+
+async def paste_func(answers, text):
+    start_time = time()
+    url = await paste(text)
+    msg = f"__**{url}**__"
+    end_time = time()
+    answers.append(
+        InlineQueryResultArticle(
+            title=f"Pasted In {round(end_time - start_time)} Seconds.",
+            description=url,
+            input_message_content=InputTextMessageContent(msg)
+        ))
+    return answers