This commit is contained in:
Joaquín Torres 2020-09-22 21:43:08 -03:00
parent c37191e3ed
commit 8a3d6d5000
9 changed files with 87 additions and 0 deletions

3
.gitignore vendored
View File

@ -107,3 +107,6 @@ dist
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
package-lock.json
pass.js

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

12
.idea/GoJapanBanBot.iml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/jsLibraryMappings.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

6
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/GoJapanBanBot.iml" filepath="$PROJECT_DIR$/.idea/GoJapanBanBot.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

28
goJapanBanBot.js Normal file
View File

@ -0,0 +1,28 @@
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));

10
package.json Normal file
View File

@ -0,0 +1,10 @@
{
"version": "5.4.0",
"private": true,
"dependencies": {
"axios": "^0.20.0",
"cheerio": "^1.0.0-rc.3",
"node-telegram-bot-api": "^0.30.0"
},
"devDependencies": {}
}