a lot of stuff in here around support for loading plugins from arbitrary files. plugins have a basic amount of initialization and then hook into the core IRC event system it makes sense to have modules respond to regexes, so there's some handler stuff for that --- it was the most popular way to do stuff in the old version of the bot we need to check that people trying to load plugins are admins, so there's some stuff for that, too the expectation is that many features from here are happen in plugins, rather than modifying the core bot
47 lines
1018 B
Python
47 lines
1018 B
Python
"""Track basic IRC settings and similar."""
|
|
|
|
import logging
|
|
|
|
from django.db import models
|
|
|
|
|
|
log = logging.getLogger('ircbot.models')
|
|
|
|
|
|
class BotAdmin(models.Model):
|
|
|
|
"""Configure admins, which can do things through the bot that others can't."""
|
|
|
|
nickmask = models.CharField(max_length=200, unique=True)
|
|
|
|
def __unicode__(self):
|
|
"""String representation."""
|
|
|
|
return u"{0:s}".format(self.nickmask)
|
|
|
|
|
|
class IrcChannel(models.Model):
|
|
|
|
"""Track channel settings."""
|
|
|
|
name = models.CharField(max_length=200, unique=True)
|
|
autojoin = models.BooleanField(default=False)
|
|
|
|
def __unicode__(self):
|
|
"""String representation."""
|
|
|
|
return u"{0:s}".format(self.name)
|
|
|
|
|
|
class IrcPlugin(models.Model):
|
|
|
|
"""Represent an IRC plugin and its loading settings."""
|
|
|
|
path = models.CharField(max_length=200, unique=True)
|
|
autoload = models.BooleanField(default=False)
|
|
|
|
def __unicode__(self):
|
|
"""String representation."""
|
|
|
|
return u"{0:s}".format(self.path)
|