@manybot/manybot 4.1.1 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/package.json +1 -1
- package/src/kernel/pluginLoader.js +21 -1
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
**Just a cool open source WhatsApp bot**
|
|
6
|
-
|
|
7
5
|

|
|
8
6
|

|
|
9
7
|

|
|
@@ -14,7 +12,7 @@
|
|
|
14
12
|
|
|
15
13
|
---
|
|
16
14
|
|
|
17
|
-
ManyBot is
|
|
15
|
+
ManyBot is free and open-source a messaging automation ecosystem for online businesses and communities.
|
|
18
16
|
|
|
19
17
|
## Requirements
|
|
20
18
|
|
package/package.json
CHANGED
|
@@ -74,12 +74,32 @@ export async function setupPlugins(api) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
async function findPluginPath(name) {
|
|
78
|
+
// key direto: synt-xerror/figurinha
|
|
79
|
+
const direct = path.join(PLUGINS_DIR, name, "index.js");
|
|
80
|
+
if (fs.existsSync(direct)) return direct;
|
|
81
|
+
|
|
82
|
+
// nome simples em subdir: plugins/synt-xerror/figurinha
|
|
83
|
+
if (!fs.existsSync(PLUGINS_DIR)) return null;
|
|
84
|
+
for (const entry of fs.readdirSync(PLUGINS_DIR, { withFileTypes: true })) {
|
|
85
|
+
if (!entry.isDirectory()) continue;
|
|
86
|
+
const nested = path.join(PLUGINS_DIR, entry.name, name, "index.js");
|
|
87
|
+
if (fs.existsSync(nested)) return nested;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
77
92
|
/**
|
|
78
93
|
* Carrega um único plugin pelo nome.
|
|
79
94
|
* @param {string} name
|
|
80
95
|
*/
|
|
81
96
|
async function loadPlugin(name) {
|
|
82
|
-
const pluginPath =
|
|
97
|
+
const pluginPath = await findPluginPath(name);
|
|
98
|
+
if (!pluginPath) {
|
|
99
|
+
logger.warn(t("system.pluginNotFound", { name, path: path.join(PLUGINS_DIR, name) }));
|
|
100
|
+
pluginRegistry.set(name, { name, status: "disabled", run: null, exports: null, error: null });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
83
103
|
|
|
84
104
|
if (!fs.existsSync(pluginPath)) {
|
|
85
105
|
logger.warn(t("system.pluginNotFound", { name, path: pluginPath }));
|