def __init__(self): # Read command line options. (options, args) = self.get_options() # Read configuration. configfile = options.config or 'config.ini' configsection = options.section or 'LOCAL' self.cfg = Conf(configfile, configsection) self.cfg.set_items(vars(options)) try: for s in self.cfg.ignorelist.split(','): self.ignorelist.append(s.strip()) except AttributeError: pass # Setup database try: debug = self.cfg.get_bool('debug') except AttributeError: debug = False self.db = HaliDb('sqlite:///extras/twippy.db', debug) # Load list of plugins if not self.load_plugins(self.cfg.plugins): print "No plugins loaded. Quitting." sys.exit(1) # setup twitter self.setup_twitter()
def start_shoutbridge(): # Read command line options. (options, args) = get_options() # Read configuration. configfile = options.config or 'config.ini' configsection = options.section or 'LOCAL' cfg = Conf(configfile, configsection) cfg.set_items(vars(options)) if cfg.get_bool('verbose'): print "Shoutbridge started..." # Setup Shoutbox of = ObjectFactory() sbox = of.create(cfg.shoutbox_type, mod='shoutbox', inst="Shoutbox") #sbox.setConfig(cfg) # Setup xmpp bridge bridge = of.create(cfg.bridge_type, mod='bridges', inst="XmppBridge") bridge.setup(sbox, cfg) # Start bridge bridge.listen() if cfg.get_bool('verbose'): print "Shoutbridge ended."
class Twippy(BridgeClass): #: Conf object with configuration options to use. cfg = None #: List of references to loadd bot Plugins. plugins = dict() #: An ObjectFactory instance to use for loading plugins. of = None #: List of twitter accounts to ignore messages from. ignorelist = [] def __init__(self): # Read command line options. (options, args) = self.get_options() # Read configuration. configfile = options.config or 'config.ini' configsection = options.section or 'LOCAL' self.cfg = Conf(configfile, configsection) self.cfg.set_items(vars(options)) try: for s in self.cfg.ignorelist.split(','): self.ignorelist.append(s.strip()) except AttributeError: pass # Setup database try: debug = self.cfg.get_bool('debug') except AttributeError: debug = False self.db = HaliDb('sqlite:///extras/twippy.db', debug) # Load list of plugins if not self.load_plugins(self.cfg.plugins): print "No plugins loaded. Quitting." sys.exit(1) # setup twitter self.setup_twitter() def get_options(self): parser = OptionParser(version="%prog 1.0") parser.add_option("-c", "--config", dest="config", default="config.ini", help="Read configuration from FILE", metavar="FILE") parser.add_option("-S", "--section", dest="section", default="LOCAL", help="Read configuration from SECTION", metavar="SECTION") parser.add_option("-D", "--debug", action="store_true", dest="debug", default=False, help="Print RAW data sent and received on the stream.") return parser.parse_args() def load_plugins(self, plugs): """ Imports all configured Plugins and adds them to the list of active plugins. """ if not plugs: return if not self.of: self.of = ObjectFactory() pluginlist = plugs.split(',') for p in pluginlist: try: plug = self.of.create(p + "Plugin", mod='plugins', inst='Plugin', args=[self]) except ImportError, ie: self.logprint("Couldn't load plugin:", p, ie) continue plug.setup() self.logprint("Loaded plugin:", plug.name, "\n", plug.description) self.plugins[p] = plug return len(self.plugins)
class Twippy(BridgeClass): #: Conf object with configuration options to use. cfg = None #: List of references to loadd bot Plugins. plugins = dict() #: An ObjectFactory instance to use for loading plugins. of = None #: List of twitter accounts to ignore messages from. ignorelist = [] def __init__(self): # Read command line options. (options, args) = self.get_options() # Read configuration. configfile = options.config or 'config.ini' configsection = options.section or 'LOCAL' self.cfg = Conf(configfile, configsection) self.cfg.set_items(vars(options)) try: for s in self.cfg.ignorelist.split(','): self.ignorelist.append(s.strip()) except AttributeError: pass # Setup database try: debug = self.cfg.get_bool('debug') except AttributeError: debug = False self.db = HaliDb('sqlite:///extras/twippy.db', debug) # Load list of plugins if not self.load_plugins(self.cfg.plugins): print "No plugins loaded. Quitting." sys.exit(1) # setup twitter self.setup_twitter() def get_options(self): parser = OptionParser(version="%prog 1.0") parser.add_option("-c", "--config", dest="config", default="config.ini", help="Read configuration from FILE", metavar="FILE") parser.add_option("-S", "--section", dest="section", default="LOCAL", help="Read configuration from SECTION", metavar="SECTION") parser.add_option( "-D", "--debug", action="store_true", dest="debug", default=False, help="Print RAW data sent and received on the stream.") return parser.parse_args() def load_plugins(self, plugs): """ Imports all configured Plugins and adds them to the list of active plugins. """ if not plugs: return if not self.of: self.of = ObjectFactory() pluginlist = plugs.split(',') for p in pluginlist: try: plug = self.of.create(p + "Plugin", mod='plugins', inst='Plugin', args=[self]) except ImportError, ie: self.logprint("Couldn't load plugin:", p, ie) continue plug.setup() self.logprint("Loaded plugin:", plug.name, "\n", plug.description) self.plugins[p] = plug return len(self.plugins)