Explorar o código

Updated many things

TheHamkerCat %!s(int64=5) %!d(string=hai) anos
pai
achega
713467ef4a

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
+unknown_errors.txt
 *.jpg
 *.jpg
 token.py
 token.py
 *.raw
 *.raw

+ 0 - 0
wbb/utils/errors.py → wbb/core/decorators/errors.py


+ 68 - 34
wbb/core/types/InlineQueryResult.py

@@ -1,27 +1,9 @@
-#  Pyrogram - Telegram MTProto API Client Library for Python
-#  Copyright (C) 2017-2020 Dan <https://github.com/delivrance>
-#
-#  This file is part of Pyrogram.
-#
-#  Pyrogram is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU Lesser General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  Pyrogram is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Lesser General Public License for more details.
-#
-#  You should have received a copy of the GNU Lesser General Public License
-#  along with Pyrogram.  If not, see <http://www.gnu.org/licenses/>.
-
 from typing import Optional, List, Union
 from typing import Optional, List, Union
-import pyrogram
 from pyrogram import raw, types, utils
 from pyrogram import raw, types, utils
-from pyrogram.file_id import FileType
+from pyrogram.file_id import FileType, FileId, PHOTO_TYPES, DOCUMENT_TYPES
 from pyrogram.parser import Parser
 from pyrogram.parser import Parser
 from pyrogram.types import InlineQueryResult
 from pyrogram.types import InlineQueryResult
+import pyrogram
 
 
 
 
 class InlineQueryResultAudio(InlineQueryResult):
 class InlineQueryResultAudio(InlineQueryResult):
@@ -157,31 +139,44 @@ class InlineQueryResultAudio(InlineQueryResult):
             )
             )
         )
         )
 
 
+""" 
+    CREDITS:
 
 
-class InlineQueryResultCachedAudio(InlineQueryResult):
-    """Represents a link to an MP3 audio file stored on the Telegram servers.
+    THE CODE BELOW THIS LINE IS WRITTEN BY https://github.com/Mahesh0253. [https://t.me/DeletedUser420]
+    HERE IS THE ACTUAL ORIGIN:
+    https://github.com/Mahesh0253/pyrogram/blob/inline/pyrogram/types/inline_mode/inline_query_result_cached_document.py
+"""
 
 
-    By default, this audio file will be sent by the user.
-    Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.    
+
+class InlineQueryResultCachedDocument(InlineQueryResult):
+    """Link to a file stored on the Telegram servers.
+    
+    By default, this file will be sent by the user with an optional caption. 
+    Alternatively, you can use input_message_content to send a message with the specified content instead of the file.
     
     
     Parameters:
     Parameters:
+        title (``str``):
+            Title for the result.
+        
         file_id (``str``):
         file_id (``str``):
-            A valid file identifier for the audio file
+            Pass a file_id as string to send a media that exists on the Telegram servers.
             
             
         id (``str``, *optional*):
         id (``str``, *optional*):
             Unique identifier for this result, 1-64 bytes.
             Unique identifier for this result, 1-64 bytes.
             Defaults to a randomly generated UUID4.
             Defaults to a randomly generated UUID4.
             
             
+        description (``str``, *optional*):
+            Short description of the result.
+            
         caption (``str``, *optional*):
         caption (``str``, *optional*):
-            Caption, 0-1024 characters after entities parsing.
-
+            Caption of the photo to be sent, 0-1024 characters.
+        
         parse_mode (``str``, *optional*):
         parse_mode (``str``, *optional*):
             By default, texts are parsed using both Markdown and HTML styles.
             By default, texts are parsed using both Markdown and HTML styles.
             You can combine both syntaxes together.
             You can combine both syntaxes together.
             Pass "markdown" or "md" to enable Markdown-style parsing only.
             Pass "markdown" or "md" to enable Markdown-style parsing only.
             Pass "html" to enable HTML-style parsing only.
             Pass "html" to enable HTML-style parsing only.
             Pass None to completely disable style parsing.
             Pass None to completely disable style parsing.
-
         caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
         caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
                 List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
                 List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
             
             
@@ -195,34 +190,39 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
     def __init__(
     def __init__(
         self,
         self,
         file_id: str,
         file_id: str,
+        title: str= None,
         id: str = None,
         id: str = None,
+        description: str = None,
         caption: str = "",
         caption: str = "",
         parse_mode: Optional[str] = object,
         parse_mode: Optional[str] = object,
         caption_entities: List["types.MessageEntity"] = None,
         caption_entities: List["types.MessageEntity"] = None,
         reply_markup: "types.InlineKeyboardMarkup" = None,
         reply_markup: "types.InlineKeyboardMarkup" = None,
         input_message_content: "types.InputMessageContent" = None
         input_message_content: "types.InputMessageContent" = None
     ):
     ):
-        super().__init__("audio", id, input_message_content, reply_markup)
+        super().__init__("file", id, input_message_content, reply_markup)
 
 
         self.file_id = file_id
         self.file_id = file_id
+        self.title = title
+        self.description = description
         self.caption = caption
         self.caption = caption
-        self.parse_mode = parse_mode
         self.caption_entities = caption_entities
         self.caption_entities = caption_entities
+        self.parse_mode = parse_mode
         self.reply_markup = reply_markup
         self.reply_markup = reply_markup
         self.input_message_content = input_message_content
         self.input_message_content = input_message_content
 
 
-
     async def write(self, client: "pyrogram.Client"):
     async def write(self, client: "pyrogram.Client"):
-        audio = utils.get_input_media_from_file_id(self.file_id, FileType.AUDIO)
+        document = get_input_file_from_file_id(self.file_id)
 
 
         message, entities = (await utils.parse_text_entities(
         message, entities = (await utils.parse_text_entities(
             client, self.caption, self.parse_mode, self.caption_entities
             client, self.caption, self.parse_mode, self.caption_entities
         )).values()
         )).values()
-        print(audio)
+
         return raw.types.InputBotInlineResultDocument(
         return raw.types.InputBotInlineResultDocument(
             id=self.id,
             id=self.id,
             type=self.type,
             type=self.type,
-            document=audio,
+            title=self.title,
+            description=self.description,
+            document=document,
             send_message=(
             send_message=(
                 await self.input_message_content.write(client, self.reply_markup)
                 await self.input_message_content.write(client, self.reply_markup)
                 if self.input_message_content
                 if self.input_message_content
@@ -233,3 +233,37 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
                 )
                 )
             )
             )
         )
         )
+
+def get_input_file_from_file_id(
+    file_id: str,
+    expected_file_type: FileType = None
+) -> Union["raw.types.InputPhoto", "raw.types.InputDocument"]:
+    try:
+        decoded = FileId.decode(file_id)
+    except Exception:
+        raise ValueError(f'Failed to decode "{file_id}". The value does not represent an existing local file, '
+                         f'HTTP URL, or valid file id.')
+
+    file_type = decoded.file_type
+
+    if expected_file_type is not None and file_type != expected_file_type:
+        raise ValueError(f'Expected: "{expected_file_type}", got "{file_type}" file_id instead')
+
+    if file_type in (FileType.THUMBNAIL, FileType.CHAT_PHOTO):
+        raise ValueError(f"This file_id can only be used for download: {file_id}")
+
+    if file_type in PHOTO_TYPES:
+        return raw.types.InputPhoto(
+            id=decoded.media_id,
+            access_hash=decoded.access_hash,
+            file_reference=decoded.file_reference
+        )
+
+    if file_type in DOCUMENT_TYPES:
+        return raw.types.InputDocument(
+            id=decoded.media_id,
+            access_hash=decoded.access_hash,
+            file_reference=decoded.file_reference
+        )
+
+    raise ValueError(f"Unknown file id: {file_id}")

+ 1 - 1
wbb/modules/admin.py

@@ -1,7 +1,7 @@
 from pyrogram import filters
 from pyrogram import filters
 from pyrogram.types import ChatPermissions
 from pyrogram.types import ChatPermissions
 from wbb import SUDOERS, app, BOT_ID
 from wbb import SUDOERS, app, BOT_ID
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.dbfunctions import add_warn, get_warn, remove_warns, int_to_alpha
 from wbb.utils.dbfunctions import add_warn, get_warn, remove_warns, int_to_alpha
 import asyncio
 import asyncio
 
 

+ 18 - 13
wbb/modules/admin_misc.py

@@ -1,6 +1,6 @@
 from pyrogram import filters
 from pyrogram import filters
 from wbb import SUDOERS, app
 from wbb import SUDOERS, app
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.modules.admin import list_admins, member_permissions
 from wbb.modules.admin import list_admins, member_permissions
 import os
 import os
 
 
@@ -10,16 +10,19 @@ __HELP__ = """
 /set_chat_photo - Change The PFP Of A Group/Channel.
 /set_chat_photo - Change The PFP Of A Group/Channel.
 /set_user_title - Change The Administrator Title Of An Admin.
 /set_user_title - Change The Administrator Title Of An Admin.
 """
 """
+
+
 @app.on_message(filters.command("set_chat_title") & ~filters.private)
 @app.on_message(filters.command("set_chat_title") & ~filters.private)
 @capture_err
 @capture_err
 async def set_chat_title(_, message):
 async def set_chat_title(_, message):
     try:
     try:
         chat_id = message.chat.id
         chat_id = message.chat.id
         user_id = message.from_user.id
         user_id = message.from_user.id
-        permissions = await member_permissions(chat_id, user_id)
-        if "can_change_info" not in permissions:
-            await message.reply_text("You Don't Have Enough Permissions.")
-            return
+        if user_id not in SUDOERS:
+            permissions = await member_permissions(chat_id, user_id)
+            if "can_change_info" not in permissions:
+                await message.reply_text("You Don't Have Enough Permissions.")
+                return
         if len(message.command) < 2:
         if len(message.command) < 2:
             await message.reply_text("**Usage:**\n/set_chat_title NEW NAME")
             await message.reply_text("**Usage:**\n/set_chat_title NEW NAME")
             return
             return
@@ -39,10 +42,11 @@ async def set_user_title(_, message):
         chat_id = message.chat.id
         chat_id = message.chat.id
         user_id = message.from_user.id
         user_id = message.from_user.id
         from_user = message.reply_to_message.from_user
         from_user = message.reply_to_message.from_user
-        permissions = await member_permissions(chat_id, user_id)
-        if "can_change_info" not in permissions:
-            await message.reply_text("You Don't Have Enough Permissions.")
-            return
+        if user_id not in SUDOERS:
+            permissions = await member_permissions(chat_id, user_id)
+            if "can_change_info" not in permissions:
+                await message.reply_text("You Don't Have Enough Permissions.")
+                return
         if len(message.command) < 2:
         if len(message.command) < 2:
             await message.reply_text("**Usage:**\n/set_user_title NEW ADMINISTRATOR TITLE")
             await message.reply_text("**Usage:**\n/set_user_title NEW ADMINISTRATOR TITLE")
             return
             return
@@ -60,10 +64,11 @@ async def set_chat_photo(_, message):
     try:
     try:
         chat_id = message.chat.id
         chat_id = message.chat.id
         user_id = message.from_user.id
         user_id = message.from_user.id
-        permissions = await member_permissions(chat_id, user_id)
-        if "can_change_info" not in permissions:
-            await message.reply_text("You Don't Have Enough Permissions.")
-            return
+        if user_id not in SUDOERS:
+            permissions = await member_permissions(chat_id, user_id)
+            if "can_change_info" not in permissions:
+                await message.reply_text("You Don't Have Enough Permissions.")
+                return
         if not message.reply_to_message:
         if not message.reply_to_message:
             await message.reply_text("Reply to a photo to set it as chat_photo")
             await message.reply_text("Reply to a photo to set it as chat_photo")
             return
             return

+ 3 - 0
wbb/modules/antiservice.py

@@ -4,6 +4,7 @@
 from wbb import app
 from wbb import app
 from pyrogram import filters
 from pyrogram import filters
 from wbb.modules.admin import member_permissions
 from wbb.modules.admin import member_permissions
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.dbfunctions import is_antiservice_on, antiservice_on, antiservice_off
 from wbb.utils.dbfunctions import is_antiservice_on, antiservice_on, antiservice_off
 
 
 __MODULE__ = "AntiService"
 __MODULE__ = "AntiService"
@@ -15,6 +16,7 @@ Plugin to delete service messages in a chat!
 
 
 
 
 @app.on_message(filters.command("antiservice") & ~filters.private)
 @app.on_message(filters.command("antiservice") & ~filters.private)
+@capture_err
 async def anti_service(_, message):
 async def anti_service(_, message):
     if len(message.command) != 2:
     if len(message.command) != 2:
         await message.reply_text("Usage: /antiservice [enable | disable]")
         await message.reply_text("Usage: /antiservice [enable | disable]")
@@ -38,6 +40,7 @@ async def anti_service(_, message):
 
 
 
 
 @app.on_message(filters.service, group=11)
 @app.on_message(filters.service, group=11)
+@capture_err
 async def delete_service(_, message):
 async def delete_service(_, message):
     chat_id = message.chat.id
     chat_id = message.chat.id
     try:
     try:

+ 4 - 0
wbb/modules/bay.py

@@ -5,6 +5,8 @@ import aiofiles
 from wbb import app, SUDOERS
 from wbb import app, SUDOERS
 from pyrogram import filters
 from pyrogram import filters
 from random import randint
 from random import randint
+from wbb.core.decorators.errors import capture_err
+
 
 
 __MODULE__ = "BAYFILES"
 __MODULE__ = "BAYFILES"
 __HELP__ = """/url [URL] To upload a url to bayfiles. [SUDO ONLY]
 __HELP__ = """/url [URL] To upload a url to bayfiles. [SUDO ONLY]
@@ -12,6 +14,7 @@ __HELP__ = """/url [URL] To upload a url to bayfiles. [SUDO ONLY]
 
 
 
 
 @app.on_message(filters.command("url") & filters.user(SUDOERS))
 @app.on_message(filters.command("url") & filters.user(SUDOERS))
+@capture_err
 async def url(_, message):
 async def url(_, message):
     if len(message.command) != 2:
     if len(message.command) != 2:
         await message.reply_text("/url [url]")
         await message.reply_text("/url [url]")
@@ -39,6 +42,7 @@ async def url(_, message):
 
 
 
 
 @app.on_message(filters.command("tg") & filters.user(SUDOERS))
 @app.on_message(filters.command("tg") & filters.user(SUDOERS))
+@capture_err
 async def tg(_, message):
 async def tg(_, message):
     if not message.reply_to_message:
     if not message.reply_to_message:
         await message.reply_text("Reply To A File With /tg To Upload")
         await message.reply_text("Reply To A File With /tg To Upload")

+ 1 - 1
wbb/modules/chatbot.py

@@ -1,5 +1,5 @@
 from wbb import app, arq, BOT_ID
 from wbb import app, arq, BOT_ID
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.filter_groups import chatbot_group
 from wbb.utils.filter_groups import chatbot_group
 from pyrogram import filters
 from pyrogram import filters
 
 

+ 1 - 1
wbb/modules/couple.py

@@ -1,5 +1,5 @@
 from wbb import app
 from wbb import app
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.dbfunctions import get_couple, save_couple
 from wbb.utils.dbfunctions import get_couple, save_couple
 from pyrogram import filters
 from pyrogram import filters
 import random
 import random

+ 1 - 1
wbb/modules/covid.py

@@ -1,5 +1,5 @@
 from wbb import app
 from wbb import app
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.json_prettify import json_prettify
 from wbb.utils.json_prettify import json_prettify
 from wbb.utils.fetch import fetch
 from wbb.utils.fetch import fetch
 from pyrogram import filters
 from pyrogram import filters

+ 1 - 1
wbb/modules/filters.py

@@ -4,7 +4,7 @@ from wbb.utils.dbfunctions import (
     save_filter, get_filters_names, get_filter, delete_filter
     save_filter, get_filters_names, get_filter, delete_filter
 )
 )
 from pyrogram import filters
 from pyrogram import filters
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.filter_groups import chat_filters_group
 from wbb.utils.filter_groups import chat_filters_group
 import re
 import re
 
 

+ 2 - 0
wbb/modules/genstr.py

@@ -1,6 +1,7 @@
 from wbb import app
 from wbb import app
 from pyrogram import Client, filters
 from pyrogram import Client, filters
 from asyncio.exceptions import TimeoutError
 from asyncio.exceptions import TimeoutError
+from wbb.core.decorators.errors import capture_err
 from pyrogram.errors import (
 from pyrogram.errors import (
     SessionPasswordNeeded, PhoneNumberInvalid,
     SessionPasswordNeeded, PhoneNumberInvalid,
     PhoneCodeInvalid, PhoneCodeExpired
     PhoneCodeInvalid, PhoneCodeExpired
@@ -19,6 +20,7 @@ Send **/genstr** Command To The Bot In Private And Follow Instructions."""
 
 
 
 
 @app.on_message(filters.command("genstr") & filters.private)
 @app.on_message(filters.command("genstr") & filters.private)
+@capture_err
 async def genstr(_, message):
 async def genstr(_, message):
     chat = message.chat
     chat = message.chat
     while True:
     while True:

+ 1 - 1
wbb/modules/global_stats.py

@@ -1,6 +1,6 @@
 from wbb import app, SUDOERS, BOT_ID, BOT_NAME
 from wbb import app, SUDOERS, BOT_ID, BOT_NAME
 from wbb.utils.filter_groups import global_stats_group
 from wbb.utils.filter_groups import global_stats_group
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.fetch import fetch
 from wbb.utils.fetch import fetch
 from wbb.modules import ALL_MODULES
 from wbb.modules import ALL_MODULES
 from wbb.utils.dbfunctions import (
 from wbb.utils.dbfunctions import (

+ 1 - 1
wbb/modules/greetings.py

@@ -4,7 +4,7 @@ import asyncio
 import os
 import os
 from wbb import app, WELCOME_DELAY_KICK_SEC, SUDOERS
 from wbb import app, WELCOME_DELAY_KICK_SEC, SUDOERS
 from wbb.modules.admin import member_permissions
 from wbb.modules.admin import member_permissions
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.filter_groups import welcome_captcha_group
 from wbb.utils.filter_groups import welcome_captcha_group
 from wbb.utils.functions import generate_captcha
 from wbb.utils.functions import generate_captcha
 from wbb.utils.dbfunctions import (
 from wbb.utils.dbfunctions import (

+ 1 - 1
wbb/modules/images.py

@@ -3,7 +3,7 @@ import json
 import asyncio
 import asyncio
 from pyrogram import filters
 from pyrogram import filters
 from wbb import app
 from wbb import app
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 
 
 __MODULE__ = "Images"
 __MODULE__ = "Images"
 __HELP__ = '''/cat  - Get Cute Cats Images
 __HELP__ = '''/cat  - Get Cute Cats Images

+ 14 - 4
wbb/modules/inline.py

@@ -2,6 +2,7 @@ from wbb import app
 from wbb.utils.inlinefuncs import *
 from wbb.utils.inlinefuncs import *
 from pyrogram import filters
 from pyrogram import filters
 from pyrogram.errors.exceptions.bad_request_400 import QueryIdInvalid
 from pyrogram.errors.exceptions.bad_request_400 import QueryIdInvalid
+from wbb.core.types.InlineQueryResult import InlineQueryResultCachedDocument
 
 
 __MODULE__ = "Inline"
 __MODULE__ = "Inline"
 __HELP__ = '''```
 __HELP__ = '''```
@@ -294,14 +295,23 @@ async def inline_query_handler(client, query):
                 cache_time=2
                 cache_time=2
             )
             )
 
 
-        elif text.split()[0] == "audio":
-            answerss = await cached_audio_test_func(answers)
+        elif text.split()[0] == "music":
+            if len(text.split()) < 2:
+                await client.answer_inline_query(
+                    query.id,
+                    results=answers,
+                    switch_pm_text='Search For Music.',
+                    switch_pm_parameter='inline',
+                )
+                return
+            tex = text.split(None, 1)[1].strip()
+            answerss = await music_inline_func(answers, tex)
             await client.answer_inline_query(
             await client.answer_inline_query(
                 query.id,
                 query.id,
                 results=answerss,
                 results=answerss,
                 cache_time=2
                 cache_time=2
             )
             )
 
 
-    except (IndexError, TypeError, KeyError, ValueError, QueryIdInvalid) as e:
-        print(e + "InLine")
+    except Exception as e:
+        print(str(e) + "InLine")
         return
         return

+ 1 - 1
wbb/modules/karma.py

@@ -1,5 +1,5 @@
 from wbb import app
 from wbb import app
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.dbfunctions import (update_karma, get_karma, get_karmas,
 from wbb.utils.dbfunctions import (update_karma, get_karma, get_karmas,
                                    int_to_alpha, alpha_to_int)
                                    int_to_alpha, alpha_to_int)
 from wbb.utils.filter_groups import karma_positive_group, karma_negative_group
 from wbb.utils.filter_groups import karma_positive_group, karma_negative_group

+ 1 - 1
wbb/modules/misc.py

@@ -9,7 +9,7 @@ from wbb.utils import random_line
 from wbb.utils.json_prettify import json_prettify
 from wbb.utils.json_prettify import json_prettify
 from wbb.utils.fetch import fetch
 from wbb.utils.fetch import fetch
 from wbb.utils.pastebin import paste
 from wbb.utils.pastebin import paste
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 
 
 __MODULE__ = "Misc"
 __MODULE__ = "Misc"
 __HELP__ = '''/commit - Generate Funny Commit Messages
 __HELP__ = '''/commit - Generate Funny Commit Messages

+ 3 - 3
wbb/modules/music.py

@@ -7,7 +7,7 @@ import os
 from random import randint
 from random import randint
 from pyrogram import filters
 from pyrogram import filters
 from wbb import app, SUDOERS, arq, MAIN_CHATS
 from wbb import app, SUDOERS, arq, MAIN_CHATS
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.pastebin import paste
 from wbb.utils.pastebin import paste
 
 
 __MODULE__ = "Music"
 __MODULE__ = "Music"
@@ -85,7 +85,7 @@ is_downloading = False
 # Jiosaavn Music
 # Jiosaavn Music
 
 
 
 
-@app.on_message(filters.command("saavn") & ~filters.edited & filters.chat(MAIN_CHATS))
+@app.on_message(filters.command("saavn") & ~filters.edited)
 @capture_err
 @capture_err
 async def jssong(_, message):
 async def jssong(_, message):
     global is_downloading
     global is_downloading
@@ -120,7 +120,7 @@ async def jssong(_, message):
 # Deezer Music
 # Deezer Music
 
 
 
 
-@app.on_message(filters.command("deezer") & ~filters.edited & filters.chat(MAIN_CHATS))
+@app.on_message(filters.command("deezer") & ~filters.edited)
 @capture_err
 @capture_err
 async def deezsong(_, message):
 async def deezsong(_, message):
     global is_downloading
     global is_downloading

+ 1 - 1
wbb/modules/notes.py

@@ -2,7 +2,7 @@ from wbb import app
 from wbb.utils.dbfunctions import (
 from wbb.utils.dbfunctions import (
     save_note, get_note_names, get_note, delete_note
     save_note, get_note_names, get_note, delete_note
 )
 )
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.modules.admin import member_permissions
 from wbb.modules.admin import member_permissions
 from pyrogram import filters
 from pyrogram import filters
 
 

+ 1 - 1
wbb/modules/paste.py

@@ -2,7 +2,7 @@ import os
 from pyrogram import filters
 from pyrogram import filters
 from wbb.utils.pastebin import paste
 from wbb.utils.pastebin import paste
 from wbb import app
 from wbb import app
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 
 
 __MODULE__ = "Paste"
 __MODULE__ = "Paste"
 __HELP__ = "/paste - To Paste Replied Text Or Document To Nekobin"
 __HELP__ = "/paste - To Paste Replied Text Or Document To Nekobin"

+ 1 - 1
wbb/modules/reddit.py

@@ -1,6 +1,6 @@
 from pyrogram import filters
 from pyrogram import filters
 from wbb import app, arq
 from wbb import app, arq
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 
 
 __MODULE__ = "Reddit"
 __MODULE__ = "Reddit"
 __HELP__ = "/reddit [query] - results something from reddit"
 __HELP__ = "/reddit [query] - results something from reddit"

+ 2 - 1
wbb/modules/regex.py

@@ -3,7 +3,7 @@ import sre_constants
 from wbb import app
 from wbb import app
 from wbb.utils.filter_groups import regex_group
 from wbb.utils.filter_groups import regex_group
 from pyrogram import filters
 from pyrogram import filters
-
+from wbb.core.decorators.errors import capture_err
 
 
 __MODULE__ = "Sed"
 __MODULE__ = "Sed"
 __HELP__ = "**Usage:**\ns/foo/bar"
 __HELP__ = "**Usage:**\ns/foo/bar"
@@ -13,6 +13,7 @@ DELIMITERS = ("/", ":", "|", "_")
 
 
 
 
 @app.on_message(filters.regex(r"s([{}]).*?\1.*".format("".join(DELIMITERS))), group=regex_group)
 @app.on_message(filters.regex(r"s([{}]).*?\1.*".format("".join(DELIMITERS))), group=regex_group)
+@capture_err
 async def sed(_, message):
 async def sed(_, message):
     sed_result = separate_sed(message.text)
     sed_result = separate_sed(message.text)
     if message.reply_to_message:
     if message.reply_to_message:

+ 1 - 1
wbb/modules/repo.py

@@ -1,6 +1,6 @@
 from pyrogram import filters
 from pyrogram import filters
 from wbb import app
 from wbb import app
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.fetch import fetch
 from wbb.utils.fetch import fetch
 
 
 __MODULE__ = "Repo"
 __MODULE__ = "Repo"

+ 1 - 1
wbb/modules/rice.py

@@ -2,7 +2,7 @@ from pyrogram import filters
 from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
 from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
 from pyrogram.types import InputMediaPhoto, InputMediaVideo
 from pyrogram.types import InputMediaPhoto, InputMediaVideo
 from wbb import app
 from wbb import app
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 
 
 RICE_GROUP = "DE_WM"
 RICE_GROUP = "DE_WM"
 RICE_CHANNEL = "RiceGallery"
 RICE_CHANNEL = "RiceGallery"

+ 1 - 1
wbb/modules/stickers.py

@@ -2,7 +2,7 @@ import os
 import imghdr
 import imghdr
 from wbb import app, BOT_USERNAME
 from wbb import app, BOT_USERNAME
 from pyrogram import filters
 from pyrogram import filters
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.files import resize_file_to_sticker_size, upload_document, get_document_from_file_id
 from wbb.utils.files import resize_file_to_sticker_size, upload_document, get_document_from_file_id
 from wbb.utils.stickerset import get_sticker_set_by_name, create_sticker, add_sticker_to_set, create_sticker_set
 from wbb.utils.stickerset import get_sticker_set_by_name, create_sticker, add_sticker_to_set, create_sticker_set
 from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
 from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup

+ 1 - 1
wbb/modules/sudoers.py

@@ -11,7 +11,7 @@ from wbb import (
     USERBOT_USERNAME, GBAN_LOG_GROUP_ID
     USERBOT_USERNAME, GBAN_LOG_GROUP_ID
 )
 )
 from wbb.utils import formatter
 from wbb.utils import formatter
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.dbfunctions import (
 from wbb.utils.dbfunctions import (
     is_gbanned_user,
     is_gbanned_user,
     add_gban_user,
     add_gban_user,

+ 1 - 1
wbb/modules/webss.py

@@ -1,5 +1,5 @@
 from wbb import app
 from wbb import app
-from wbb.utils.errors import capture_err
+from wbb.core.decorators.errors import capture_err
 from wbb.utils.fetch import fetch
 from wbb.utils.fetch import fetch
 from pyrogram import filters
 from pyrogram import filters
 import time
 import time

+ 38 - 9
wbb/utils/inlinefuncs.py

@@ -19,11 +19,11 @@ from wbb.modules.userbot import eval_executor_func
 from wbb.utils.fetch import fetch
 from wbb.utils.fetch import fetch
 from wbb.utils.formatter import convert_seconds_to_minutes as time_convert
 from wbb.utils.formatter import convert_seconds_to_minutes as time_convert
 from wbb.utils.pastebin import paste
 from wbb.utils.pastebin import paste
+from wbb.core.types.InlineQueryResult import InlineQueryResultCachedDocument
 from wbb import (
 from wbb import (
     arq, app, app2, USERBOT_USERNAME,
     arq, app, app2, USERBOT_USERNAME,
     BOT_USERNAME, LOG_GROUP_ID, USERBOT_ID
     BOT_USERNAME, LOG_GROUP_ID, USERBOT_ID
 )
 )
-from wbb.core.types.InlineQueryResult import InlineQueryResultAudio, InlineQueryResultCachedAudio
 
 
 
 
 async def inline_help_func(__HELP__):
 async def inline_help_func(__HELP__):
@@ -319,7 +319,7 @@ async def torrent_func(answers, text):
 **Seeds:** __{seeds}__
 **Seeds:** __{seeds}__
 **Leechs:** __{leechs}__
 **Leechs:** __{leechs}__
 **Uploaded:** __{upload_date}__
 **Uploaded:** __{upload_date}__
-**Magnet:** __{magnet}__"""
+**Magnet:** `{magnet}`"""
 
 
         description = f"{size} | {upload_date} | Seeds: {seeds}"
         description = f"{size} | {upload_date} | Seeds: {seeds}"
         try:
         try:
@@ -550,7 +550,7 @@ async def tg_search_func(answers, text, user_id):
 **Date:** {ctime(message.date)}
 **Date:** {ctime(message.date)}
 **Text:** >>
 **Text:** >>
 
 
-{message.text.markdown if message.text else message.caption if message.caption else "[NO_TEXT]"}
+{message.text.markdown if message.text else message.caption if message.caption else '[NO_TEXT]'}
 """
 """
         result = InlineQueryResultArticle(
         result = InlineQueryResultArticle(
             title=name,
             title=name,
@@ -559,16 +559,45 @@ async def tg_search_func(answers, text, user_id):
             input_message_content=InputTextMessageContent(
             input_message_content=InputTextMessageContent(
                 caption,
                 caption,
                 disable_web_page_preview=True
                 disable_web_page_preview=True
-                )
+            )
         )
         )
         answers.append(result)
         answers.append(result)
     return answers
     return answers
 
 
 
 
-async def cached_audio_test_func(answers):
-    answers.append(
-        InlineQueryResultCachedAudio(
-            file_id="CQACAgUAAx0EWIlO9AABA5N3YH0yxW2M9qTAMATvsj2-hkXv7NUAAn4CAAL2U-hXv1yOjFTFTiweBA"
+async def music_inline_func(answers, query):
+    chat_id = -1001445180719
+    group_invite = "https://t.me/joinchat/vSDE2DuGK4Y4Nzll"
+    try:
+        messages = [m async for m in app2.search_messages(chat_id, query, filter="audio", limit=199)]
+        file_and_message_ids = []
+        for f_ in messages:
+            file_and_message_ids.append(
+                {"message_id": f_.message_id, "file_unique_id": f_.audio.file_unique_id}
+                )
+        messages = list(
+            {v["file_unique_id"]: v for v in file_and_message_ids}.values())
+        messages_ids = []
+        for ff_ in messages:
+            messages_ids.append(ff_['message_id'])
+    except Exception as e:
+        print(e)
+        msg = f"You Need To Join Here With Your Bot And Userbot To Get Cached Music.\n{group_invite}"
+        answers.append(
+            InlineQueryResultArticle(
+                title="ERROR",
+                description="Click Here To Know More.",
+                input_message_content=InputTextMessageContent(
+                    msg, disable_web_page_preview=True)
+            )
+        )
+        return answers
+    messages = await app.get_messages(chat_id, messages_ids[0:48])
+    for message_ in messages:
+        answers.append(
+            InlineQueryResultCachedDocument(
+                file_id=message_.audio.file_id,
+                title=message_.audio.title
+            )
         )
         )
-    )
     return answers
     return answers