Quellcode durchsuchen

Added A.R.Q & Fixed some things.

thehamkercat vor 5 Jahren
Ursprung
Commit
3b07c93e6c

+ 1 - 1
.gitignore

@@ -5,7 +5,7 @@ __pycache__/
 .
 # C extensions
 *.so
-
+config.py
 # Distribution / packaging
 .Python
 build/

+ 1 - 2
requirements.txt

@@ -1,5 +1,6 @@
 TgCrypto
 aiohttp
+aiofiles
 future
 psutil
 pillow
@@ -8,9 +9,7 @@ requests
 speedtest-cli
 uvloop
 youtube_dl
-coffeehouse
 youtube_search
 search_engine_parser
-wget
 cryptography
 googletrans==4.0.0-rc1

+ 0 - 25
sample_config.ini

@@ -1,25 +0,0 @@
-[pyrogram]
-bot_token = 123456789:AAF30XNmCurueFA44kwd7v64cPKcPv5w8RscW6
-api_id = 123456
-api_hash = r7s8c3b22d4869bd6ca7cc756cb9
-
-[admin]
-owner_id = 1243703097
-sudo_user_id = 79813487
-neofetch = True
-# https://wall.alphacoders.com/api.php
-alpha_coders_wall_api_key = ca45r8c444s55g7t5s3a4esd33hs6t
-log_group_id = -1001337393587
-# https://cryptography.io/en/latest/fernet.html
-fernet_encryption_key = iKMq0WZMnJKjMQxZWKtv-cplMuF_LoyshXj0XbTGGWM=
-captcha_delay_in_seconds = 300
-#https://github.com/cyberboysumanjay/JioSaavnAPI
-jio_saavn_api = http://127.0.0.1:5000/result/?query=
-
-
-[prefix]
-prefixes = /
-
-[mods]
-load_modules =
-noload_modules = rice

+ 19 - 0
sample_config.py

@@ -0,0 +1,19 @@
+bot_token = "1455:AAE4qFS3nF-0Tn"
+
+api_id = 69
+
+api_hash = "e46b6c854d2bf580"
+
+OWNER_ID = 1243703097
+
+sudo_users_id = [354165569, 564426514, 686215463]
+
+log_group_id = -1001337393587
+
+# https://cryptography.io/en/latest/fernet.html
+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/"

+ 14 - 17
wbb/__init__.py

@@ -1,7 +1,12 @@
-import logging
-import time
-from configparser import ConfigParser
+from config import (
+        bot_token, api_id, api_hash, OWNER_ID,
+        sudo_users_id as SUDO_USER_ID, log_group_id as LOG_GROUP_ID,
+        fernet_encryption_key as FERNET_ENCRYPTION_KEY,
+        captcha_delay_in_seconds as WELCOME_DELAY_KICK_SEC,
+        ARQ_API_BASE_URL as ARQ)
 from pyrogram import Client
+import time
+import logging
 
 
 f = open("error.log", "w")
@@ -28,19 +33,11 @@ logging.getLogger("").addHandler(console)
 
 log = logging.getLogger()
 
-config = ConfigParser()
-config.read("config.ini")
-OWNER_ID = int(config.get("admin", "owner_id"))
-SUDO_USER_ID = int(config.get("admin", "sudo_user_id"))
-LOG_GROUP_ID = int(config.get("admin", "log_group_id"))
-NEOFETCH = config.get("admin", "neofetch")
-WALL_API_KEY = config.get("admin", "alpha_coders_wall_api_key")
-FERNET_ENCRYPTION_KEY = config.get("admin", "fernet_encryption_key")
-WELCOME_DELAY_KICK_SEC = int(config.get("admin", "captcha_delay_in_seconds"))
-JSMAPI = config.get("admin", "jio_saavn_api")
-Command = config.get("prefix", "prefixes").split()
-MOD_LOAD = config.get("mods", "load_modules").split()
-MOD_NOLOAD = config.get("mods", "noload_modules").split()
+
+SUDOERS = SUDO_USER_ID
+SUDOERS.append(OWNER_ID)
+MOD_LOAD = []
+MOD_NOLOAD = []
 bot_start_time = time.time()
 
-app = Client("wbb", workers=16)
+app = Client("wbb", bot_token=bot_token, api_id=api_id, api_hash=api_hash)

+ 3 - 3
wbb/__main__.py

@@ -6,7 +6,7 @@ import uvloop
 from pyrogram import filters, idle
 from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
 from wbb import app, MOD_NOLOAD
-from wbb.utils import get_info, paginate_modules, cust_filter
+from wbb.utils import get_info, paginate_modules
 from wbb.utils import botinfo, formatter
 from wbb.modules import ALL_MODULES
 from wbb import bot_start_time
@@ -56,7 +56,7 @@ async def start_bot():
     await idle()
 
 
-@app.on_message(cust_filter.command("start"))
+@app.on_message(filters.command("start"))
 async def start(_, message):
     bot_uptime = int(time.time() - bot_start_time)
     await message.reply_text(
@@ -64,7 +64,7 @@ async def start(_, message):
         " Maybe Try /help")
 
 
-@app.on_message(cust_filter.command("help"))
+@app.on_message(filters.command("help"))
 async def help_command(_, message):
     if message.chat.type != "private":
         if len(message.command) >= 2 and message.command[1] == "help":

+ 19 - 20
wbb/modules/admin.py

@@ -1,7 +1,6 @@
 from pyrogram import filters
-from pyrogram.types import Message, ChatPermissions
+from pyrogram.types import ChatPermissions
 from wbb import OWNER_ID, SUDO_USER_ID, app
-from wbb.utils import cust_filter
 from wbb.utils.botinfo import BOT_ID
 from wbb.utils.errors import capture_err
 
@@ -40,9 +39,9 @@ async def list_members(group_id):
 # Purge Messages
 
 
-@app.on_message(cust_filter.command(commands=("purge")) & ~filters.edited)
+@app.on_message(filters.command("purge") & ~filters.edited)
 @capture_err
-async def purge(client, message: Message):
+async def purge(client, message):
     message_ids = []
     if message.chat.type not in ("supergroup", "channel"):
         return
@@ -91,9 +90,9 @@ async def purge(client, message: Message):
 # Kick members
 
 
-@app.on_message(cust_filter.command(commands=("kick")) & ~filters.edited)
+@app.on_message(filters.command("kick") & ~filters.edited)
 @capture_err
-async def kick(_, message: Message):
+async def kick(_, message):
     try:
         if (await app.get_chat_member(
             message.chat.id, message.from_user.id)).status == 'creator' \
@@ -133,9 +132,9 @@ async def kick(_, message: Message):
 # Ban members
 
 
-@app.on_message(cust_filter.command(commands=("ban")) & ~filters.edited)
+@app.on_message(filters.command("ban") & ~filters.edited)
 @capture_err
-async def ban(_, message: Message):
+async def ban(_, message):
     try:
         if (await app.get_chat_member(
             message.chat.id, message.from_user.id)).status == 'creator' \
@@ -174,9 +173,9 @@ async def ban(_, message: Message):
 # Unban members
 
 
-@app.on_message(cust_filter.command(commands=("unban")) & ~filters.edited)
+@app.on_message(filters.command("unban") & ~filters.edited)
 @capture_err
-async def unban(_, message: Message):
+async def unban(_, message):
     try:
         if (await app.get_chat_member(
             message.chat.id, message.from_user.id)).status == 'creator' \
@@ -209,9 +208,9 @@ async def unban(_, message: Message):
 # Delete messages
 
 
-@app.on_message(cust_filter.command(commands=("del")))
+@app.on_message(filters.command("del"))
 @capture_err
-async def delete(_, message: Message):
+async def delete(_, message):
     if not message.reply_to_message:
         await message.reply_text("Reply To A Message To Delete It")
         return
@@ -238,9 +237,9 @@ async def delete(_, message: Message):
 # Promote Members
 
 
-@app.on_message(cust_filter.command(commands=("promote")) & ~filters.edited)
+@app.on_message(filters.command("promote") & ~filters.edited)
 @capture_err
-async def promote(_, message: Message):
+async def promote(_, message):
     try:
         admins = await list_admins(message.chat.id)
         chat_id = message.chat.id
@@ -297,9 +296,9 @@ async def promote(_, message: Message):
 # Pin Messages
 
 
-@app.on_message(cust_filter.command(commands=("pin")) & ~filters.edited)
+@app.on_message(filters.command("pin") & ~filters.edited)
 @capture_err
-async def pin(_, message: Message):
+async def pin(_, message):
     if not message.reply_to_message:
         await message.reply_text("Reply To A Message To Pin.")
         return
@@ -326,9 +325,9 @@ async def pin(_, message: Message):
 # Mute members
 
 
-@app.on_message(cust_filter.command(commands=("mute")) & ~filters.edited)
+@app.on_message(filters.command("mute") & ~filters.edited)
 @capture_err
-async def mute(_, message: Message):
+async def mute(_, message):
     try:
         chat_id = message.chat.id
         from_user_id = message.from_user.id
@@ -353,9 +352,9 @@ async def mute(_, message: Message):
 # Unmute members
 
 
-@app.on_message(cust_filter.command(commands=("unmute")) & ~filters.edited)
+@app.on_message(filters.command("unmute") & ~filters.edited)
 @capture_err
-async def unmute(_, message: Message):
+async def unmute(_, message):
     try:
         chat_id = message.chat.id
         from_user_id = message.from_user.id

+ 10 - 15
wbb/modules/images.py

@@ -2,48 +2,43 @@ import urllib.request
 import json
 import asyncio
 from random import randint
-import requests as r
 from pyrogram import filters
-from pyrogram.types import Message
-from wbb.utils import cust_filter
-from wbb import app, WALL_API_KEY
+from wbb import app, ARQ
 from wbb.utils.errors import capture_err
+from wbb.utils.fetch import fetch
+
 
 __MODULE__ = "Images"
 __HELP__ = '''/cat  - Get Cute Cats Images
 /wall - Get Wallpapers'''
 
 
-async def delete_message_with_delay(delay, message: Message):
+async def delete_message_with_delay(delay, message):
     await asyncio.sleep(delay)
     await message.delete()
 
 
-@app.on_message(cust_filter.command(commands=("cat")) & ~filters.edited)
+@app.on_message(filters.command("cat") & ~filters.edited)
 @capture_err
-async def cat(_, message: Message):
+async def cat(_, message):
     with urllib.request.urlopen(
-        "https://api.thecatapi.com/v1/images/search"
+            "https://api.thecatapi.com/v1/images/search"
     ) as url:
         data = json.loads(url.read().decode())
     cat_url = (data[0]['url'])
     await message.reply_photo(cat_url)
 
 
-@app.on_message(cust_filter.command(commands=("wall")) & ~filters.edited)
+@app.on_message(filters.command("wall") & ~filters.edited)
 @capture_err
-async def wall(_, message: Message):
+async def wall(_, message):
     if len(message.command) < 2:
         await message.reply_text("/wall needs an argument")
         return
     initial_term = message.text.split(None, 1)[1]
     m = await message.reply_text("Searching!")
-
     term = initial_term.replace(' ', '%20')
-    api = "https://wall.alphacoders.com/api2.0/get.php?auth=" + \
-        "{}&method=search&term={}".format(WALL_API_KEY, term)
-
-    json_rep = r.get(api).json()
+    json_rep = await fetch(f"{ARQ}wall?query={term}")
     if not json_rep.get("success"):
         await m.edit("Something happened! Shit.")
     else:

+ 19 - 19
wbb/modules/misc.py

@@ -2,11 +2,10 @@ import secrets
 import string
 import requests
 from pyrogram import filters
-from pyrogram.types import Message
 from googletrans import Translator
 from cryptography.fernet import Fernet
 from wbb import app, FERNET_ENCRYPTION_KEY
-from wbb.utils import cust_filter, random_line
+from wbb.utils import random_line
 from wbb.utils.errors import capture_err
 from wbb.utils.json_prettify import json_prettify
 from wbb.utils.fetch import fetch
@@ -27,11 +26,12 @@ __HELP__ = '''/commit - Generate Funny Commit Messages
 #RTFM - Check it lol'''
 
 
-@app.on_message(cust_filter.command(commands=("commit")) & ~filters.edited)
+@app.on_message(filters.command("commit") & ~filters.edited)
 @capture_err
-async def commit(_, message: Message):
+async def commit(_, message):
     await message.reply_text((await random_line('wbb/utils/commit.txt')))
 
+
 @app.on_message(filters.command("RTFM", "#"))
 @capture_err
 async def rtfm(_, message):
@@ -42,15 +42,15 @@ async def rtfm(_, message):
     await message.reply_to_message.reply_text("Are You Lost? READ THE FUCKING DOCS!")
 
 
-@app.on_message(cust_filter.command(commands=("runs")) & ~filters.edited)
+@app.on_message(filters.command("runs") & ~filters.edited)
 @capture_err
-async def runs(_, message: Message):
+async def runs(_, message):
     await message.reply_text((await random_line('wbb/utils/runs.txt')))
 
 
-@app.on_message(cust_filter.command(commands=("id")) & ~filters.edited)
+@app.on_message(filters.command("id") & ~filters.edited)
 @capture_err
-async def get_id(_, message: Message):
+async def get_id(_, message):
     if len(message.command) != 1:
         username = message.text.split(None, 1)[1]
         user_id = (await app.get_users(username)).id
@@ -71,9 +71,9 @@ async def get_id(_, message: Message):
 # Random
 
 
-@app.on_message(cust_filter.command(commands=('random')) & ~filters.edited)
+@app.on_message(filters.command('random') & ~filters.edited)
 @capture_err
-async def random(_, message: Message):
+async def random(_, message):
     if len(message.command) != 2:
         await message.reply_text('"/random" Needs An Argurment.'
                                  ' Ex: `/random 5`')
@@ -95,9 +95,9 @@ async def random(_, message: Message):
 # Encrypt
 
 
-@app.on_message(cust_filter.command(commands=('encrypt')) & ~filters.edited)
+@app.on_message(filters.command('encrypt') & ~filters.edited)
 @capture_err
-async def encrypt(_, message: Message):
+async def encrypt(_, message):
     if not message.reply_to_message:
         await message.reply_text('Reply To A Message To Encrypt It.')
         return
@@ -111,9 +111,9 @@ async def encrypt(_, message: Message):
 # Decrypt
 
 
-@app.on_message(cust_filter.command(commands=('decrypt')) & ~filters.edited)
+@app.on_message(filters.command('decrypt') & ~filters.edited)
 @capture_err
-async def decrypt(_, message: Message):
+async def decrypt(_, message):
     if not message.reply_to_message:
         await message.reply_text('Reply To A Message To Decrypt It.')
         return
@@ -128,9 +128,9 @@ async def decrypt(_, message: Message):
 # Cheat.sh
 
 
-@app.on_message(cust_filter.command(commands=("cheat")) & ~filters.edited)
+@app.on_message(filters.command("cheat") & ~filters.edited)
 @capture_err
-async def cheat(_, message: Message):
+async def cheat(_, message):
     if len(message.command) < 3:
         await message.reply_text("/cheat [language] [query]")
         return
@@ -152,9 +152,9 @@ async def cheat(_, message: Message):
 # Weather
 
 
-@app.on_message(cust_filter.command(commands=("weather")) & ~filters.edited)
+@app.on_message(filters.command("weather") & ~filters.edited)
 @capture_err
-async def weather(_, message: Message):
+async def weather(_, message):
     if len(message.command) != 2:
         await message.reply_text("/weather [city]")
         return
@@ -167,7 +167,7 @@ async def weather(_, message: Message):
 # Translate
 
 
-@app.on_message(cust_filter.command(commands=("tr")) & ~filters.edited)
+@app.on_message(filters.command("tr") & ~filters.edited)
 @capture_err
 async def tr(_, message):
     if len(message.command) != 2:

+ 54 - 13
wbb/modules/music.py

@@ -3,18 +3,18 @@ from urllib.parse import urlparse
 import os
 import youtube_dl
 import aiohttp
-import json
-import wget
+import aiofiles
+import os
+from random import randint
 from pyrogram import filters
-from pyrogram.types import Message
-from wbb.utils import cust_filter
-from wbb import app, OWNER_ID, SUDO_USER_ID
+from wbb import app, SUDOERS, ARQ
+from wbb.utils.fetch import fetch
 from wbb.utils.errors import capture_err
 
-SUDOERS = [OWNER_ID, SUDO_USER_ID]
 
 __MODULE__ = "Music"
-__HELP__ = "/music [link] To Download Music From Various Websites"
+__HELP__ = """/ytmusic [link] To Download Music From Various Websites Including Youtube
+/saavn [query] To Download Music From Saavn."""
 
 ydl_opts = {
     'format': 'bestaudio/best',
@@ -27,11 +27,13 @@ ydl_opts = {
 }
 
 
-@app.on_message(cust_filter.command(commands=("music")) & ~filters.edited & filters.user(SUDOERS))
+# Ytmusic
+
+@app.on_message(filters.command("ytmusic") & ~filters.edited & filters.user(SUDOERS))
 @capture_err
-async def music(_, message: Message):
+async def music(_, message):
     if len(message.command) != 2:
-        await message.reply_text("`/music` needs a link as argument")
+        await message.reply_text("/ytmusic needs a link as argument")
         return
     link = message.text.split(None, 1)[1]
     m = await message.reply_text(f"Downloading {link}",
@@ -54,11 +56,9 @@ async def music(_, message: Message):
     webpage_url = info_dict['webpage_url']
     performer = info_dict['uploader']
     duration = int(float(info_dict['duration']))
-    caption = f"[{title}]({webpage_url})"
     await m.delete()
     await message.reply_chat_action("upload_document")
-    await message.reply_audio(audio_file, caption=caption,
-                              duration=duration, performer=performer,
+    await message.reply_audio(audio_file, duration=duration, performer=performer,
                               title=title, thumb=thumbnail_file)
     os.remove(audio_file)
     os.remove(thumbnail_file)
@@ -68,3 +68,44 @@ def get_file_extension_from_url(url):
     url_path = urlparse(url).path
     basename = os.path.basename(url_path)
     return basename.split(".")[-1]
+
+
+# Funtion To Download Song
+async def download_song(url):
+    song_name = f"{randint(6969, 6999)}.mp3"
+    async with aiohttp.ClientSession() as session:
+        async with session.get(url) as resp:
+            if resp.status == 200:
+                f = await aiofiles.open(song_name, mode='wb')
+                await f.write(await resp.read())
+                await f.close()
+    return song_name
+
+
+# Jiosaavn Music
+
+
+@app.on_message(filters.command("saavn"))
+@capture_err
+async def jssong(_, message):
+    if len(message.command) < 2:
+        await message.reply_text("/saavn requires an argument.")
+        return
+    text = message.text.split(None, 1)[1]
+    query = text.replace(" ", "%20")
+    m = await message.reply_text("Searching...")
+    try:
+        r = await fetch(f"{ARQ}saavn?query={query}")
+    except Exception as e:
+        await m.edit(str(e))
+        return
+    sname = r[0]['song']
+    slink = r[0]['media_url']
+    ssingers = r[0]['singers']
+    await m.edit("Downloading") 
+    song = await download_song(slink)
+    await m.edit("Uploading") 
+    await message.reply_audio(audio=song, title=sname,
+                              performer=ssingers)
+    os.remove(song)
+    await m.delete()

+ 3 - 4
wbb/modules/paste.py

@@ -1,7 +1,6 @@
 import os
 from pyrogram import filters
-from pyrogram.types import Message
-from wbb.utils import cust_filter, nekobin
+from wbb.utils import nekobin
 from wbb.utils.errors import capture_err
 from wbb import app
 
@@ -9,9 +8,9 @@ __MODULE__ = "Paste"
 __HELP__ = "/paste - To Paste Replied Text Or Document To Neokobin"
 
 
-@app.on_message(cust_filter.command(commands=("paste")) & ~filters.edited)
+@app.on_message(filters.command("paste") & ~filters.edited)
 @capture_err
-async def paste(_, message: Message):
+async def paste(_, message):
     if bool(message.reply_to_message) is True:
         app.set_parse_mode("markdown")
         if bool(message.reply_to_message.text) is True:

+ 2 - 4
wbb/modules/ping.py

@@ -1,8 +1,6 @@
 import requests
 from pyrogram import filters
-from pyrogram.types import Message
 from wbb import app
-from wbb.utils import cust_filter
 from wbb.utils.botinfo import BOT_DC_ID
 from wbb.utils.errors import capture_err
 
@@ -10,9 +8,9 @@ __MODULE__ = "Ping"
 __HELP__ = " /ping - To Get Response Time From All TG Datacenters"
 
 
-@app.on_message(cust_filter.command(commands=("ping")) & ~filters.edited)
+@app.on_message(filters.command("ping") & ~filters.edited)
 @capture_err
-async def ping(_, message: Message):
+async def ping(_, message):
     datacenter = (f"https://cdn{BOT_DC_ID}.telesco.pe")
     ping1 = round(requests.head(datacenter).elapsed.total_seconds() * 1000)
     result = f'`DC{BOT_DC_ID} - {ping1}ms`\n'

+ 2 - 4
wbb/modules/reddit.py

@@ -1,17 +1,15 @@
 import requests as r
-from pyrogram.types import Message
 from pyrogram import filters
 from wbb import app
-from wbb.utils import cust_filter
 from wbb.utils.errors import capture_err
 
 
 __MODULE__ = "Reddit"
 __HELP__ = "/reddit [query] - results something from reddit"
 
-@app.on_message(cust_filter.command(commands=("reddit")) & ~filters.edited)
+@app.on_message(filters.command("reddit") & ~filters.edited)
 @capture_err
-async def reddit(_, message: Message):
+async def reddit(_, message):
     if len(message.command) != 2:
         await message.reply_text("/reddit needs an argument")
         return

+ 2 - 4
wbb/modules/repo.py

@@ -1,7 +1,5 @@
 from pyrogram import filters
-from pyrogram.types import Message
 from wbb import app
-from wbb.utils import cust_filter
 from wbb.utils.errors import capture_err
 
 __MODULE__ = "Repo"
@@ -9,9 +7,9 @@ __HELP__ = "/repo - To Get My Github Repository Link " \
            "And Support Group Link"
 
 
-@app.on_message(cust_filter.command(commands=("repo")) & ~filters.edited)
+@app.on_message(filters.command("repo") & ~filters.edited)
 @capture_err
-async def repo(_, message: Message):
+async def repo(_, message):
     await message.reply_text(
         "[Github](https://github.com/thehamkercat/WilliamButcherBot)"
         + " | [Group](t.me/TheHamkerChat)", disable_web_page_preview=True)

+ 12 - 12
wbb/modules/search.py

@@ -1,23 +1,23 @@
 from youtube_search import YoutubeSearch
 from search_engine_parser import GoogleSearch
-from pyrogram.types import Message
 from pyrogram import filters
 from requests import get
 from wbb import app
-from wbb.utils import cust_filter
 from wbb.utils.errors import capture_err
 
 __MODULE__ = "Search"
 __HELP__ = '''/ud - Search For Something In Urban Dictionary
 /google - Search For Something On Google
+/so - Search For Something On Stack OverFlow
+/gh - Search For Something On GitHub
 /yt - Search For Something On YouTube'''
 
 # ud -  urbandictionary
 
 
-@app.on_message(cust_filter.command(commands=("ud")) & ~filters.edited)
+@app.on_message(filters.command("ud") & ~filters.edited)
 @capture_err
-async def urbandict(_, message: Message):
+async def urbandict(_, message):
     if len(message.command) < 2:
         await message.reply_text('"/ud" Needs An Argument.')
         return
@@ -41,9 +41,9 @@ async def urbandict(_, message: Message):
 # google
 
 
-@app.on_message(cust_filter.command(commands=("google")) & ~filters.edited)
+@app.on_message(filters.command("google") & ~filters.edited)
 @capture_err
-async def google(_, message: Message):
+async def google(_, message):
     try:
         if len(message.command) < 2:
             await message.reply_text('"/google" Needs An Argument')
@@ -68,9 +68,9 @@ async def google(_, message: Message):
 # StackOverflow [This is also a google search with some added args]
 
 
-@app.on_message(cust_filter.command(commands=("so")) & ~filters.edited)
+@app.on_message(filters.command("so") & ~filters.edited)
 @capture_err
-async def stack(_, message: Message):
+async def stack(_, message):
     try:
         if len(message.command) < 2:
             await message.reply_text('"/so" Needs An Argument')
@@ -96,9 +96,9 @@ async def stack(_, message: Message):
 # Github [This is also a google search with some added args]
 
 
-@app.on_message(cust_filter.command(commands=("gh")) & ~filters.edited)
+@app.on_message(filters.command("gh") & ~filters.edited)
 @capture_err
-async def github(_, message: Message):
+async def github(_, message):
     try:
         if len(message.command) < 2:
             await message.reply_text('"/gh" Needs An Argument')
@@ -124,9 +124,9 @@ async def github(_, message: Message):
 # YouTube
 
 
-@app.on_message(cust_filter.command(commands=("yt")) & ~filters.edited)
+@app.on_message(filters.command("yt") & ~filters.edited)
 @capture_err
-async def ytsearch(_, message: Message):
+async def ytsearch(_, message):
     try:
         if len(message.command) < 2:
             await message.reply_text("/yt needs an argument")

+ 12 - 66
wbb/modules/sudoers.py

@@ -1,15 +1,11 @@
-import os
 import re
-import requests
 import time
-import wget
 from pyrogram import filters, types
-from pyrogram.types import Message
 import speedtest
 import psutil
-from wbb.utils import cust_filter, nekobin, formatter
+from wbb.utils import nekobin, formatter
 from wbb.utils.errors import capture_err
-from wbb import app, OWNER_ID, SUDO_USER_ID, bot_start_time, NEOFETCH, JSMAPI
+from wbb import app, SUDOERS, bot_start_time
 
 __MODULE__ = "Sudoers"
 __HELP__ = '''/log - To Get Logs From Last Run.
@@ -17,15 +13,13 @@ __HELP__ = '''/log - To Get Logs From Last Run.
 /stats - To Check System Status.
 /song - To Download Songs From JioSaavn'''
 
-SUDOERS = [OWNER_ID, SUDO_USER_ID]
-
 
 # Logs Module
 
 
-@app.on_message(filters.user(SUDOERS) & cust_filter.command("log"))
+@app.on_message(filters.user(SUDOERS) & filters.command("log"))
 @capture_err
-async def logs_chat(_, message: Message):
+async def logs_chat(_, message):
     keyb = types.InlineKeyboardMarkup(
         [
             [
@@ -78,10 +72,10 @@ def speed_convert(size):
 
 
 @app.on_message(
-    filters.user(SUDOERS) & cust_filter.command(commands=("speedtest"))
+    filters.user(SUDOERS) & filters.command("speedtest")
 )
 @capture_err
-async def get_speedtest_result(_, message: Message):
+async def get_speedtest_result(_, message):
     m = await message.reply_text("`Performing A Speedtest!`")
     speed = speedtest.Speedtest()
     i = speed.get_best_server()
@@ -97,64 +91,16 @@ Latency  - {round((i["latency"]))} ms
 
 
 @app.on_message(
-    filters.user(SUDOERS) & cust_filter.command(commands=("stats"))
+    filters.user(SUDOERS) & filters.command("stats")
 )
 @capture_err
-async def get_stats(_, message: Message):
+async def get_stats(_, message):
     bot_uptime = int(time.time() - bot_start_time)
     cpu = psutil.cpu_percent(interval=0.5)
     mem = psutil.virtual_memory().percent
     disk = psutil.disk_usage("/").percent
-    if NEOFETCH == "True":
-        os.system("neofetch --stdout > neofetch.txt")
-        i = open("neofetch.txt", "r")
-        read_file = i.read()
-        neofetch = (f'''
-----------[Neofetch]----------
-
-{read_file}
-''')
-        i.close()
-    else:
-        neofetch = "NeoFetch Is Disabled!"
-    stats = (f'''
-```
-----------[Stats]----------
-
-      Uptime: {formatter.get_readable_time((bot_uptime))}
-      CPU: {cpu}%
-      RAM: {mem}%
-      Disk: {disk}%
-{neofetch}
-```''')
+    stats = (f'''```Uptime: {formatter.get_readable_time((bot_uptime))}
+CPU: {cpu}%
+RAM: {mem}%
+Disk: {disk}%```''')
     await message.reply_text(stats)
-
-# Song
-
-
-@app.on_message(
-    filters.user(SUDOERS) & cust_filter.command(commands=("song"))
-)
-@capture_err
-async def song(_, message: Message):
-    if len(message.command) < 2:
-        await message.reply_text("/song requires an argument.")
-        return
-    text = message.text.split(None, 1)[1]
-    query = text.replace(" ", "%20")
-    m = await message.reply_text("Searching...")
-    try:
-        r = requests.get(f"{JSMAPI}{query}")
-    except Exception as e:
-        await m.edit(str(e))
-        return
-    sname = r.json()[0]['song']
-    slink = r.json()[0]['media_url']
-    ssingers = r.json()[0]['singers']
-    file = wget.download(slink)
-    ffile = file.replace("mp4", "m4a")
-    os.rename(file, ffile)
-    await message.reply_audio(audio=ffile, title=sname,
-                              performer=ssingers)
-    os.remove(ffile)
-    await m.delete()

+ 2 - 0
wbb/utils/botinfo.py

@@ -18,3 +18,5 @@ async def get_info(app):
     BOT_DC_ID = getme.dc_id
     try:
         await app.send_message(LOG_GROUP_ID, text=f"{BOT_NAME} Started!")
+    except:
+        pass

+ 0 - 68
wbb/utils/cust_filter.py

@@ -1,68 +0,0 @@
-import shlex
-from typing import List
-import re
-
-from pyrogram.filters import create
-from pyrogram.types import Message
-
-from wbb import Command
-from wbb.utils.botinfo import BOT_USERNAME
-
-
-def command(
-    commands: str or List[str],
-    prefixes: str or List[str] = "/",
-    case_sensitive: bool = False,
-):
-    """
-    This is a drop in replacement for the default
-    cust_filter.command that is included in Pyrogram.
-    The Pyrogram one does not support /command@botname
-    type commands, so this custom filter enables that
-    throughout all groups and private chats. This filter
-    works exactly the same as the original command filter
-    even with support for multiple command prefixes and
-    case sensitivity. Command arguments are given to user
-    as message.command
-    """
-
-    async def func(flt, _, message: Message):
-        text: str = message.text or message.caption
-        message.command = None
-
-        if not text:
-            return False
-
-        regex = "^({prefix})+\\b({regex})\\b(\\b@{bot_name}\\b)?(.*)".format(
-            prefix="|".join(re.escape(x) for x in Command),
-            regex="|".join(flt.commands).lower(),
-            bot_name=BOT_USERNAME,
-        )
-
-        matches = re.search(re.compile(regex), text.lower())
-        if matches:
-            message.command = [matches.group(2)]
-            try:
-                for arg in shlex.split(matches.group(4).strip()):
-                    if arg == BOT_USERNAME:
-                        continue
-                    message.command.append(arg)
-            except ValueError:
-                return True
-            return True
-        return False
-
-    commands = commands if type(commands) is list else [commands]
-    commands = {c if case_sensitive else c.lower() for c in commands}
-
-    prefixes = [] if prefixes is None else prefixes
-    prefixes = prefixes if type(prefixes) is list else [prefixes]
-    prefixes = set(prefixes) if prefixes else {""}
-
-    return create(
-        func,
-        "CustomCommandFilter",
-        commands=commands,
-        prefixes=prefixes,
-        case_sensitive=case_sensitive,
-    )