Ejemplo n.º 1
0
def add_plugin(plugin_name):
    if plugin_name in utilities.config["plugins"]:
        return "This plugin is already active"
    if not exists(join(utilities.WD, "plugins", plugin_name + ".py")):
        return "There is no file that name is " + plugin_name + " in plugins directory"
    try:
        utilities.load_plugin(plugin_name)
        utilities.config["plugins"].append(plugin_name)
        utilities.save_config()
        utilities.load_plugins()
        return ("Plugin " + plugin_name + " Enable Successfully\n" +
                stringify(utilities.load_plugin(plugin_name)))
    except Exception as e:
        print(str(e))
        return ("There is error while install " + plugin_name +
                " check developers for more info.")
Ejemplo n.º 2
0
def getallUsage(name=None):
    response_text = ""

    plugin_files = [name]
    if name == None:
        plugin_files = [
            files for files in os.listdir(join(utilities.WD, "plugins"))
            if re.search("^(.*)\.py$", files)
        ]
    for plugin_file in plugin_files:
        plugin_file = plugin_file.replace(".py", "")
        if plugin_file == "__init__":
            continue
        if plugin_file in utilities.config["plugins"]:
            plugin = utilities.load_plugin(plugin_file)
            if "usage" in plugin:
                response_text += ("ℹ️ " + plugin["name"] + "'s usage :\n\n" +
                                  "".join(((i + "\n"))
                                          for i in plugin["usage"]) + "\n" +
                                  ("" if name == None else "Description : " +
                                   plugin["desc"]))
            else:

                response_text += ("ℹ️ " + plugin["name"] +
                                  "'s patterns :\n\n" + "".join(
                                      (i + "\n")
                                      for i in plugin["patterns"]) + "\n")
    return response_text if (response_text != "") else "no such a plugin"
Ejemplo n.º 3
0
def add_plugin(plugin_name):
    if plugin_name in utilities.config["plugins"]:
        return "This plugin is already active"
    if not exists(join(utilities.WD, "plugins", plugin_name + ".py")):
        return "There is no file that name is " + plugin_name + " in plugins directory"
    utilities.config["plugins"].append(plugin_name)
    utilities.save_config()
    utilities.load_plugins()
    return ("Plugin " + plugin_name + " Enable Successfully\n" +
            stringify(utilities.load_plugin(plugin_name)))
Ejemplo n.º 4
0
def getallUsage(id,name=None):
    response_text = ""

    plugin_files = [name]
    if name == None:
        plugin_files = [
            files
            for files in os.listdir(join(utilities.WD, "plugins"))
            if re.search("^(.*)\.py$", files)
        ]
        plugin_files.sort()
    msgs = []
    for plugin_file in plugin_files:
        plugin_file = plugin_file.replace(".py", "")
        if plugin_file == "__init__" :
            continue
        if plugin_file in utilities.config["plugins"]:
            plugin = utilities.load_plugin(plugin_file)
            if ( not utilities.check_sudo(id) and plugin["sudo"]):
                continue
            if "usage" in plugin:
                response_text += (
                    "ℹ️ "
                    + plugin["name"]
                    + "'s usage :\n"
                    + "".join(((i + "\n")) for i in plugin["usage"])
                    + "\n"
                    + ("" if name == None else "Description : " + plugin["desc"])
                )
            else:
                response_text += (
                    "ℹ️ "
                    + plugin["name"]
                    + "'s patterns :\n"
                    + "".join((i + "\n") for i in plugin["patterns"])
                    + "\n"
                )
            if len(response_text) > 3500:
                msgs.append(response_text)
                response_text = ""
        else:
            if name != None:
                msgs.append("no such a plugin")
                return msgs
    if len(response_text) > 0:
        msgs.append(response_text)
    return msgs