TheHamkerCat 5 лет назад
Родитель
Сommit
01092b6868
5 измененных файлов с 251 добавлено и 15 удалено
  1. 3 2
      wbb/__main__.py
  2. 131 0
      wbb/core/types/InlineQueryResult.py
  3. 79 0
      wbb/modules/admin_misc.py
  4. 9 1
      wbb/modules/inline.py
  5. 29 12
      wbb/utils/inlinefuncs.py

+ 3 - 2
wbb/__main__.py

@@ -4,7 +4,7 @@ import importlib
 import uvloop
 import uvloop
 from pyrogram import filters, idle
 from pyrogram import filters, idle
 from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
 from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-from wbb import app, BOT_NAME, BOT_USERNAME
+from wbb import app, BOT_NAME, BOT_USERNAME, USERBOT_NAME
 from wbb.utils import paginate_modules
 from wbb.utils import paginate_modules
 from wbb.modules.sudoers import bot_sys_stats
 from wbb.modules.sudoers import bot_sys_stats
 from wbb.modules import ALL_MODULES
 from wbb.modules import ALL_MODULES
@@ -44,7 +44,8 @@ async def start_bot():
     print("+===============+===============+===============+===============+")
     print("+===============+===============+===============+===============+")
     print(bot_modules)
     print(bot_modules)
     print("+===============+===============+===============+===============+")
     print("+===============+===============+===============+===============+")
-    print("Bot Started Successfully as {}!".format(BOT_NAME))
+    print(f"BOT Started Successfully as {BOT_NAME}!")
+    print(f"USERBOT Started Successfully as {USERBOT_NAME}!")
     await idle()
     await idle()
 
 
 
 

+ 131 - 0
wbb/core/types/InlineQueryResult.py

@@ -0,0 +1,131 @@
+#  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 Union
+
+from pyrogram import raw
+from pyrogram import types
+from pyrogram.parser import Parser
+from pyrogram.types import InlineQueryResult
+
+
+"https://github.com/JollyGoal/pyrogram/blob/add-inline-query-audio/pyrogram/types/inline_mode/inline_query_result_audio.py"
+
+
+class InlineQueryResultAudio(InlineQueryResult):
+    """Link to an audio file.
+    By default, this audio file will be sent by the user with optional caption.
+    Alternatively, you can use *input_message_content* to send a message with the specified content instead of the
+    audio.
+    Parameters:
+        audio_url (``str``):
+            A valid URL for the audio file.
+        title (``str``):
+            Title for the result.
+        duration (``int``, *optional*):
+            Duration of the audio in second.
+        voice (``bool``, *optional*):
+            Whether this file should be sent as voice message (default=False).
+        performer (``str``, *optional*):
+            Audio artist.
+        thumb_url (``str``, *optional*):
+            URL of the static thumbnail for the result (jpeg or gif)
+            Defaults to the value passed in *animation_url*.
+        id (``str``, *optional*):
+            Unique identifier for this result, 1-64 bytes.
+            Defaults to a randomly generated UUID4.
+        description (``str``, *optional*):
+            Short description of the result.
+        caption (``str``, *optional*):
+            Caption of the photo to be sent, 0-1024 characters.
+        parse_mode (``str``, *optional*):
+            By default, texts are parsed using both Markdown and HTML styles.
+            You can combine both syntaxes together.
+            Pass "markdown" or "md" to enable Markdown-style parsing only.
+            Pass "html" to enable HTML-style parsing only.
+            Pass None to completely disable style parsing.
+        reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
+            An InlineKeyboardMarkup object.
+        input_message_content (:obj:`~pyrogram.types.InputMessageContent`):
+            Content of the message to be sent instead of the photo.
+    """
+
+    def __init__(
+            self,
+            audio_url: str,
+            title: str,
+            duration: int = 0,
+            voice: bool = False,
+            performer: str = "",
+            thumb_url: str = None,
+            id: str = None,
+            description: str = None,
+            caption: str = "",
+            parse_mode: Union[str, None] = object,
+            reply_markup: "types.InlineKeyboardMarkup" = None,
+            input_message_content: "types.InputMessageContent" = None
+    ):
+        super().__init__("audio", id, input_message_content, reply_markup)
+
+        self.audio_url = audio_url
+        self.thumb_url = thumb_url
+        self.title = title
+        self.description = description
+        self.caption = caption
+        self.parse_mode = parse_mode
+        self.reply_markup = reply_markup
+        self.input_message_content = input_message_content
+        self.duration = duration
+        self.voice = voice
+        self.performer = performer
+
+    async def write(self):
+        audio = raw.types.InputWebDocument(
+            url=self.audio_url,
+            size=0,
+            mime_type="audio/ogg",
+            attributes=[raw.types.DocumentAttributeAudio(
+                duration=self.duration,
+                voice=self.voice,
+                title=self.title,
+                performer=self.performer,
+                # waveform=idk wtf is that...
+            )],
+        )
+
+        return raw.types.InputBotInlineResult(
+            id=self.id,
+            type=self.type,
+            title=self.title,
+            description=self.description,
+            thumb=raw.types.InputWebDocument(
+                url=self.thumb_url,
+                size=0,
+                mime_type="image/jpeg",
+                attributes=[]
+            ) if self.thumb_url else None,
+            content=audio,
+            send_message=(
+                self.input_message_content.write(self.reply_markup)
+                if self.input_message_content
+                else raw.types.InputBotInlineMessageMediaAuto(
+                    reply_markup=self.reply_markup.write() if self.reply_markup else None,
+                    **await(Parser(None)).parse(self.caption, self.parse_mode)
+                )
+            )
+        )

+ 79 - 0
wbb/modules/admin_misc.py

@@ -0,0 +1,79 @@
+from pyrogram import filters
+from wbb import SUDOERS, app
+from wbb.utils.errors import capture_err
+from wbb.modules.admin import list_admins, member_permissions
+import os
+
+__MODULE__ = "Admin Miscs"
+__HELP__ = """
+/set_chat_title - Change The Name Of A Group/Channel.
+/set_chat_photo - Change The PFP Of A Group/Channel.
+/set_user_title - Change The Administrator Title Of An Admin.
+"""
+@app.on_message(filters.command("set_chat_title") & ~filters.private)
+@capture_err
+async def set_chat_title(_, message):
+    try:
+        chat_id = message.chat.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 len(message.command) < 2:
+            await message.reply_text("**Usage:**\n/set_chat_title NEW NAME")
+            return
+        old_title = message.chat.title
+        new_title = message.text.split(None ,1)[1]
+        await message.chat.set_title(new_title)
+        await message.reply_text(f"Successfully Changed Group Title From {old_title} To {new_title}")
+    except Exception as e:
+        print(e)
+        await message.reply_text(e)
+
+
+@app.on_message(filters.command("set_user_title") & ~filters.private)
+@capture_err
+async def set_user_title(_, message):
+    try:
+        chat_id = message.chat.id
+        user_id = message.from_user.id
+        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 len(message.command) < 2:
+            await message.reply_text("**Usage:**\n/set_user_title NEW ADMINISTRATOR TITLE")
+            return
+        title = message.text.split(None ,1)[1]
+        await app.set_administrator_title(chat_id, from_user.id, title)
+        await message.reply_text(f"Successfully Changed {from_user.mention}'s Admin Title To {title}")
+    except Exception as e:
+        print(e)
+        await message.reply_text(e)
+
+
+@app.on_message(filters.command("set_chat_photo") & ~filters.private)
+@capture_err
+async def set_chat_photo(_, message):
+    try:
+        chat_id = message.chat.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 not message.reply_to_message:
+            await message.reply_text("Reply to a photo to set it as chat_photo")
+            return
+        if not message.reply_to_message.photo and not message.reply_to_message.document:
+            await message.reply_text("Reply to a photo to set it as chat_photo")
+            return
+        photo = await message.reply_to_message.download()
+        await message.chat.set_photo(photo)
+        await message.reply_text(f"Successfully Changed Group Photo")
+        os.remove(photo)
+    except Exception as e:
+        print(e)
+        await message.reply_text(e)

+ 9 - 1
wbb/modules/inline.py

@@ -5,7 +5,7 @@ from wbb.utils.inlinefuncs import (
     saavn_func, deezer_func, inline_help_func,
     saavn_func, deezer_func, inline_help_func,
     torrent_func, youtube_func, lyrics_func,
     torrent_func, youtube_func, lyrics_func,
     eval_func, github_user_func, github_repo_func,
     eval_func, github_user_func, github_repo_func,
-    tg_search_func
+    tg_search_func, deezaudio_func
 )
 )
 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
@@ -301,5 +301,13 @@ async def inline_query_handler(client, query):
                 cache_time=2
                 cache_time=2
             )
             )
 
 
+        elif text.split()[0] == "audio":
+            answerss = await deezaudio_func(answers)
+            await client.answer_inline_query(
+                query.id,
+                results=answerss,
+                cache_time=2
+            )
+
     except (IndexError, TypeError, KeyError, ValueError, QueryIdInvalid):
     except (IndexError, TypeError, KeyError, ValueError, QueryIdInvalid):
         return
         return

+ 29 - 12
wbb/utils/inlinefuncs.py

@@ -1,7 +1,7 @@
-from wbb import (
-    arq, app, app2, USERBOT_USERNAME,
-    BOT_USERNAME, LOG_GROUP_ID, USERBOT_ID
-)
+import aiohttp
+import json
+import sys
+import asyncio
 from pyrogram.types import (
 from pyrogram.types import (
     InlineQueryResultArticle,
     InlineQueryResultArticle,
     InputTextMessageContent,
     InputTextMessageContent,
@@ -10,19 +10,36 @@ from pyrogram.types import (
 )
 )
 from googletrans import Translator
 from googletrans import Translator
 from search_engine_parser import GoogleSearch
 from search_engine_parser import GoogleSearch
-from wbb.modules.userbot import eval_executor_func
-from wbb.utils.fetch import fetch
-from wbb.utils.formatter import convert_seconds_to_minutes as time_convert
-from wbb.utils.pastebin import paste
 from pykeyboard import InlineKeyboard
 from pykeyboard import InlineKeyboard
 from sys import version as pyver
 from sys import version as pyver
 from motor import version as mongover
 from motor import version as mongover
 from pyrogram import __version__ as pyrover
 from pyrogram import __version__ as pyrover
 from time import time, ctime
 from time import time, ctime
-import aiohttp
-import json
-import sys
-import asyncio
+from wbb.modules.userbot import eval_executor_func
+from wbb.utils.fetch import fetch
+from wbb.utils.formatter import convert_seconds_to_minutes as time_convert
+from wbb.utils.pastebin import paste
+from wbb import (
+    arq, app, app2, USERBOT_USERNAME,
+    BOT_USERNAME, LOG_GROUP_ID, USERBOT_ID
+)
+from wbb.core.types.InlineQueryResult import InlineQueryResultAudio
+
+
+async def deezaudio_func(answers):
+    msg = "a"
+    answers.append(
+        InlineQueryResultAudio(
+            audio_url="https://masstamilan2019download.com/tamil/2019%20Tamil%20Mp3/Oh%20My%20Kadavule/Kadhaippoma-Masstamilan.In.mp3",
+            title="a",
+            description="desc",
+            input_message_content=InputTextMessageContent(msg)
+        )
+    )
+    return answers
+
+
+
 
 
 
 
 async def inline_help_func(__HELP__):
 async def inline_help_func(__HELP__):