at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
код:
const https = require('https');
const Slimbot = require('slimbot');
const slimbot = new Slimbot('hidden');
// Register listeners
slimbot.on('message', message => {
if (message.text.startsWith("/start")) {
slimbot.sendMessage(message.chat.id, "Hello! This bot helps with finding pictures on gelbooru, try \"gelbooru [tags]\"");
}
if (message.text.startsWith("/help")) {
slimbot.sendMessage(message.chat.id, "To search pictures on gelbooru.com enter \"gelbooru [tags]\"");
};
if (message.text.startsWith("/gelbooru")) {
try {
var tags = message.text.match("/gelbooru (.*)")[1].replace(" ", "%20");
}
catch {
var tags = "";
}
https.get(`https://api.rule34.xxx/index.php?page=dapi&s=post&q=index&tags=${tags}&json=1`, (response) => {
let posts = "";
// called when a data chunk is received.
response.on("data", (chunk) => {
posts += chunk;
});
// called when the complete response is received.
response.on("end", () => {
for (post in JSON.parse(posts)) {
try {
if (post.file_url.includes("animation") || post.file_url.includes("animated") || post.file_url.includes("video") || post.file_url.includes("webm")) {
slimbot.sendVideo(message.chat.id, post.file_url, post.tags);
}
else {
slimbot.sendPhoto(message.chat.id, post.file_url, post.tags);
}
}
catch {
slimbot.sendMessage(message.chat.id, post.file_url);
}
finally {
sleep(delayTime in milliseconds).then(() => {});
}
}
});
}).on("error", (error) => {
console.log("Error: " + error.message);
});
};
});
});
// Call API
slimbot.startPolling();
хорошо еще что выдаёт ошибку,а то что при старте вообще замечательно
Обсуждают сегодня