2024-01-31 19:37:01 +10:00
|
|
|
class UserPrivacyException(Exception):
|
|
|
|
"""Occurs when user's privacy setting doesn't allow certain actions (e.g., inviting to a channel, sending a message)"""
|
|
|
|
def __init__(self, error: Exception, *args: object) -> None:
|
|
|
|
self.error = error
|
|
|
|
|
|
|
|
self.message = f"Can't do action due to user's privacy settings"
|
|
|
|
super().__init__(self.message, *args)
|
|
|
|
|
|
|
|
class AdminPrivilegesExceptions(Exception):
|
|
|
|
"""Occurs when administrator privileges are required to perform a certain action (e.g., channel invitations, user parsing)"""
|
|
|
|
def __init__(self, error: Exception, *args: object) -> None:
|
|
|
|
self.error = error
|
|
|
|
|
|
|
|
self.message = f"Administrator privileges are required to perform the action."
|
|
|
|
super().__init__(self.message, *args)
|
|
|
|
|
|
|
|
class FloodException(Exception):
|
|
|
|
def __init__(self, error, *args: object):
|
|
|
|
self.error = error
|
|
|
|
self.seconds = self.error.seconds if hasattr(self.error, "seconds") else -1 #type: ignore
|
2024-02-08 18:00:06 +10:00
|
|
|
self.message = f"Flood wait for {self.seconds}" if self.seconds > 0 else "Flood error"
|
|
|
|
|
|
|
|
super().__init__(self.message, *args)
|
2024-01-31 19:37:01 +10:00
|
|
|
|
|
|
|
class IgnoreException(Exception):
|
|
|
|
def __init__(self, error, *args):
|
|
|
|
self.error = error
|
|
|
|
|
|
|
|
super().__init__(*args)
|
|
|
|
|
|
|
|
class TooMuchException(Exception):
|
|
|
|
def __init__(self, error, *args):
|
|
|
|
self.error = error
|
|
|
|
|
|
|
|
super().__init__(*args)
|
|
|
|
|
|
|
|
class NeedPasswordException(Exception):
|
|
|
|
def __init__(self, *args):
|
|
|
|
self.message = "Need password"
|
|
|
|
|
|
|
|
super().__init__(self.message, *args)
|