Ejemplo n.º 1
0
 def apropos(self, search):
     """ search existing commands for search term. """
     result = []
     from boot import getcmndtable
     for name, plugname in getcmndtable().iteritems():
         if search in name: result.append(name)
     return result
Ejemplo n.º 2
0
 def apropos(self, search):
     """ search existing commands for search term. """
     result = []
     from boot import getcmndtable
     for name, plugname in getcmndtable().iteritems():
         if search in name: result.append(name)
     return result
Ejemplo n.º 3
0
    def reloadcheck(self, bot, event, target=None):
        """
            check if event requires a plugin to be reloaded. if so 
            reload the plugin.

        """
        logging.debug("plugins - checking for reload of %s (%s)" %
                      (event.usercmnd, event.userhost))
        plugloaded = None
        try:
            from boot import getcmndtable
            plugin = getcmndtable()[event.usercmnd.lower()]
        except KeyError:
            logging.debug("plugins - can't find plugin to reload for %s" %
                          event.usercmnd)
            return
        if plugin in self:
            logging.debug("plugins - %s already loaded" % plugin)
            return plugloaded
        if plugin in default_plugins: pass
        elif bot.cfg.blacklist and plugin in bot.cfg.blacklist:
            return plugloaded
        elif bot.cfg.loadlist and plugin not in bot.cfg.loadlist:
            return plugloaded
        logging.info("plugins - loaded %s on demand (%s)" %
                     (plugin, event.usercmnd))
        plugloaded = self.reload(plugin)
        return plugloaded
Ejemplo n.º 4
0
 def whereis(self, cmnd):
     """ return plugin name in which command is implemented. """
     logging.warn("looking for %s" % cmnd)
     try:
         cmndlist = getshorttable()[cmnd]
         if len(cmndlist) == 1: cmnd = cmndlist[0]
     except KeyError: pass
     try: return getcmndtable()[cmnd]
     except KeyError: return ""
Ejemplo n.º 5
0
    def reloadcheck(self, bot, event, target=None):
        """
            check if event requires a plugin to be reloaded. if so 
            reload the plugin.  

        """
        from boot import getcmndtable
        from boot import plugblacklist
        plugloaded = None
        plugin = None
        target = target or event.usercmnd.lower()
        from jsb.lib.aliases import getaliases
        aliases = getaliases()
        try: target = aliases[target]
        except KeyError:
            try: target = event.chan.data.aliases[target]
            except (AttributeError, KeyError, TypeError): pass
            if not getcmndtable().has_key(target):
                try:
                    from boot import shorttable
                    if shorttable.data.has_key(target):
                        cmndlist = shorttable.data[target]
                        if len(cmndlist) == 1: target = cmndlist[0]
                except Exception, ex: handle_exception()
        if target: target = target.split()[0]
        logging.debug("checking for reload of %s" % target)
        try:
            plugin = getcmndtable()[target]
        except KeyError:
            try:
                from boot import retable
                for regex, mod in retable.data.iteritems():
                    if re.search(regex, event.stripcc() or event.txt): plugin = mod ; break
            except Exception, ex: handle_exception()
        logging.info("plugin is %s" % plugin)
        if not plugin: logging.debug("can't find plugin to reload for %s" % target) ; return
        if plugin in bot.plugs: logging.info(" %s already loaded" % plugin) ; return plugloaded
        elif plugin in plugblacklist.data: return plugloaded
        elif bot.cfg.loadlist and plugin not in bot.cfg.loadlist: logging.warn("plugin %s is blacklisted" % plugin) ; return plugloaded
        logging.info("loaded %s on demand" % plugin)
        plugloaded = bot.plugs.reload(plugin)
        return plugloaded
Ejemplo n.º 6
0
 def whereis(self, cmnd):
     """ return plugin name in which command is implemented. """
     logging.warn("looking for %s" % cmnd)
     try:
         cmndlist = getshorttable()[cmnd]
         if len(cmndlist) == 1: cmnd = cmndlist[0]
     except KeyError:
         pass
     try:
         return getcmndtable()[cmnd]
     except KeyError:
         return ""
Ejemplo n.º 7
0
    def reloadcheck(self, bot, event, target=None):
        """
            check if event requires a plugin to be reloaded. if so 
            reload the plugin.

        """
        logging.debug("plugins - checking for reload of %s (%s)" % (event.usercmnd, event.userhost))
        plugloaded = None
        try:
            from boot import getcmndtable
            plugin = getcmndtable()[event.usercmnd.lower()]
        except KeyError:
            logging.debug("plugins - can't find plugin to reload for %s" % event.usercmnd)
            return
        if plugin in self: logging.debug("plugins - %s already loaded" % plugin) ; return plugloaded
        if  plugin in default_plugins: pass
        elif bot.cfg.blacklist and plugin in bot.cfg.blacklist: return plugloaded
        elif bot.cfg.loadlist and plugin not in bot.cfg.loadlist: return plugloaded
        logging.info("plugins - loaded %s on demand (%s)" % (plugin, event.usercmnd))
        plugloaded = self.reload(plugin)
        return plugloaded
Ejemplo n.º 8
0
         if not target: target = evemt.txt.split()[0]
 except Exception, ex:
     target = None
 if not target:
     logging.debug("can't find target in %s" % event.txt)
     return
 from jsb.lib.aliases import getaliases
 aliases = getaliases()
 try:
     target = aliases[target]
 except KeyError:
     try:
         target = event.chan.data.aliases[target]
     except (AttributeError, KeyError, TypeError):
         pass
 cmndtable = getcmndtable()
 if not cmndtable.has_key(target):
     try:
         short = getshorttable()
         if short.has_key(target):
             cmndlist = short[target]
             if len(cmndlist) == 1: target = cmndlist[0]
     except Exception, ex:
         handle_exception()
 if target: target = target.split()[0]
 logging.info("checking for reload of %s" % target)
 try:
     plugin = cmndtable[target]
 except KeyError:
     logging.warn("no cmnd for %s .. trying REGEX" % target)
     try:
Ejemplo n.º 9
0
 def whereis(self, cmnd):
     """ return plugin name in which command is implemented. """
     from boot import getcmndtable
     try: return getcmndtable()[cmnd]
     except KeyError: return ""