Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12a9cf122f | ||
|
|
48e851fd05 | ||
|
|
ae256da596 | ||
|
|
92e2ea2337 | ||
|
|
438e674eff | ||
|
|
5b74cf2dc5 | ||
|
|
4f5d937265 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ cookies.txt
|
|||||||
bin/
|
bin/
|
||||||
mychats.txt
|
mychats.txt
|
||||||
manybot.conf
|
manybot.conf
|
||||||
|
update.log
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "whatsapp-bot",
|
"name": "whatsapp-bot",
|
||||||
"version": "2.3.2",
|
"version": "2.3.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "whatsapp-bot",
|
"name": "whatsapp-bot",
|
||||||
"version": "2.3.2",
|
"version": "2.3.5",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-addon-api": "^7",
|
"node-addon-api": "^7",
|
||||||
"node-gyp": "^12.2.0",
|
"node-gyp": "^12.2.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "manybot",
|
"name": "manybot",
|
||||||
"version": "2.3.2",
|
"version": "2.3.5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-addon-api": "^7",
|
"node-addon-api": "^7",
|
||||||
|
|||||||
@@ -16,7 +16,15 @@ logger.info(isTermux
|
|||||||
// ── Instância ─────────────────────────────────────────────────
|
// ── Instância ─────────────────────────────────────────────────
|
||||||
export const client = new Client({
|
export const client = new Client({
|
||||||
authStrategy: new LocalAuth({ clientId: CLIENT_ID }),
|
authStrategy: new LocalAuth({ clientId: CLIENT_ID }),
|
||||||
puppeteer: { headless: true, ...resolvePuppeteerConfig() },
|
puppeteer: {
|
||||||
|
headless: true,
|
||||||
|
args: [
|
||||||
|
'--no-sandbox',
|
||||||
|
'--disable-setuid-sandbox',
|
||||||
|
...(resolvePuppeteerConfig().args || [])
|
||||||
|
],
|
||||||
|
...resolvePuppeteerConfig()
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── Eventos ───────────────────────────────────────────────────
|
// ── Eventos ───────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const DOWNLOADS_DIR = path.resolve("downloads");
|
|||||||
const FFMPEG = os.platform() === "win32" ? ".\\bin\\ffmpeg.exe" : "./bin/ffmpeg";
|
const FFMPEG = os.platform() === "win32" ? ".\\bin\\ffmpeg.exe" : "./bin/ffmpeg";
|
||||||
const MAX_STICKER_SIZE = 900 * 1024;
|
const MAX_STICKER_SIZE = 900 * 1024;
|
||||||
const SESSION_TIMEOUT = 2 * 60 * 1000;
|
const SESSION_TIMEOUT = 2 * 60 * 1000;
|
||||||
const MAX_MEDIA = 10;
|
const MAX_MEDIA = 30;
|
||||||
|
|
||||||
// ── Helpers ───────────────────────────────────────────────────
|
// ── Helpers ───────────────────────────────────────────────────
|
||||||
function ensureDownloadsDir() {
|
function ensureDownloadsDir() {
|
||||||
|
|||||||
@@ -1,32 +1,62 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
function parseValue(v) {
|
function parseConf(raw) {
|
||||||
v = v.trim();
|
// Remove comentários inline e de linha inteira, preservando estrutura
|
||||||
|
const lines = raw.split("\n");
|
||||||
|
|
||||||
// lista: [a, b, c]
|
const cleaned = [];
|
||||||
if (v.startsWith("[") && v.endsWith("]")) {
|
let insideList = false;
|
||||||
return v
|
let buffer = "";
|
||||||
|
|
||||||
|
for (let line of lines) {
|
||||||
|
// Remove comentário inline (# ...) — mas só fora de strings
|
||||||
|
line = line.replace(/#.*$/, "").trim();
|
||||||
|
if (!line) continue;
|
||||||
|
|
||||||
|
if (!insideList) {
|
||||||
|
if (line.includes("=[") && !line.includes("]")) {
|
||||||
|
// Início de lista multilinha
|
||||||
|
insideList = true;
|
||||||
|
buffer = line;
|
||||||
|
} else {
|
||||||
|
cleaned.push(line);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buffer += line;
|
||||||
|
if (line.includes("]")) {
|
||||||
|
// Fim da lista
|
||||||
|
insideList = false;
|
||||||
|
cleaned.push(buffer);
|
||||||
|
buffer = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parseia cada linha chave=valor
|
||||||
|
const result = {};
|
||||||
|
for (const line of cleaned) {
|
||||||
|
const eqIdx = line.indexOf("=");
|
||||||
|
if (eqIdx === -1) continue;
|
||||||
|
|
||||||
|
const key = line.slice(0, eqIdx).trim();
|
||||||
|
const raw = line.slice(eqIdx + 1).trim();
|
||||||
|
|
||||||
|
if (raw.startsWith("[") && raw.endsWith("]")) {
|
||||||
|
result[key] = raw
|
||||||
.slice(1, -1)
|
.slice(1, -1)
|
||||||
.split(",")
|
.split(",")
|
||||||
.map(x => x.trim())
|
.map(x => x.trim())
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
} else {
|
||||||
|
result[key] = raw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const raw = fs.readFileSync("manybot.conf", "utf8");
|
const raw = fs.readFileSync("manybot.conf", "utf8");
|
||||||
|
const config = parseConf(raw);
|
||||||
const config = Object.fromEntries(
|
|
||||||
raw
|
|
||||||
.split("\n")
|
|
||||||
.map(l => l.trim())
|
|
||||||
.filter(l => l && !l.startsWith("#"))
|
|
||||||
.map(l => {
|
|
||||||
const [k, ...v] = l.split("=");
|
|
||||||
return [k.trim(), parseValue(v.join("="))];
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
export const CLIENT_ID = config.CLIENT_ID ?? "bot_permanente";
|
export const CLIENT_ID = config.CLIENT_ID ?? "bot_permanente";
|
||||||
export const BOT_PREFIX = config.BOT_PREFIX ?? "🤖 *ManyBot:* ";
|
export const BOT_PREFIX = config.BOT_PREFIX ?? "🤖 *ManyBot:* ";
|
||||||
|
|||||||
Reference in New Issue
Block a user