Parcourir la source

Removed OCR & Fixed eval doc

TheHamkerCat il y a 5 ans
Parent
commit
cac75bee4a
4 fichiers modifiés avec 6 ajouts et 99 suppressions
  1. 3 3
      wbb/modules/devs.py
  2. 0 1
      wbb/modules/misc.py
  3. 0 92
      wbb/modules/ocr.py
  4. 3 3
      wbb/modules/userbot.py

+ 3 - 3
wbb/modules/devs.py

@@ -86,13 +86,13 @@ async def executor(client, message):
         )
         await message.reply_document(
             document=filename,
-            caption=cmd,
-            disable_notification=True,
+            caption=f"`{cmd[0:1020]}`",
+            quote=False,
             reply_to_message_id=reply_to_id,
             reply_markup=keyboard,
         )
-        os.remove(filename)
         await message.delete()
+        os.remove(filename)
     else:
         t2 = time()
         keyboard = InlineKeyboardMarkup(

+ 0 - 1
wbb/modules/misc.py

@@ -48,7 +48,6 @@ __HELP__ = """
 /weather [City] - To Get Weather Info
 /tr [en] - Translate A Message
 /json [URL] - Get JSON Response From An API or Something.
-/ocr - Perform OCR On An Image.
 /arq - Statistics Of ARQ API.
 #RTFM - Check it lol
 """

+ 0 - 92
wbb/modules/ocr.py

@@ -1,92 +0,0 @@
-"""
-MIT License
-
-Copyright (c) 2021 TheHamkerCat
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-"""
-import os
-
-from pyrogram import filters
-from pyrogram.errors.exceptions.bad_request_400 import MessageEmpty
-
-from wbb import app, arq
-from wbb.core.decorators.errors import capture_err
-from wbb.utils.functions import transfer_sh
-
-
-@app.on_message(filters.command("ocr"))
-@capture_err
-async def image_ocr(_, message):
-    if not message.reply_to_message:
-        await message.reply_text("Reply to an image or document to perform OCR on it.")
-        return
-    reply = message.reply_to_message
-    if (
-        not reply.document
-        and not reply.photo
-        and not reply.sticker
-        and not reply.animation
-        and not reply.video
-    ):
-        await message.reply_text(
-            "Reply to an image/document/sticker/animation to perform OCR on it."
-        )
-        return
-    m = await message.reply_text("Scanning")
-    if reply.document:
-        if int(reply.document.file_size) > 3145728:
-            await m.edit("File too large")
-            return
-        mime_type = reply.document.mime_type
-        if mime_type != "image/png" and mime_type != "image/jpeg":
-            await m.edit("Document Mimetype Invalid")
-            return
-        file_id = reply.document.file_id
-    if reply.sticker:
-        if reply.sticker.is_animated:
-            if not reply.sticker.thumbs:
-                await m.edit("Sticker Has No Thumb")
-                return
-            file_id = reply.sticker.thumbs[0].file_id
-        else:
-            file_id = reply.sticker.file_id
-
-    if reply.photo:
-        file_id = reply.photo.file_id
-
-    if reply.animation:
-        if not reply.animation.thumbs:
-            await m.edit("Gif Has No Thumbnail, so it cannot be scanned for OCR")
-            return
-        file_id = reply.animation.thumbs[0].file_id
-
-    if reply.video:
-        if not reply.video.thumbs:
-            return
-        file_id = reply.video.thumbs[0].file_id
-    file = await app.download_media(file_id)
-    url = await transfer_sh(file)
-    os.remove(file)
-    data = await arq.ocr(url)
-    try:
-        await m.edit(data.result)
-    except MessageEmpty:
-        await m.edit("There's no text in that image.")
-        return

+ 3 - 3
wbb/modules/userbot.py

@@ -89,12 +89,12 @@ async def executor(client, message):
             out_file.write(str(evaluation.strip()))
         await message.reply_document(
             document=filename,
-            caption=cmd,
-            disable_notification=True,
+            caption=f"`{cmd[0:1020]}`",
+            quote=False,
             reply_to_message_id=reply_to_id,
         )
-        os.remove(filename)
         await message.delete()
+        os.remove(filename)
     else:
         await edit_or_reply(message, text=final_output)