twisted/plugins/fixbot_nexus_plugin.py
author Tero Marttila <terom@fixme.fi>
Fri, 05 Feb 2010 21:39:51 +0200
changeset 57 31e7421e98af
parent 43 78bc61c677d8
child 62 e4db89a5f6bc
permissions -rw-r--r--
rename event_type to label
from zope.interface import implements

from twisted.python import usage
from twisted.plugin import IPlugin
from twisted.application.service import IServiceMaker

from twisted.application import internet

from fixbot import config, nexus

class NexusOptions (config.ConfigOptions) :
    
    optParameters = [
        (   "irc-server",   "s",    "irc.fixme.fi",     "IRC server hostname",                          ),
        (   "irc-port",     "p",    6667,               "IRC server port",                      int     ),
        (   "irc-nickname", "N",    "FixBotDev",        "IRC nickname",                                 ),
        (   "irc-username", "U",    "fixbot",           "IRC username",                                 ),
        (   "irc-channel",  "C",    "#fixme-test",      "IRC channel",                                  ),
        (   "api-listen",   "l",    "127.0.0.1",        "address for API server to listen on"           ),
        (   "api-port",     "P",    34888,              "port for API server to listen on",     int     ),
        (   "api-secret",   None,   None,               "secret key for API connections"                ),
    ]

    optFlags = [

    ]

class MyServiceMaker (object) :
    implements(IServiceMaker, IPlugin)
    tapname = "fixbot-nexus"
    description = "FixBot (nexus component)"
    options = NexusOptions

    def makeService (self, config) :
        if config['api-secret'] is None :
            raise usage.UsageError("No value given for required option api-secret")

        return nexus.makeService(config)

serviceMaker = MyServiceMaker()