Browse Source

translate

TheHamkerCat 5 years ago
parent
commit
ad1c8540f8
5 changed files with 42 additions and 26 deletions
  1. 1 1
      wbb/modules/admin.py
  2. 1 1
      wbb/modules/misc.py
  3. 3 1
      wbb/utils/dbfunctions.py
  4. 10 2
      wbb/utils/fetch.py
  5. 27 21
      wbb/utils/functions.py

+ 1 - 1
wbb/modules/admin.py

@@ -561,7 +561,7 @@ async def check_warns(_, message: Message):
 
 
 @app.on_message(
-    filters.command(["report", "admins"], prefixes=["@", "/"])
+    (filters.command("report") | filters.command("admins", prefixes="@"))
     & ~filters.edited
     & ~filters.private
 )

+ 1 - 1
wbb/modules/misc.py

@@ -257,7 +257,7 @@ async def tr(_, message):
             + "/latest/#googletrans-languages"
         )
     reply = message.reply_to_message
-    text = message.text or message.reply
+    text = reply.text or reply.caption
     if not text:
         return await message.reply_text(
             "Reply to a text to translate it"

+ 3 - 1
wbb/utils/dbfunctions.py

@@ -780,7 +780,9 @@ async def update_trust_db(user_id: int, new_data: float):
     if len(data) >= 100:
         data = data[:99]
     data.append(new_data)
-    data = [i for i in data if isinstance(i, float) or isinstance(i, int)]
+    data = [
+        i for i in data if isinstance(i, float) or isinstance(i, int)
+    ]
     await trustdb.update_one(
         {"user_id": user_id},
         {"$set": {"data": data}},

+ 10 - 2
wbb/utils/fetch.py

@@ -22,8 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 """
 from asyncio import gather
+
 from wbb import aiohttpsession as session
 
+
 async def fetch(url: str, *args, **kwargs):
     async with session.get(url, *args, **kwargs) as resp:
         try:
@@ -41,8 +43,14 @@ async def post(url: str, *args, **kwargs):
             data = await resp.text()
     return data
 
+
 async def multifetch(url: str, times: int, *args, **kwargs):
-    return await gather(*[fetch(url, *args, **kwargs) for _ in range(times)])
+    return await gather(
+        *[fetch(url, *args, **kwargs) for _ in range(times)]
+    )
+
 
 async def multipost(url: str, times: int, *args, **kwargs):
-    return await gather(*[post(url, *args, **kwargs) for _ in range(times)])
+    return await gather(
+        *[post(url, *args, **kwargs) for _ in range(times)]
+    )

+ 27 - 21
wbb/utils/functions.py

@@ -36,7 +36,8 @@ import speedtest
 from PIL import Image, ImageDraw, ImageFilter, ImageFont
 from wget import download
 
-from wbb import aiohttpsession as aiosession, arq
+from wbb import aiohttpsession as aiosession
+from wbb import arq
 from wbb.utils import aiodownloader
 from wbb.utils.fetch import fetch
 
@@ -235,28 +236,33 @@ async def extract_user_and_reason(message):
 async def extract_user(message):
     return (await extract_user_and_reason(message))[0]
 
+
 async def test_ARQ(message):
     results = ""
-    funcs ={"deezer": arq.deezer("attention", 1),
-            "image": arq.image("something"),
-            "luna": arq.luna("hello"),
-            "lyrics": arq.lyrics("attention"),
-            "nlp": arq.nlp("bitcoin"),
-            "nsfw_scan": arq.nsfw_scan(url="https://www.pixsy.com/wp-content/uploads/2021/04/ben-sweet-2LowviVHZ-E-unsplash-1.jpeg"),
-            "pornhub": arq.pornhub("incest"),
-            "proxy": arq.proxy(),
-            "pypi": arq.pypi("python-arq"),
-            "reddit": arq.reddit("porn"),
-            "quotly": arq.quotly(message),
-            "saavn": arq.saavn("attention"),
-            "stats": arq.stats(),
-            "tmdb": arq.tmdb("flash"),
-            "torrent": arq.torrent("porn"),
-            "translate": arq.translate("hello"),
-            "urbandict": arq.urbandict("wtf"),
-            "wall": arq.wall("anime"),
-            "wiki": arq.wiki("cat"),
-            "youtube": arq.youtube("never gonna give you up")}
+    funcs = {
+        "deezer": arq.deezer("attention", 1),
+        "image": arq.image("something"),
+        "luna": arq.luna("hello"),
+        "lyrics": arq.lyrics("attention"),
+        "nlp": arq.nlp("bitcoin"),
+        "nsfw_scan": arq.nsfw_scan(
+            url="https://www.pixsy.com/wp-content/uploads/2021/04/ben-sweet-2LowviVHZ-E-unsplash-1.jpeg"
+        ),
+        "pornhub": arq.pornhub("incest"),
+        "proxy": arq.proxy(),
+        "pypi": arq.pypi("python-arq"),
+        "reddit": arq.reddit("porn"),
+        "quotly": arq.quotly(message),
+        "saavn": arq.saavn("attention"),
+        "stats": arq.stats(),
+        "tmdb": arq.tmdb("flash"),
+        "torrent": arq.torrent("porn"),
+        "translate": arq.translate("hello"),
+        "urbandict": arq.urbandict("wtf"),
+        "wall": arq.wall("anime"),
+        "wiki": arq.wiki("cat"),
+        "youtube": arq.youtube("never gonna give you up"),
+    }
 
     for key, value in funcs.items():
         try: