瀏覽代碼

Temp commit

TheHamkerCat 5 年之前
父節點
當前提交
a19d21f341
共有 3 個文件被更改,包括 9 次插入 和 12 次删除
  1. 0 1
      requirements.txt
  2. 1 1
      sample_config.py
  3. 8 10
      wbb/modules/search.py

+ 0 - 1
requirements.txt

@@ -9,7 +9,6 @@ requests
 speedtest-cli
 uvloop
 youtube_dl
-youtube_search
 search_engine_parser
 cryptography
 googletrans==4.0.0-rc1

+ 1 - 1
sample_config.py

@@ -16,4 +16,4 @@ fernet_encryption_key = "iKMq0WZMnJKjMQxZWKtv-cplMuF_LoyshXj0XbTGGWM="
 captcha_delay_in_seconds = 300
 
 # Leave This As It Is
-ARQ_API_BASE_URL = "http://52.0.6.104:8000/"
+ARQ_API_BASE_URL = "https://thearq.tech/"

+ 8 - 10
wbb/modules/search.py

@@ -1,9 +1,9 @@
-from youtube_search import YoutubeSearch
 from search_engine_parser import GoogleSearch
 from pyrogram import filters
 from requests import get
-from wbb import app
+from wbb import app, ARQ
 from wbb.utils.errors import capture_err
+from wbb.utils.fetch import fetch
 
 __MODULE__ = "Search"
 __HELP__ = '''/ud - Search For Something In Urban Dictionary
@@ -22,12 +22,10 @@ async def urbandict(_, message):
         await message.reply_text('"/ud" Needs An Argument.')
         return
     text = message.text.split(None, 1)[1]
-    api = "http://api.urbandictionary.com/v0/define?term="
-
     try:
-        results = get(f"{api}{text}").json()
-        reply_text = f'Definition: {results["list"][0]["definition"]}'
-        reply_text += f'\n\nExample: {results["list"][0]["example"]}'
+        results = await fetch(f"{ARQ}ud?query={text}")
+        reply_text = f"""Definition: {results["list"][0]["definition"]}
+Example: {results["list"][0]["example"]}"""
     except IndexError:
         reply_text = ("Sorry could not find any matching results!")
     ignore_chars = "[]"
@@ -46,7 +44,7 @@ async def urbandict(_, message):
 async def google(_, message):
     try:
         if len(message.command) < 2:
-            await message.reply_text('"/google" Needs An Argument')
+            await message.reply_text('/google Needs An Argument')
             return
         text = message.text.split(None, 1)[1]
         gresults = await GoogleSearch().async_search(text, 1)
@@ -133,10 +131,10 @@ async def ytsearch(_, message):
             return
         query = message.text.split(None, 1)[1]
         m = await message.reply_text("Searching....")
-        results = YoutubeSearch(query, max_results=4).to_dict()
+        results = await fetch(f"{ARQ}youtube?query={query}&count=3")
         i = 0
         text = ""
-        while i < 4:
+        while i < 3:
             text += f"Title - {results[i]['title']}\n"
             text += f"Duration - {results[i]['duration']}\n"
             text += f"Views - {results[i]['views']}\n"