Browse Source

Errors not go brr

TheHamkerCat 5 năm trước cách đây
mục cha
commit
83513ac734

+ 10 - 0
wbb/modules/admin.py

@@ -3,6 +3,7 @@ from pyrogram.types import Message, ChatPermissions
 from wbb import OWNER_ID, SUDO_USER_ID, app
 from wbb import OWNER_ID, SUDO_USER_ID, app
 from wbb.utils import cust_filter
 from wbb.utils import cust_filter
 from wbb.utils.botinfo import BOT_ID
 from wbb.utils.botinfo import BOT_ID
+from wbb.utils.errors import capture_err
 
 
 __MODULE__ = "Admin"
 __MODULE__ = "Admin"
 __HELP__ = '''/ban - Ban A User
 __HELP__ = '''/ban - Ban A User
@@ -40,6 +41,7 @@ async def list_members(group_id):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("purge")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("purge")) & ~filters.edited)
+@capture_err
 async def purge(client, message: Message):
 async def purge(client, message: Message):
     message_ids = []
     message_ids = []
     if message.chat.type not in ("supergroup", "channel"):
     if message.chat.type not in ("supergroup", "channel"):
@@ -90,6 +92,7 @@ async def purge(client, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("kick")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("kick")) & ~filters.edited)
+@capture_err
 async def kick(_, message: Message):
 async def kick(_, message: Message):
     try:
     try:
         if (await app.get_chat_member(
         if (await app.get_chat_member(
@@ -131,6 +134,7 @@ async def kick(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("ban")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("ban")) & ~filters.edited)
+@capture_err
 async def ban(_, message: Message):
 async def ban(_, message: Message):
     try:
     try:
         if (await app.get_chat_member(
         if (await app.get_chat_member(
@@ -171,6 +175,7 @@ async def ban(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("unban")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("unban")) & ~filters.edited)
+@capture_err
 async def unban(_, message: Message):
 async def unban(_, message: Message):
     try:
     try:
         if (await app.get_chat_member(
         if (await app.get_chat_member(
@@ -205,6 +210,7 @@ async def unban(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("del")))
 @app.on_message(cust_filter.command(commands=("del")))
+@capture_err
 async def delete(_, message: Message):
 async def delete(_, message: Message):
     try:
     try:
         admins = await list_admins(message.chat.id)
         admins = await list_admins(message.chat.id)
@@ -230,6 +236,7 @@ async def delete(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("promote")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("promote")) & ~filters.edited)
+@capture_err
 async def promote(_, message: Message):
 async def promote(_, message: Message):
     try:
     try:
         admins = await list_admins(message.chat.id)
         admins = await list_admins(message.chat.id)
@@ -280,6 +287,7 @@ async def promote(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("pin")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("pin")) & ~filters.edited)
+@capture_err
 async def pin(_, message: Message):
 async def pin(_, message: Message):
     try:
     try:
         admins = await list_admins(message.chat.id)
         admins = await list_admins(message.chat.id)
@@ -305,6 +313,7 @@ async def pin(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("mute")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("mute")) & ~filters.edited)
+@capture_err
 async def mute(_, message: Message):
 async def mute(_, message: Message):
     try:
     try:
         chat_id = message.chat.id
         chat_id = message.chat.id
@@ -331,6 +340,7 @@ async def mute(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("unmute")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("unmute")) & ~filters.edited)
+@capture_err
 async def unmute(_, message: Message):
 async def unmute(_, message: Message):
     try:
     try:
         chat_id = message.chat.id
         chat_id = message.chat.id

+ 1 - 1
wbb/modules/eval.py

@@ -59,7 +59,7 @@ async def executor(client, message):
         evaluation = stdout
         evaluation = stdout
     else:
     else:
         evaluation = "Success"
         evaluation = "Success"
-    final_output = (f"**OUTPUT**:\n```{evaluation.strip()}``")
+    final_output = (f"**OUTPUT**:\n```{evaluation.strip()}```")
     if len(final_output) > 4096:
     if len(final_output) > 4096:
         filename = "output.txt"
         filename = "output.txt"
         with open(filename, "w+", encoding="utf8") as out_file:
         with open(filename, "w+", encoding="utf8") as out_file:

+ 3 - 0
wbb/modules/f.py

@@ -2,6 +2,8 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
 from wbb import app
 from wbb import app
 from pyrogram import filters
 from pyrogram import filters
 from wbb.modules.admin import list_admins
 from wbb.modules.admin import list_admins
+from wbb.utils.errors import capture_err
+
 i = 0
 i = 0
 m = None
 m = None
 pressers = []
 pressers = []
@@ -16,6 +18,7 @@ keyboard = InlineKeyboardMarkup(
 
 
 
 
 @app.on_message(filters.command("f"))
 @app.on_message(filters.command("f"))
+@capture_err
 async def f(_, message):
 async def f(_, message):
     global i, m, pressers
     global i, m, pressers
     i = 0
     i = 0

+ 3 - 0
wbb/modules/github.py

@@ -1,12 +1,15 @@
 import aiohttp
 import aiohttp
 from pyrogram import filters
 from pyrogram import filters
 from wbb import app
 from wbb import app
+from wbb.utils.errors import capture_err
+
 
 
 __MODULE__ = 'Github'
 __MODULE__ = 'Github'
 __HELP__ = "Get information about a GitHub user.\n /github [username]"
 __HELP__ = "Get information about a GitHub user.\n /github [username]"
 
 
 
 
 @app.on_message(filters.command('github'))
 @app.on_message(filters.command('github'))
+@capture_err
 async def github(_, message):
 async def github(_, message):
     if len(message.command) != 2:
     if len(message.command) != 2:
         await message.reply_text("/git Username")
         await message.reply_text("/git Username")

+ 5 - 7
wbb/modules/greetings.py

@@ -13,24 +13,21 @@ import asyncio
 from datetime import datetime
 from datetime import datetime
 from pyrogram import filters
 from pyrogram import filters
 from wbb import app, WELCOME_DELAY_KICK_SEC
 from wbb import app, WELCOME_DELAY_KICK_SEC
+from wbb.utils.errors import capture_err
 from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
 from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
 from pyrogram.types import ChatPermissions
 from pyrogram.types import ChatPermissions
 from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant, ChatAdminRequired
 from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant, ChatAdminRequired
-
+from pyrogram.errors.exceptions.forbidden_403 import 
 
 
 @app.on_message(filters.new_chat_members)
 @app.on_message(filters.new_chat_members)
+@capture_err
 async def welcome(_, message: Message):
 async def welcome(_, message: Message):
     """Mute new member and send message with button"""
     """Mute new member and send message with button"""
     new_members = [f"{u.mention}" for u in message.new_chat_members]
     new_members = [f"{u.mention}" for u in message.new_chat_members]
     text = (f"Welcome, {', '.join(new_members)}\n**Are you human?**\n"
     text = (f"Welcome, {', '.join(new_members)}\n**Are you human?**\n"
             "You will be removed from this chat if you are not verified "
             "You will be removed from this chat if you are not verified "
             f"in {WELCOME_DELAY_KICK_SEC} seconds")
             f"in {WELCOME_DELAY_KICK_SEC} seconds")
-    try:
-        await message.chat.restrict_member(message.from_user.id, ChatPermissions())
-    except ChatAdminRequired:
-        msg = "Yeah, I Can't Verify Newly Joined Members, Make Sure I'm Admin."
-        await message.reply_text(msg)
-        return
+    await message.chat.restrict_member(message.from_user.id, ChatPermissions())
 
 
     button_message = await message.reply(
     button_message = await message.reply(
         text,
         text,
@@ -82,6 +79,7 @@ async def kick_restricted_after_delay(delay, button_message: Message):
 
 
 
 
 @app.on_message(filters.left_chat_member)
 @app.on_message(filters.left_chat_member)
+@capture_err
 async def left_chat_member(_, message: Message):
 async def left_chat_member(_, message: Message):
     """When a restricted member left the chat, ban him for a while"""
     """When a restricted member left the chat, ban him for a while"""
     group_chat = message.chat
     group_chat = message.chat

+ 3 - 0
wbb/modules/images.py

@@ -7,6 +7,7 @@ from pyrogram import filters
 from pyrogram.types import Message
 from pyrogram.types import Message
 from wbb.utils import cust_filter
 from wbb.utils import cust_filter
 from wbb import app, WALL_API_KEY
 from wbb import app, WALL_API_KEY
+from wbb.utils.errors import capture_err
 
 
 __MODULE__ = "Images"
 __MODULE__ = "Images"
 __HELP__ = '''/cat  - Get Cute Cats Images
 __HELP__ = '''/cat  - Get Cute Cats Images
@@ -19,6 +20,7 @@ async def delete_message_with_delay(delay, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("cat")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("cat")) & ~filters.edited)
+@capture_err
 async def cat(_, message: Message):
 async def cat(_, message: Message):
     with urllib.request.urlopen(
     with urllib.request.urlopen(
         "https://api.thecatapi.com/v1/images/search"
         "https://api.thecatapi.com/v1/images/search"
@@ -29,6 +31,7 @@ async def cat(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("wall")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("wall")) & ~filters.edited)
+@capture_err
 async def wall(_, message: Message):
 async def wall(_, message: Message):
     if len(message.command) < 2:
     if len(message.command) < 2:
         await message.reply_text("/wall needs an argument")
         await message.reply_text("/wall needs an argument")

+ 12 - 0
wbb/modules/misc.py

@@ -7,6 +7,7 @@ from googletrans import Translator
 from cryptography.fernet import Fernet
 from cryptography.fernet import Fernet
 from wbb import app, FERNET_ENCRYPTION_KEY
 from wbb import app, FERNET_ENCRYPTION_KEY
 from wbb.utils import cust_filter, random_line
 from wbb.utils import cust_filter, random_line
+from wbb.utils.errors import capture_err
 
 
 __MODULE__ = "Misc"
 __MODULE__ = "Misc"
 __HELP__ = '''/commit - Generate Funny Commit Messages
 __HELP__ = '''/commit - Generate Funny Commit Messages
@@ -25,10 +26,12 @@ __HELP__ = '''/commit - Generate Funny Commit Messages
 
 
 
 
 @app.on_message(cust_filter.command(commands=("commit")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("commit")) & ~filters.edited)
+@capture_err
 async def commit(_, message: Message):
 async def commit(_, message: Message):
     await message.reply_text((await random_line('wbb/utils/commit.txt')))
     await message.reply_text((await random_line('wbb/utils/commit.txt')))
 
 
 @app.on_message(filters.command("RTFM", "#"))
 @app.on_message(filters.command("RTFM", "#"))
+@capture_err
 async def rtfm(_, message):
 async def rtfm(_, message):
     await message.delete()
     await message.delete()
     if not message.reply_to_message:
     if not message.reply_to_message:
@@ -38,11 +41,13 @@ async def rtfm(_, message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("runs")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("runs")) & ~filters.edited)
+@capture_err
 async def runs(_, message: Message):
 async def runs(_, message: Message):
     await message.reply_text((await random_line('wbb/utils/runs.txt')))
     await message.reply_text((await random_line('wbb/utils/runs.txt')))
 
 
 
 
 @app.on_message(cust_filter.command(commands=("id")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("id")) & ~filters.edited)
+@capture_err
 async def get_id(_, message: Message):
 async def get_id(_, message: Message):
     if len(message.command) != 1:
     if len(message.command) != 1:
         username = message.text.split(None, 1)[1]
         username = message.text.split(None, 1)[1]
@@ -65,6 +70,7 @@ async def get_id(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=('random')) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=('random')) & ~filters.edited)
+@capture_err
 async def random(_, message: Message):
 async def random(_, message: Message):
     if len(message.command) != 2:
     if len(message.command) != 2:
         await message.reply_text('"/random" Needs An Argurment.'
         await message.reply_text('"/random" Needs An Argurment.'
@@ -88,6 +94,7 @@ async def random(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=('encrypt')) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=('encrypt')) & ~filters.edited)
+@capture_err
 async def encrypt(_, message: Message):
 async def encrypt(_, message: Message):
     if not message.reply_to_message:
     if not message.reply_to_message:
         await message.reply_text('Reply To A Message To Encrypt It.')
         await message.reply_text('Reply To A Message To Encrypt It.')
@@ -103,6 +110,7 @@ async def encrypt(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=('decrypt')) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=('decrypt')) & ~filters.edited)
+@capture_err
 async def decrypt(_, message: Message):
 async def decrypt(_, message: Message):
     if not message.reply_to_message:
     if not message.reply_to_message:
         await message.reply_text('Reply To A Message To Decrypt It.')
         await message.reply_text('Reply To A Message To Decrypt It.')
@@ -119,6 +127,7 @@ async def decrypt(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("cheat")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("cheat")) & ~filters.edited)
+@capture_err
 async def cheat(_, message: Message):
 async def cheat(_, message: Message):
     text = message.text.split(None, 1)[1]
     text = message.text.split(None, 1)[1]
     ftext = text.split()
     ftext = text.split()
@@ -140,6 +149,7 @@ async def cheat(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("weather")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("weather")) & ~filters.edited)
+@capture_err
 async def weather(_, message: Message):
 async def weather(_, message: Message):
     city = message.text.split(None, 1)[1]
     city = message.text.split(None, 1)[1]
     if len(message.command) != 2:
     if len(message.command) != 2:
@@ -153,6 +163,7 @@ async def weather(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("tr")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("tr")) & ~filters.edited)
+@capture_err
 async def tr(_, message: Message):
 async def tr(_, message: Message):
     lang = message.text.split(None, 1)[1]
     lang = message.text.split(None, 1)[1]
     if not message.reply_to_message or lang == "":
     if not message.reply_to_message or lang == "":
@@ -169,6 +180,7 @@ async def tr(_, message: Message):
 
 
 
 
 @app.on_message(filters.command('bun'))
 @app.on_message(filters.command('bun'))
+@capture_err
 async def bunn(_, message):
 async def bunn(_, message):
     if message.reply_to_message:
     if message.reply_to_message:
         await message.reply_to_message.reply_sticker('CAACAgUAAx0CWIlO9AABARyRYBhyjKXFATVhu7AGQwip3TzSFiMAAuMBAAJ7usBUIu2xBtXTmuweBA')
         await message.reply_to_message.reply_sticker('CAACAgUAAx0CWIlO9AABARyRYBhyjKXFATVhu7AGQwip3TzSFiMAAuMBAAJ7usBUIu2xBtXTmuweBA')

+ 2 - 0
wbb/modules/music.py

@@ -9,6 +9,7 @@ from pyrogram import filters
 from pyrogram.types import Message
 from pyrogram.types import Message
 from wbb.utils import cust_filter
 from wbb.utils import cust_filter
 from wbb import app, OWNER_ID, SUDO_USER_ID
 from wbb import app, OWNER_ID, SUDO_USER_ID
+from wbb.utils.errors import capture_err
 
 
 SUDOERS = [OWNER_ID, SUDO_USER_ID]
 SUDOERS = [OWNER_ID, SUDO_USER_ID]
 
 
@@ -27,6 +28,7 @@ ydl_opts = {
 
 
 
 
 @app.on_message(cust_filter.command(commands=("music")) & ~filters.edited & filters.user(SUDOERS))
 @app.on_message(cust_filter.command(commands=("music")) & ~filters.edited & filters.user(SUDOERS))
+@capture_err
 async def music(_, message: Message):
 async def music(_, message: Message):
     if len(message.command) != 2:
     if len(message.command) != 2:
         await message.reply_text("`/music` needs a link as argument")
         await message.reply_text("`/music` needs a link as argument")

+ 2 - 0
wbb/modules/paste.py

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

+ 2 - 1
wbb/modules/ping.py

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

+ 2 - 0
wbb/modules/repo.py

@@ -2,6 +2,7 @@ from pyrogram import filters
 from pyrogram.types import Message
 from pyrogram.types import Message
 from wbb import app
 from wbb import app
 from wbb.utils import cust_filter
 from wbb.utils import cust_filter
+from wbb.utils.errors import capture_err
 
 
 __MODULE__ = "Repo"
 __MODULE__ = "Repo"
 __HELP__ = "/repo - To Get My Github Repository Link " \
 __HELP__ = "/repo - To Get My Github Repository Link " \
@@ -9,6 +10,7 @@ __HELP__ = "/repo - To Get My Github Repository Link " \
 
 
 
 
 @app.on_message(cust_filter.command(commands=("repo")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("repo")) & ~filters.edited)
+@capture_err
 async def repo(_, message: Message):
 async def repo(_, message: Message):
     await message.reply_text(
     await message.reply_text(
         "[Github](https://github.com/thehamkercat/WilliamButcherBot)"
         "[Github](https://github.com/thehamkercat/WilliamButcherBot)"

+ 2 - 0
wbb/modules/rice.py

@@ -2,6 +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
 
 
 RICE_GROUP = "DE_WM"
 RICE_GROUP = "DE_WM"
 RICE_CHANNEL = "RiceGallery"
 RICE_CHANNEL = "RiceGallery"
@@ -12,6 +13,7 @@ RICE_CHANNEL = "RiceGallery"
                 & filters.regex(r"^\[RICE\] ")
                 & filters.regex(r"^\[RICE\] ")
                 & ~filters.forwarded
                 & ~filters.forwarded
                 & ~filters.edited)
                 & ~filters.edited)
+@capture_err
 async def rice(_, message: Message):
 async def rice(_, message: Message):
     """Forward media and media_group messages which has caption starts
     """Forward media and media_group messages which has caption starts
     with [RICE] with space and description in RICE_GROUP to RICE_CHANNEL
     with [RICE] with space and description in RICE_GROUP to RICE_CHANNEL

+ 6 - 0
wbb/modules/search.py

@@ -5,6 +5,7 @@ from pyrogram import filters
 from requests import get
 from requests import get
 from wbb import app
 from wbb import app
 from wbb.utils import cust_filter
 from wbb.utils import cust_filter
+from wbb.utils.errors import capture_err
 
 
 __MODULE__ = "Search"
 __MODULE__ = "Search"
 __HELP__ = '''/ud - Search For Something In Urban Dictionary
 __HELP__ = '''/ud - Search For Something In Urban Dictionary
@@ -15,6 +16,7 @@ __HELP__ = '''/ud - Search For Something In Urban Dictionary
 
 
 
 
 @app.on_message(cust_filter.command(commands=("ud")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("ud")) & ~filters.edited)
+@capture_err
 async def urbandict(_, message: Message):
 async def urbandict(_, message: Message):
     if len(message.command) < 2:
     if len(message.command) < 2:
         await message.reply_text('"/ud" Needs An Argument.')
         await message.reply_text('"/ud" Needs An Argument.')
@@ -40,6 +42,7 @@ async def urbandict(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("google")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("google")) & ~filters.edited)
+@capture_err
 async def google(_, message: Message):
 async def google(_, message: Message):
     try:
     try:
         if len(message.command) < 2:
         if len(message.command) < 2:
@@ -66,6 +69,7 @@ async def google(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("so")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("so")) & ~filters.edited)
+@capture_err
 async def stack(_, message: Message):
 async def stack(_, message: Message):
     try:
     try:
         if len(message.command) < 2:
         if len(message.command) < 2:
@@ -93,6 +97,7 @@ async def stack(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("gh")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("gh")) & ~filters.edited)
+@capture_err
 async def github(_, message: Message):
 async def github(_, message: Message):
     try:
     try:
         if len(message.command) < 2:
         if len(message.command) < 2:
@@ -120,6 +125,7 @@ async def github(_, message: Message):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("yt")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("yt")) & ~filters.edited)
+@capture_err
 async def ytsearch(_, message: Message):
 async def ytsearch(_, message: Message):
     try:
     try:
         if len(message.command) < 2:
         if len(message.command) < 2:

+ 5 - 1
wbb/modules/succ.py

@@ -3,9 +3,11 @@ from pyrogram.types import Message
 from pyrogram import filters
 from pyrogram import filters
 from wbb import app
 from wbb import app
 from wbb.utils import cust_filter
 from wbb.utils import cust_filter
+from wbb.utils.errors import capture_err
 
 
 __MODULE__ = "Succ"
 __MODULE__ = "Succ"
-__HELP__ = "/succ - Sends Succ Image For A Given Argument"
+__HELP__ = """/succ - Sends Succ Image For A Given Argument
+/reddit [query] - results something from reddit"""
 
 
 hack = [
 hack = [
     "https://i.ibb.co/YLLhCtt/i.png",
     "https://i.ibb.co/YLLhCtt/i.png",
@@ -43,6 +45,7 @@ def suck(text):
 
 
 
 
 @app.on_message(cust_filter.command(commands=("succ")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("succ")) & ~filters.edited)
+@capture_err
 def succ(_, message: Message):
 def succ(_, message: Message):
     if len(message.command) != 2:
     if len(message.command) != 2:
         message.reply_text(
         message.reply_text(
@@ -63,6 +66,7 @@ phijiks, welth, smrt`"""
 
 
 
 
 @app.on_message(cust_filter.command(commands=("reddit")) & ~filters.edited)
 @app.on_message(cust_filter.command(commands=("reddit")) & ~filters.edited)
+@capture_err
 async def reddit(_, message: Message):
 async def reddit(_, message: Message):
     app.set_parse_mode("html")
     app.set_parse_mode("html")
     if len(message.command) != 2:
     if len(message.command) != 2:

+ 5 - 0
wbb/modules/sudoers.py

@@ -8,6 +8,7 @@ from pyrogram.types import Message
 import speedtest
 import speedtest
 import psutil
 import psutil
 from wbb.utils import cust_filter, nekobin, formatter
 from wbb.utils import cust_filter, 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, OWNER_ID, SUDO_USER_ID, bot_start_time, NEOFETCH, JSMAPI
 
 
 __MODULE__ = "Sudoers"
 __MODULE__ = "Sudoers"
@@ -23,6 +24,7 @@ SUDOERS = [OWNER_ID, SUDO_USER_ID]
 
 
 
 
 @app.on_message(filters.user(SUDOERS) & cust_filter.command("log"))
 @app.on_message(filters.user(SUDOERS) & cust_filter.command("log"))
+@capture_err
 async def logs_chat(_, message: Message):
 async def logs_chat(_, message: Message):
     keyb = types.InlineKeyboardMarkup(
     keyb = types.InlineKeyboardMarkup(
         [
         [
@@ -78,6 +80,7 @@ def speed_convert(size):
 @app.on_message(
 @app.on_message(
     filters.user(SUDOERS) & cust_filter.command(commands=("speedtest"))
     filters.user(SUDOERS) & cust_filter.command(commands=("speedtest"))
 )
 )
+@capture_err
 async def get_speedtest_result(_, message: Message):
 async def get_speedtest_result(_, message: Message):
     m = await message.reply_text("`Performing A Speedtest!`")
     m = await message.reply_text("`Performing A Speedtest!`")
     speed = speedtest.Speedtest()
     speed = speedtest.Speedtest()
@@ -96,6 +99,7 @@ Latency  - {round((i["latency"]))} ms
 @app.on_message(
 @app.on_message(
     filters.user(SUDOERS) & cust_filter.command(commands=("stats"))
     filters.user(SUDOERS) & cust_filter.command(commands=("stats"))
 )
 )
+@capture_err
 async def get_stats(_, message: Message):
 async def get_stats(_, message: Message):
     bot_uptime = int(time.time() - bot_start_time)
     bot_uptime = int(time.time() - bot_start_time)
     cpu = psutil.cpu_percent(interval=0.5)
     cpu = psutil.cpu_percent(interval=0.5)
@@ -131,6 +135,7 @@ async def get_stats(_, message: Message):
 @app.on_message(
 @app.on_message(
     filters.user(SUDOERS) & cust_filter.command(commands=("song"))
     filters.user(SUDOERS) & cust_filter.command(commands=("song"))
 )
 )
+@capture_err
 async def song(_, message: Message):
 async def song(_, message: Message):
     if len(message.command) < 2:
     if len(message.command) < 2:
         await message.reply_text("/song requires an argument.")
         await message.reply_text("/song requires an argument.")

+ 48 - 0
wbb/utils/errors.py

@@ -0,0 +1,48 @@
+import sys
+import traceback
+from functools import wraps
+from wbb import app, OWNER_ID
+
+def split_limits(text):
+    if len(text) < 2048:
+        return [text]
+
+    lines = text.splitlines(True)
+    small_msg = ''
+    result = []
+    for line in lines:
+        if len(small_msg) + len(line) < 2048:
+            small_msg += line
+        else:
+            result.append(small_msg)
+            small_msg = line
+    else:
+        result.append(small_msg)
+
+    return result
+
+def capture_err(func):
+    @wraps(func)
+    async def capture(client, message, *args, **kwargs):
+        try:
+            return await func(client, message, *args, **kwargs)
+        except Exception as err:
+            exc_type, exc_obj, exc_tb = sys.exc_info()
+            errors = traceback.format_exception(
+                etype=exc_type, value=exc_obj, tb=exc_tb,
+            )
+            error_feedback = split_limits(
+                '**ERROR** | `{}` | `{}`\n\n```{}```\n\n```{}```\n'.format(
+                    0 if not message.from_user else message.from_user.id,
+                    0 if not message.chat else message.chat.id,
+                    message.text or message.caption,
+                    ''.join(errors),
+                ),
+            )
+            for x in error_feedback:
+                await app.send_message(
+                    OWNER_ID,
+                    x
+                )
+            raise err
+    return capture