@manybot/manybot 4.0.1 → 4.0.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/package.json +1 -1
- package/src/config.js +50 -22
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* config.js
|
|
3
3
|
*
|
|
4
|
+
<<<<<<< HEAD
|
|
5
|
+
* Reads and parses manybot.conf and manyplug.conf.
|
|
6
|
+
* Supports multiline lists and inline comments.
|
|
7
|
+
=======
|
|
4
8
|
* Loads:
|
|
5
9
|
* ~/.manybot/manybot.conf
|
|
6
10
|
* ~/.manybot/manyplug.conf
|
|
7
11
|
*
|
|
8
12
|
* Merges both files into a single configuration object.
|
|
13
|
+
>>>>>>> dev
|
|
9
14
|
*/
|
|
10
15
|
|
|
11
16
|
import fs from "fs/promises";
|
|
@@ -139,6 +144,10 @@ async function readFileSafe(file) {
|
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
|
|
147
|
+
<<<<<<< HEAD
|
|
148
|
+
const filePath = path.join(__dirname, "../manybot.conf");
|
|
149
|
+
const plugFilePath = path.join(__dirname, "../manyplug.conf");
|
|
150
|
+
=======
|
|
142
151
|
const defaultConfig =
|
|
143
152
|
`
|
|
144
153
|
# Many bot configuration file
|
|
@@ -150,6 +159,7 @@ CHATS=[]
|
|
|
150
159
|
LANGUAGE=en
|
|
151
160
|
PHONE_NUMBER=
|
|
152
161
|
`;
|
|
162
|
+
>>>>>>> dev
|
|
153
163
|
|
|
154
164
|
try {
|
|
155
165
|
await fs.stat(CONFIG_FILE);
|
|
@@ -160,31 +170,49 @@ try {
|
|
|
160
170
|
await fs.writeFile(CONFIG_FILE, defaultConfig);
|
|
161
171
|
}
|
|
162
172
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
export const CHATS =
|
|
178
|
-
CONFIG.CHATS ?? [];
|
|
173
|
+
<<<<<<< HEAD
|
|
174
|
+
let plugRaw;
|
|
175
|
+
try {
|
|
176
|
+
plugRaw = fs.readFileSync(plugFilePath, "utf8");
|
|
177
|
+
} catch (err) {
|
|
178
|
+
if (err.code === "ENOENT") {
|
|
179
|
+
console.warn("Plugin file not found: manyplug.conf")
|
|
180
|
+
console.log("You probably don't have executed manyplug to install some plugins yet")
|
|
181
|
+
} else {
|
|
182
|
+
console.warn("Error when reading manyplug.conf: ", err.message);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const bringTogheter = plugRaw !== undefined;
|
|
179
186
|
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
let completeRaw;
|
|
188
|
+
if (bringTogheter) {
|
|
189
|
+
completeRaw = raw + "\n" + plugRaw;
|
|
190
|
+
} else {
|
|
191
|
+
completeRaw = raw;
|
|
192
|
+
}
|
|
182
193
|
|
|
183
|
-
|
|
184
|
-
|
|
194
|
+
const config = parseConf(completeRaw);
|
|
195
|
+
=======
|
|
196
|
+
const baseConfig = await readFileSafe(CONFIG_FILE);
|
|
197
|
+
const pluginConfig = await readFileSafe(PLUGIN_FILE);
|
|
198
|
+
>>>>>>> dev
|
|
199
|
+
|
|
200
|
+
export const CONFIG = {
|
|
201
|
+
CMD_PREFIX: "!",
|
|
202
|
+
CLIENT_ID: "manybot",
|
|
203
|
+
CHATS: [],
|
|
204
|
+
PLUGINS: [],
|
|
205
|
+
LANGUAGE: "en",
|
|
206
|
+
PHONE_NUMBER: null,
|
|
207
|
+
...parseConf(baseConfig + "\n" + pluginConfig),
|
|
208
|
+
};
|
|
185
209
|
|
|
186
|
-
export const
|
|
187
|
-
|
|
210
|
+
export const CLIENT_ID = CONFIG.CLIENT_ID;
|
|
211
|
+
export const CMD_PREFIX = CONFIG.CMD_PREFIX;
|
|
212
|
+
export const CHATS = CONFIG.CHATS;
|
|
213
|
+
export const PLUGINS = CONFIG.PLUGINS;
|
|
214
|
+
export const LANGUAGE = CONFIG.LANGUAGE;
|
|
215
|
+
export const PHONE_NUMBER = CONFIG.PHONE_NUMBER;
|
|
188
216
|
|
|
189
217
|
/**
|
|
190
218
|
* Useful paths for plugins/modules.
|