Explorar o código

Leave the fucking chat

TheHamkerCat %!s(int64=5) %!d(string=hai) anos
pai
achega
faab96f88a
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      wbb/utils/errors.py

+ 4 - 1
wbb/utils/errors.py

@@ -2,7 +2,7 @@ import sys
 import traceback
 from functools import wraps
 from wbb import app, LOG_GROUP_ID
-
+from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden
 
 def split_limits(text):
     if len(text) < 2048:
@@ -28,6 +28,9 @@ def capture_err(func):
     async def capture(client, message, *args, **kwargs):
         try:
             return await func(client, message, *args, **kwargs)
+        except ChatWriteForbidden:
+            await app.leave_chat(message.chat.id)
+            return
         except Exception as err:
             exc_type, exc_obj, exc_tb = sys.exc_info()
             errors = traceback.format_exception(