예제 #1
0
 def blacklist(self, mess, args):
     """Blacklist a plugin so that it will not be loaded automatically during bot startup"""
     if args not in get_all_plugin_names():
         return ("{} isn't a valid plugin name. The current plugins are:\n"
                 "{}".format(args,
                             self.formatted_plugin_list(active_only=False)))
     return self.blacklist_plugin(args)
예제 #2
0
 def unblacklist(self, mess, args):
     """Remove a plugin from the blacklist"""
     if args not in get_all_plugin_names():
         return ("{} isn't a valid plugin name. The current plugins are:\n"
                 "{}".format(args,
                             self.formatted_plugin_list(active_only=False)))
     return self.unblacklist_plugin(args)
예제 #3
0
파일: errBot.py 프로젝트: glenbot/err
 def activate_plugin(self, name):
     if name in get_all_active_plugin_names():
         return "Plugin already in active list"
     if name not in get_all_plugin_names():
         return "I don't know this %s plugin" % name
     activate_plugin_with_version_check(name, self.get_plugin_configuration(name))
     return "Plugin %s activated" % name
예제 #4
0
파일: errBot.py 프로젝트: CiaranG/err
 def activate_plugin(self, name):
     try:
         if name in get_all_active_plugin_names():
             return "Plugin already in active list"
         if name not in get_all_plugin_names():
             return "I don't know this %s plugin" % name
         activate_plugin_with_version_check(name, self.get_plugin_configuration(name))
     except Exception, e:
         logging.exception("Error loading %s" % name)
         return "%s failed to start : %s\n" % (name, e)
예제 #5
0
파일: errBot.py 프로젝트: sanketsudake/err
 def activate_plugin(self, name):
     try:
         if name in get_all_active_plugin_names():
             return "Plugin already in active list"
         if name not in get_all_plugin_names():
             return "I don't know this %s plugin" % name
         activate_plugin_with_version_check(name, self.get_plugin_configuration(name))
     except Exception as e:
         logging.exception("Error loading %s" % name)
         return '%s failed to start : %s\n' % (name, e)
     return "Plugin %s activated" % name
예제 #6
0
    def formatted_plugin_list(active_only=True):
        """
        Return a formatted, plain-text list of loaded plugins.

        When active_only=True, this will only return plugins which
        are actually active. Otherwise, it will also include inactive
        (blacklisted) plugins.
        """
        if active_only:
            all_plugins = get_all_active_plugin_names()
        else:
            all_plugins = get_all_plugin_names()
        return "\n".join(("• " + plugin for plugin in all_plugins))
예제 #7
0
    def unload(self, mess, args):
        """unload a plugin"""
        args = args.strip()
        if not args:
            return ("Please tell me which of the following plugins to reload:\n"
                    "{}".format(self.formatted_plugin_list(active_only=False)))
        if args not in get_all_plugin_names():
            return ("{} isn't a valid plugin name. The current plugins are:\n"
                    "{}".format(args, self.formatted_plugin_list(active_only=False)))
        if args not in get_all_active_plugin_names():
            return "{} is not currently loaded".format(args)

        return self.deactivate_plugin(args)
예제 #8
0
    def formatted_plugin_list(active_only=True):
        """
        Return a formatted, plain-text list of loaded plugins.

        When active_only=True, this will only return plugins which
        are actually active. Otherwise, it will also include inactive
        (blacklisted) plugins.
        """
        if active_only:
            all_plugins = get_all_active_plugin_names()
        else:
            all_plugins = get_all_plugin_names()
        return "\n".join(("• " + plugin for plugin in all_plugins))
예제 #9
0
    def unload(self, mess, args):
        """unload a plugin"""
        args = args.strip()
        if not args:
            return ("Please tell me which of the following plugins to reload:\n"
                    "{}".format(self.formatted_plugin_list(active_only=False)))
        if args not in get_all_plugin_names():
            return ("{} isn't a valid plugin name. The current plugins are:\n"
                    "{}".format(args, self.formatted_plugin_list(active_only=False)))
        if args not in get_all_active_plugin_names():
            return "{} is not currently loaded".format(args)

        return self.deactivate_plugin(args)
예제 #10
0
    def reload(self, mess, args):
        """reload a plugin"""
        args = args.strip()
        if not args:
            yield ("Please tell me which of the following plugins to reload:\n"
                    "{}".format(self.formatted_plugin_list(active_only=False)))
            return
        if args not in get_all_plugin_names():
            yield ("{} isn't a valid plugin name. The current plugins are:\n"
                    "{}".format(args, self.formatted_plugin_list(active_only=False)))
            return

        yield self.deactivate_plugin(args)  # Not needed but keeps the feedback to user consistent
        reload_plugin_by_name(args)
        yield self.activate_plugin(args)
예제 #11
0
    def reload(self, mess, args):
        """reload a plugin"""
        args = args.strip()
        if not args:
            yield ("Please tell me which of the following plugins to reload:\n"
                    "{}".format(self.formatted_plugin_list(active_only=False)))
            return
        if args not in get_all_plugin_names():
            yield ("{} isn't a valid plugin name. The current plugins are:\n"
                    "{}".format(args, self.formatted_plugin_list(active_only=False)))
            return

        yield self.deactivate_plugin(args)  # Not needed but keeps the feedback to user consistent
        reload_plugin_by_name(args)
        yield self.activate_plugin(args)
예제 #12
0
 def unblacklist(self, mess, args):
     """Remove a plugin from the blacklist"""
     if args not in get_all_plugin_names():
         return ("{} isn't a valid plugin name. The current plugins are:\n"
                 "{}".format(args, self.formatted_plugin_list(active_only=False)))
     return self.unblacklist_plugin(args)
예제 #13
0
 def blacklist(self, mess, args):
     """Blacklist a plugin so that it will not be loaded automatically during bot startup"""
     if args not in get_all_plugin_names():
         return ("{} isn't a valid plugin name. The current plugins are:\n"
                 "{}".format(args, self.formatted_plugin_list(active_only=False)))
     return self.blacklist_plugin(args)