28 lines
834 B
JavaScript
28 lines
834 B
JavaScript
const TelegramBot = require('node-telegram-bot-api');
|
|
const axios = require('axios');
|
|
const cheerio = require('cheerio');
|
|
|
|
// replace the value below with the Telegram token you receive from @BotFather
|
|
let token = require("./pass.js").token;
|
|
|
|
// Create a bot that uses 'polling' to fetch new updates
|
|
const bot = new TelegramBot(token, {polling: true});
|
|
|
|
bot.onText(/\/saleGoJapon/, async (msg, match) => {
|
|
|
|
let ban = false;
|
|
const chatId = msg.chat.id;
|
|
let response = await axios.get('https://www.mofa.go.jp/ca/fna/page4e_001053.html');
|
|
|
|
const $ = await cheerio.load(response.data);
|
|
|
|
ban = $('#section1').text().toUpperCase().includes("CHILE");
|
|
|
|
if(ban) {
|
|
bot.sendMessage(chatId, "Todavía baneados prro");
|
|
} else {
|
|
bot.sendMessage(chatId, "/goJapon");
|
|
}
|
|
});
|
|
|
|
bot.on("polling_error", (err) => console.log(err)); |