40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
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
|
|
|
|
super().__init__(*args)
|
|
|
|
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) |