twisted/plugins/fixbot_nexus_plugin.py
author Tero Marttila <terom@fixme.fi>
Thu, 04 Feb 2010 19:17:29 +0200
changeset 37 6fd6a9fdc001
parent 35 5b6043ce9686
child 43 78bc61c677d8
permissions -rw-r--r--
add --config, and rename some of the option names/shortnames
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()