فهرست منبع

Suppress known error and removed useless pass statement. (#196)

* suppress known error.

* Update inlinefuncs.py
ÁÑÑÍHÌLÅTØR SPÄRK 4 سال پیش
والد
کامیت
ac213e3e5a
2فایلهای تغییر یافته به همراه4 افزوده شده و 7 حذف شده
  1. 2 3
      wbb/modules/admin.py
  2. 2 4
      wbb/utils/inlinefuncs.py

+ 2 - 3
wbb/modules/admin.py

@@ -24,6 +24,7 @@ SOFTWARE.
 import asyncio
 import re
 
+from contextlib import suppress
 from time import time
 from pyrogram.errors import FloodWait
 from pyrogram import filters
@@ -280,14 +281,12 @@ async def banFunc(_, message: Message):
         msg += f"**Banned For:** {time_value}\n"
         if temp_reason:
             msg += f"**Reason:** {temp_reason}"
-        try:
+        with suppress(AttributeError):
             if len(time_value[:-1]) < 3:
                 await message.chat.ban_member(user_id, until_date=temp_ban)
                 await message.reply_text(msg)
             else:
                 await message.reply_text("You can't use more than 99")
-        except AttributeError:
-            pass
         return
     if reason:
         msg += f"**Reason:** {reason}"

+ 2 - 4
wbb/utils/inlinefuncs.py

@@ -24,6 +24,7 @@ SOFTWARE.
 import asyncio
 import os
 import sys
+from contextlib import suppress
 from html import escape
 from re import sub as re_sub
 from sys import version as pyver
@@ -227,7 +228,7 @@ async def google_search_func(answers, text):
             break
         limit += 1
 
-        try:
+        with suppress(KeyError):
             msg = f"""
 [{i['titles']}]({i['links']})
 {i['descriptions']}"""
@@ -241,8 +242,6 @@ async def google_search_func(answers, text):
                     ),
                 )
             )
-        except KeyError:
-            pass
     return answers
 
 
@@ -306,7 +305,6 @@ async def torrent_func(answers, text):
                 ),
             )
         )
-        pass
     return answers