# Path: cardinal/exceptions.py
# class CommandNotFoundError(CardinalException):
#     """Raised when a given command isn't loaded."""
# 
# class ConfigNotFoundError(CardinalException):
#     """Raised when an expected plugin config isn't found."""
# 
# class EventAlreadyExistsError(CardinalException):
#     """Raised durring attempt to register an event name already registered."""
# 
# class EventCallbackError(CardinalException):
#     """Raised when there is an error with a callback."""
# 
# class EventDoesNotExistError(CardinalException):
#     """Raised during attempt to register a callback for a nonexistent event."""
# 
# class EventRejectedMessage(CardinalException):
#     """Raised when an event callback wants to reject an event."""
# 
# class PluginError(CardinalException):
#     """Raised when a plugin is invalid in some way."""


import os
import re
import string
import logging
import importlib
import inspect
import linecache
import random
import json
from collections import defaultdict
from copy import copy
from importlib import reload
from cardinal.exceptions import (
    CommandNotFoundError,
    ConfigNotFoundError,
    EventAlreadyExistsError,
    EventCallbackError,
    EventDoesNotExistError,
    EventRejectedMessage,
    PluginError,
)
from twisted.internet import defer
          name -- Name of the event.
          required_params -- Number of parameters a callback must take.

        Raises:
          EventAlreadyExistsError -- If register is attempted for an event name
            already in use.
          TypeError -- If required_params is not a number.
        """
        self.logger.debug("Attempting to register event: %s" % name)

        if name in self.registered_events:
            self.logger.debug("Event already exists: %s" % name)
            raise EventAlreadyExistsError("Event already exists: %s" % name)

        if not isinstance(required_params, (int, int)):
            self.logger.debug("Invalid required params: %s" % name)
            raise TypeError("Required params must be an integer")

        self.registered_events[name] = required_params
        if name not in self.registered_callbacks:
            self.registered_callbacks[name] = {}

        self.logger.info("Registered event: %s" % name)

    def remove(self, name):
        """Removes a registered event."""
        self.logger.debug("Attempting to unregister event: %s" % name)

        if name not in self.registered_events:
            self.logger.debug("Event does not exist: %s" % name)

# Path: cardinal/exceptions.py
# class CommandNotFoundError(CardinalException):
#     """Raised when a given command isn't loaded."""
# 
# class ConfigNotFoundError(CardinalException):
#     """Raised when an expected plugin config isn't found."""
# 
# class EventAlreadyExistsError(CardinalException):
#     """Raised durring attempt to register an event name already registered."""
# 
# class EventCallbackError(CardinalException):
#     """Raised when there is an error with a callback."""
# 
# class EventDoesNotExistError(CardinalException):
#     """Raised during attempt to register a callback for a nonexistent event."""
# 
# class EventRejectedMessage(CardinalException):
#     """Raised when an event callback wants to reject an event."""
# 
# class PluginError(CardinalException):
#     """Raised when a plugin is invalid in some way."""


# Path: cardinal/plugins.py
import os
import re
import string
import logging
import importlib
import inspect
import linecache
import random
import json
from collections import defaultdict
from copy import copy
from importlib import reload
from cardinal.exceptions import (
    CommandNotFoundError,
    ConfigNotFoundError,
    EventAlreadyExistsError,
    EventCallbackError,
    EventDoesNotExistError,
    EventRejectedMessage,
    PluginError,
)
from twisted.internet import defer

          name -- Name of the event.
          required_params -- Number of parameters a callback must take.

        Raises:
          EventAlreadyExistsError -- If register is attempted for an event name
            already in use.
          TypeError -- If required_params is not a number.
        """
        self.logger.debug("Attempting to register event: %s" % name)

        if name in self.registered_events:
            self.logger.debug("Event already exists: %s" % name)
            raise EventAlreadyExistsError("Event already exists: %s" % name)

        if not isinstance(required_params, (int, int)):
            self.logger.debug("Invalid required params: %s" % name)
            raise TypeError("Required params must be an integer")

        self.registered_events[name] = required_params
        if name not in self.registered_callbacks:
            self.registered_callbacks[name] = {}

        self.logger.info("Registered event: %s" % name)

    def remove(self, name):
        """Removes a registered event."""
        self.logger.debug("Attempting to unregister event: %s" % name)

        if name not in self.registered_events:
            self.logger.debug("Event does not exist: %s" % name)

            raise EventDoesNotExistError(