Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -1,28 +1,50 @@
|
|
| 1 |
const TelegramBot = require('node-telegram-bot-api');
|
| 2 |
const schedule = require("node-schedule");
|
| 3 |
const fs = require('fs');
|
|
|
|
| 4 |
|
| 5 |
-
//
|
| 6 |
-
const token =
|
| 7 |
-
const chatID = "@bot_de_sinais";
|
| 8 |
const LINK_AFILIADO = "https://bv789y.com/?a=ce235kbt";
|
| 9 |
-
const BOT_USER = "Hhhhhdhdh_bot";
|
| 10 |
|
| 11 |
const bot = new TelegramBot(token, { polling: true });
|
| 12 |
const jogos = ["Fortune Tiger 🐯", "Fortune Rabbit 🐰", "Fortune Ox 🐂", "Fortune Mouse 🐭"];
|
| 13 |
|
| 14 |
-
//
|
| 15 |
-
let db = {};
|
| 16 |
-
if (fs.existsSync('
|
| 17 |
-
db = JSON.parse(fs.readFileSync('
|
| 18 |
}
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
function getHora(min) {
|
| 22 |
-
return new Date(Date.now() + min * 60000).toLocaleTimeString("pt-BR", {
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
async function enviarSinal() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
const delay = Math.floor(Math.random() * 30000);
|
| 27 |
|
| 28 |
setTimeout(async () => {
|
|
@@ -41,7 +63,7 @@ async function enviarSinal() {
|
|
| 41 |
reply_markup: {
|
| 42 |
inline_keyboard: [
|
| 43 |
[{ text: "🔗 JOGAR AGORA", url: LINK_AFILIADO }],
|
| 44 |
-
[{ text: "🚀 COMPARTILHAR COM AMIGOS", url: `https://t.me/share/url?url=https://t.me/${BOT_USER}?start=convite&text=Olha
|
| 45 |
]
|
| 46 |
}
|
| 47 |
};
|
|
@@ -53,35 +75,46 @@ async function enviarSinal() {
|
|
| 53 |
}, delay);
|
| 54 |
}
|
| 55 |
|
| 56 |
-
//
|
| 57 |
-
bot.
|
|
|
|
|
|
|
|
|
|
| 58 |
const uid = msg.from.id.toString();
|
| 59 |
-
const ref = match[1];
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
}
|
|
|
|
| 70 |
}
|
| 71 |
-
|
|
|
|
|
|
|
| 72 |
}
|
| 73 |
-
bot.sendMessage(msg.chat.id, `Olá! Entre no canal: @bot_de_sinais`);
|
| 74 |
-
});
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
| 80 |
});
|
| 81 |
|
|
|
|
| 82 |
enviarSinal();
|
| 83 |
schedule.scheduleJob("*/5 * * * *", enviarSinal);
|
| 84 |
|
| 85 |
-
//
|
| 86 |
-
|
| 87 |
-
|
|
|
|
| 1 |
const TelegramBot = require('node-telegram-bot-api');
|
| 2 |
const schedule = require("node-schedule");
|
| 3 |
const fs = require('fs');
|
| 4 |
+
const http = require('http');
|
| 5 |
|
| 6 |
+
// NOVO TOKEN E CONFIGURAÇÕES
|
| 7 |
+
const token = "8151185457:AAEfnxKvdLI_ltEqD_-aEKjVpSnvxF1EX40";
|
|
|
|
| 8 |
const LINK_AFILIADO = "https://bv789y.com/?a=ce235kbt";
|
| 9 |
+
const BOT_USER = "Hhhhhdhdh_bot"; // Lembre-se de mudar se o @ do bot for outro
|
| 10 |
|
| 11 |
const bot = new TelegramBot(token, { polling: true });
|
| 12 |
const jogos = ["Fortune Tiger 🐯", "Fortune Rabbit 🐰", "Fortune Ox 🐂", "Fortune Mouse 🐭"];
|
| 13 |
|
| 14 |
+
// Sistema de Banco de Dados Inteligente
|
| 15 |
+
let db = { config: { canalID: null }, usuarios: {} };
|
| 16 |
+
if (fs.existsSync('db_sinais.json')) {
|
| 17 |
+
try { db = JSON.parse(fs.readFileSync('db_sinais.json', 'utf8')); } catch(e){}
|
| 18 |
}
|
| 19 |
+
if (!db.config) db.config = { canalID: null };
|
| 20 |
+
if (!db.usuarios) db.usuarios = {};
|
| 21 |
+
|
| 22 |
+
function salvar() { fs.writeFileSync('db_sinais.json', JSON.stringify(db, null, 2)); }
|
| 23 |
|
| 24 |
function getHora(min) {
|
| 25 |
+
return new Date(Date.now() + min * 60000).toLocaleTimeString("pt-BR", {
|
| 26 |
+
hour: "2-digit", minute: "2-digit", timeZone: "America/Sao_Paulo"
|
| 27 |
+
});
|
| 28 |
}
|
| 29 |
|
| 30 |
+
// 1. LER O /start DENTRO DO CANAL
|
| 31 |
+
bot.on('channel_post', (msg) => {
|
| 32 |
+
if (msg.text && msg.text.toLowerCase() === '/start') {
|
| 33 |
+
db.config.canalID = msg.chat.id;
|
| 34 |
+
salvar();
|
| 35 |
+
bot.sendMessage(msg.chat.id, "✅ **Canal vinculado com sucesso!** O radar agora enviará os sinais exclusivamente aqui.", { parse_mode: "Markdown" });
|
| 36 |
+
console.log(`Novo canal configurado: ${msg.chat.id}`);
|
| 37 |
+
}
|
| 38 |
+
});
|
| 39 |
+
|
| 40 |
+
// 2. ENVIAR SINAIS (Só envia se o canal estiver salvo)
|
| 41 |
async function enviarSinal() {
|
| 42 |
+
if (!db.config.canalID) {
|
| 43 |
+
console.log("[Aviso] Nenhum canal configurado. Vá no canal e digite /start");
|
| 44 |
+
return;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
const chatID = db.config.canalID;
|
| 48 |
const delay = Math.floor(Math.random() * 30000);
|
| 49 |
|
| 50 |
setTimeout(async () => {
|
|
|
|
| 63 |
reply_markup: {
|
| 64 |
inline_keyboard: [
|
| 65 |
[{ text: "🔗 JOGAR AGORA", url: LINK_AFILIADO }],
|
| 66 |
+
[{ text: "🚀 COMPARTILHAR COM AMIGOS", url: `https://t.me/share/url?url=https://t.me/${BOT_USER}?start=convite&text=Olha o radar de sinais do Erinaldo!` }]
|
| 67 |
]
|
| 68 |
}
|
| 69 |
};
|
|
|
|
| 75 |
}, delay);
|
| 76 |
}
|
| 77 |
|
| 78 |
+
// 3. COMANDOS NO PRIVADO (Indicação e Boas-vindas)
|
| 79 |
+
bot.on('message', (msg) => {
|
| 80 |
+
if (!msg.text || msg.chat.type !== 'private') return;
|
| 81 |
+
|
| 82 |
+
const texto = msg.text;
|
| 83 |
const uid = msg.from.id.toString();
|
|
|
|
| 84 |
|
| 85 |
+
// Comando /start no Privado
|
| 86 |
+
if (texto.startsWith('/start')) {
|
| 87 |
+
const args = texto.split(' ');
|
| 88 |
+
const ref = args[1];
|
| 89 |
+
|
| 90 |
+
if (!db.usuarios[uid]) {
|
| 91 |
+
db.usuarios[uid] = { pontos: 0, indicados: [] };
|
| 92 |
+
if (ref && db.usuarios[ref] && ref !== uid) {
|
| 93 |
+
db.usuarios[ref].pontos += 1;
|
| 94 |
+
db.usuarios[ref].indicados.push(uid);
|
| 95 |
+
bot.sendMessage(ref, `🔥 **Nova indicação!** Você tem ${db.usuarios[ref].pontos}/3 pontos.`);
|
| 96 |
+
if (db.usuarios[ref].pontos === 3) {
|
| 97 |
+
bot.sendMessage(ref, `🏆 **ESTRATÉGIA VIP LIBERADA:**\n\nJogue 10 rodadas turbo nos minutos finais 9 e 0!`);
|
| 98 |
+
}
|
| 99 |
}
|
| 100 |
+
salvar();
|
| 101 |
}
|
| 102 |
+
bot.sendMessage(msg.chat.id, `👋 Olá, ${msg.from.first_name}! Os sinais estão rolando no canal oficial.\n\n👇 Use o menu abaixo:`, {
|
| 103 |
+
reply_markup: { inline_keyboard: [[{ text: "🎁 CADASTRAR NA PLATAFORMA", url: LINK_AFILIADO }]] }
|
| 104 |
+
});
|
| 105 |
}
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
// Comando /indicar
|
| 108 |
+
if (texto === '/indicar') {
|
| 109 |
+
const link = `https://t.me/${BOT_USER}?start=${uid}`;
|
| 110 |
+
bot.sendMessage(msg.chat.id, `🚀 **INDIQUE E GANHE**\n\nConvide 3 amigos e ganhe a Estratégia VIP!\n\nLink de indicação: ${link}\nPontos: ${db.usuarios[uid]?.pontos || 0}/3`);
|
| 111 |
+
}
|
| 112 |
});
|
| 113 |
|
| 114 |
+
// Inicia os envios
|
| 115 |
enviarSinal();
|
| 116 |
schedule.scheduleJob("*/5 * * * *", enviarSinal);
|
| 117 |
|
| 118 |
+
// Servidor obrigatório para o Hugging Face
|
| 119 |
+
http.createServer((req, res) => { res.write('Bot Erinaldo 3.0 Online!'); res.end(); }).listen(7860);
|
| 120 |
+
console.log("🚀 BOT REINICIADO - Aguardando /start no canal...");
|