"""Library and convenience methods for the IRC bot and plugins.""" import logging from ircbot.models import BotAdmin log = logging.getLogger('ircbot.lib') class Plugin(object): """Plugin base class.""" def __init__(self, bot, connection, event): """Initialization stuff here --- global handlers, configs from database, so on.""" self.bot = bot self.connection = connection self.event = event log.info(u"initialized %s", self.__class__.__name__) def start(self): """Initialization stuff here --- global handlers, configs from database, so on.""" log.info(u"started %s", self.__class__.__name__) def stop(self): """Teardown stuff here --- unregister handlers, for example.""" log.info(u"stopped %s", self.__class__.__name__) def is_admin(source): """Check if the provided event source is a bot admin.""" if source in BotAdmin.objects.values_list('nickmask', flat=True): log.debug(u"in is_admin; True") return True log.debug(u"in is_admin; False") return False