this moves the dispatcher functionality that used to be in the old ircbot directly to django REST framework, which is more robust and allows for cooler stuff down the road. this still retains the ability to have the bot privmsg, that still happens over the XML-RPC interface, this is just a more convenient frontend to that
31 lines
696 B
Python
31 lines
696 B
Python
"""Track dispatcher configurations."""
|
|
|
|
import logging
|
|
|
|
from django.db import models
|
|
|
|
|
|
log = logging.getLogger('dispatch.models')
|
|
|
|
|
|
class Dispatcher(models.Model):
|
|
|
|
"""Handle incoming API requests and do something with them."""
|
|
|
|
PRIVMSG_TYPE = 'privmsg'
|
|
FILE_TYPE = 'file'
|
|
|
|
TYPE_CHOICES = (
|
|
(PRIVMSG_TYPE, "IRC privmsg"),
|
|
(FILE_TYPE, "Write to file"),
|
|
)
|
|
|
|
key = models.CharField(max_length=16, unique=True)
|
|
type = models.CharField(max_length=16, choices=TYPE_CHOICES)
|
|
destination = models.CharField(max_length=200)
|
|
|
|
def __unicode__(self):
|
|
"""String representation."""
|
|
|
|
return u"{0:s} -> {1:s}".format(self.key, self.destination)
|