From 9286548bfd2070b914056f9b1c765c77d7d89603 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 25 Jun 2020 16:17:46 +0100 Subject: [PATCH 1/7] working initial competition logic --- app.js | 98 +++++++++++++++++++++++++++++++++++++++++------ package-lock.json | 97 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 184 insertions(+), 13 deletions(-) diff --git a/app.js b/app.js index 4dfa217..9802fee 100644 --- a/app.js +++ b/app.js @@ -2,16 +2,20 @@ require('dotenv').config(); var request = require("request"); var throttledRequest = require('throttled-request')(request); -throttledRequest.configure({requests: 8, milliseconds: 60000}); //send 1 request per second +throttledRequest.configure({ requests: 8, milliseconds: 60000 }); //send 1 request per second cachedRequest = require('cached-request')(throttledRequest); cachedRequest.setCacheDirectory("./cache"); +const fs = require('fs'); + const logger = require('perfect-logger'); const TelegramBot = require('node-telegram-bot-api'); const token = process.env.BOT_TOKEN; const name = process.env.BOT_NAME; const channel = process.env.CHANNEL +const admins = JSON.parse(process.env.ADMIN_ID) +let comp_users = [] // Configure Settings logger.initialize(name + "_bot", { @@ -156,9 +160,9 @@ bot.on('message', (msg) => { } const deal = "deal"; - const me = 434187971 - const sarah = 868225940 - const MANC = 470861863 + // const me = 434187971 + // const sarah = 868225940 + // const MANC = 470861863 if (msg.text && msg.text.toString().toLowerCase().match(/\bdeal\b/)) { logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said we got a deal!"); bot.sendMessage(msg.chat.id, "I LOVE it when " + msg.from.first_name + ", does a deal :)"); @@ -230,14 +234,12 @@ bot.on('message', (msg) => { const installoOnAndroid = "- install filelinked on android"; if (msg.text && msg.text.toString().toLowerCase() === installoOnAndroid) { logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Found out how to install on Android"); - bot.sendMessage(msg.chat.id, "First thing you need to do is go to browser on your Android TV box and enter www.filelinked.com") + bot.sendMessage(msg.chat.id, "First thing you need to do is go to browser on your Android TV box and enter http://get.filelinked.com") .then(() => { - return bot.sendMessage(msg.chat.id, "From this browser page, download FileLinked.").then(() => { - return bot.sendMessage(msg.chat.id, "Once you have pressed download then you can close the browser and go to your apps.").then(() => { - return bot.sendMessage(msg.chat.id, "Then open file manager or file browser. In here go to downloads, filemanager, press install.").then(() => { - return bot.sendMessage(msg.chat.id, "Then go back to your apps section on the box and find filelinked app.").then(() => { - return bot.sendMessage(msg.chat.id, "Open the app and enter the code.") - }) + return bot.sendMessage(msg.chat.id, "Once the apk has downloaded you can close the browser and go to your apps.").then(() => { + return bot.sendMessage(msg.chat.id, "Then open file manager or file browser. In here go to downloads, filemanager, press install.").then(() => { + return bot.sendMessage(msg.chat.id, "Then go back to your apps section on the box and find filelinked app.").then(() => { + return bot.sendMessage(msg.chat.id, "Open the app and enter the code.") }) }) }) @@ -308,7 +310,79 @@ bot.on('message', (msg) => { const howToResetCache = "- how do i clear cache?"; if (msg.text && msg.text.toString().toLowerCase() === howToResetCache) { logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to clear cache"); - bot.sendMessage(msg.chat.id, "Cache files are main source of errors and problems in functioning of Apps, by clearing cache may solve most of the problems associated with Apps. To clear cache, go to Settings > Application > Manage apps > Select \"All\" tabs, select the app which was producing error and then tap Clear cache."); + bot.sendMessage(msg.chat.id, process.env.ADMIN_ID); + } + + const whoAdmin = "who is an admin"; + if (msg.text && msg.text.toString().toLowerCase() === whoAdmin) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin"); + admins.forEach(element => + bot.sendMessage(msg.chat.id, element) + ); + } + + const startCompCalled = "start comp called"; + if (msg.text && msg.text.toString().toLowerCase().includes(startCompCalled)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin"); + test = msg.text.match(/\b(\w+)$/gm); + fs.writeFileSync('./data/' + test + '.json', '[]') + bot.sendMessage(msg.chat.id, 'Comp created') + } + + const stopCompCalled = "stop comp called"; + if (msg.text && msg.text.toString().toLowerCase().includes(stopCompCalled)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin"); + test = msg.text.match(/\b(\w+)$/gm); + fs.unlinkSync('./data/' + test + '.json', '[]') + bot.sendMessage(msg.chat.id, 'Comp removed') + } + + const comp = "entered the comp"; + if (msg.text && msg.text.toString().toLowerCase().includes(comp)) { + if (admins.indexOf(msg.from.id) > -1) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin"); + user = msg.text.match(/^([\w\-]+)/gm)[0]; + let comp_name = msg.text.match(/\b(\w+)$/gm)[0]; + + comp_users = JSON.parse(fs.readFileSync('./data/' + comp_name + '.json', 'utf8')) + + let new_comp_users = comp_users.concat(user) + + fs.writeFileSync('./data/' + comp_name + '.json', JSON.stringify(new_comp_users)) + + bot.sendMessage(msg.chat.id, user + " has been added to the competition") + } else { + console.log('not found') + } + } + + const enteredTheComp = "how many in comp"; + if (msg.text && msg.text.toString().toLowerCase().includes(enteredTheComp)) { + if (admins.indexOf(msg.from.id) > -1) { + let comp_name = msg.text.match(/\b(\w+)$/gm)[0]; + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin"); + var comp_entered = JSON.parse(fs.readFileSync('./data/' + comp_name + '.json', 'utf8')) + bot.sendMessage(msg.chat.id, "There are " + comp_entered.length + " people in the comp") + } else { + console.log('not found') + } + } + + const whoWon = "who won comp"; + if (msg.text && msg.text.toString().toLowerCase().includes(whoWon)) { + if (admins.indexOf(msg.from.id) > -1) { + let comp_name = msg.text.match(/\b(\w+)$/gm)[0]; + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked who is an admin"); + var comp_entered = JSON.parse(fs.readFileSync('./data/' + comp_name + '.json', 'utf8')) + + var winner = comp_entered[Math.floor(Math.random() * comp_entered.length)]; + + bot.sendMessage(msg.chat.id, "There winner is .....").then(() => { + return bot.sendMessage(msg.chat.id, winner) + }) + } else { + console.log('not found') + } } const whatAppShouldIUse = "- what app should i use?"; diff --git a/package-lock.json b/package-lock.json index 2d515e2..59bfa43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -103,6 +103,11 @@ "type-detect": "^1.0.0" } }, + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=" + }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -275,6 +280,11 @@ "mime-types": "^2.1.12" } }, + "fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -349,6 +359,15 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "is-absolute": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", + "integrity": "sha1-IN5p89uULvLYe5wto28XIjWxtes=", + "requires": { + "is-relative": "^0.2.1", + "is-windows": "^0.2.0" + } + }, "is-callable": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", @@ -367,6 +386,14 @@ "has-symbols": "^1.0.1" } }, + "is-relative": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", + "integrity": "sha1-0n9MfVFtF1+2ENuEu+7yPDvJeqU=", + "requires": { + "is-unc-path": "^0.1.1" + } + }, "is-symbol": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", @@ -380,6 +407,19 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, + "is-unc-path": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz", + "integrity": "sha1-arBTpyVzwQJQ/0FqOBTDUXivObk=", + "requires": { + "unc-path-regex": "^0.1.0" + } + }, + "is-windows": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", + "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=" + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -529,6 +569,24 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.1.tgz", + "integrity": "sha512-bJ9nH25Z51HG2QIu66K4dMVyMs6o8bNQpviDnXzG+O/gfNxPU9IpIig0j4pzlO707GcGZ6QA4rWhlRxjJsjnZw==", + "requires": { + "clone": "2.x" + } + }, + "node-persist": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/node-persist/-/node-persist-2.1.0.tgz", + "integrity": "sha1-5lK784haBNrWo1PXQXYXfIORRwc=", + "requires": { + "is-absolute": "^0.2.6", + "mkdirp": "~0.5.1", + "q": "~1.1.1" + } + }, "node-telegram-bot-api": { "version": "0.50.0", "resolved": "https://registry.npmjs.org/node-telegram-bot-api/-/node-telegram-bot-api-0.50.0.tgz", @@ -581,6 +639,15 @@ "wrappy": "1" } }, + "path": { + "version": "0.12.7", + "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", + "requires": { + "process": "^0.11.1", + "util": "^0.10.3" + } + }, "perfect-logger": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/perfect-logger/-/perfect-logger-2.0.1.tgz", @@ -591,6 +658,11 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -615,6 +687,11 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, + "q": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/q/-/q-1.1.2.tgz", + "integrity": "sha1-Y1fikSBnAdmfGXq4TlforRlvKok=" + }, "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", @@ -814,6 +891,11 @@ "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" }, + "unc-path-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -822,6 +904,21 @@ "punycode": "^2.1.0" } }, + "util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "requires": { + "inherits": "2.0.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + } + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 5f26e1c..41e401e 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,9 @@ "dependencies": { "cached-request": "^2.0.1", "dotenv": "^8.2.0", + "fs": "0.0.1-security", "node-telegram-bot-api": "^0.50.0", "perfect-logger": "^2.0.1", - "rapidapi-connect": "0.0.6", "request": "^2.88.2", "throttled-request": "^0.1.1" } From 3b234211403c27be487b5888b05791ed6786608a Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 25 Jun 2020 19:45:38 +0100 Subject: [PATCH 2/7] keep going.. --- app.js | 172 ++----- data/bot/chat.js | 63 +++ data/bot/faq/subscriptions.js | 38 ++ data/bot/questions.js | 14 + data/bot/requests/football.js | 47 ++ data/bot/requests/joke.js | 30 ++ data/bot/welcomeMesage.js | 7 + data/group/subs.json | 57 +++ image.png | Bin 0 -> 10985 bytes lib/logger.js | 9 - package-lock.json | 895 +++++++++++++++++++++++++--------- package.json | 6 + 12 files changed, 962 insertions(+), 376 deletions(-) create mode 100644 data/bot/chat.js create mode 100644 data/bot/faq/subscriptions.js create mode 100644 data/bot/questions.js create mode 100644 data/bot/requests/football.js create mode 100644 data/bot/requests/joke.js create mode 100644 data/bot/welcomeMesage.js create mode 100644 data/group/subs.json create mode 100644 image.png delete mode 100644 lib/logger.js diff --git a/app.js b/app.js index 9802fee..67fcc07 100644 --- a/app.js +++ b/app.js @@ -11,6 +11,13 @@ const fs = require('fs'); const logger = require('perfect-logger'); const TelegramBot = require('node-telegram-bot-api'); +const bot_chat = require('./data/bot/chat') +const bot_welcome = require('./data/bot/welcomeMesage') +const bot_questions = require('./data/bot/questions') +const bot_football = require('./data/bot/requests/football') +const bot_joke = require('./data/bot/requests/joke') +const bot_faq_subscriptions = require('./data/bot/faq/subscriptions') + const token = process.env.BOT_TOKEN; const name = process.env.BOT_NAME; const channel = process.env.CHANNEL @@ -31,153 +38,46 @@ const bot = new TelegramBot(token, { // Wlecome Message bot.on('new_chat_members', (msg) => { - const newUserMention = "@" + msg.new_chat_member.first_name + "<\/a>" - bot.sendMessage(msg.chat.id, "Hello " + newUserMention + ", Welcome to " + channel + ". \n\nPlease PM me @" + process.env.BOT_USERNAME + " to find out all needed information about our service before asking an admin or posting in here.\n\nIf you do ask questions, and its obvious you have not spoken to me, you will be booted from the room. This is IPTV, admins don't have time for hand holding.!!!", { parse_mode: "HTML" }); - logger.info("ID - " + msg.new_chat_member.id + " First Name - " + msg.new_chat_member.first_name + " joined the group"); + bot_welcome.welcomeMessage(bot, msg, logger) }); bot.on('message', (msg) => { - // Listen call for "help" - const help = "help"; - if (msg.text && msg.text.toString().toLowerCase().includes(help)) { - const userMention = "@" + msg.from.first_name + "<\/a>" - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked for help"); - bot.sendMessage(msg.chat.id, "Hello " + userMention + " please PM me @" + process.env.BOT_USERNAME + " and i'll try to help.", { parse_mode: "HTML" }); - } + bot_chat.help(bot, msg, logger) + // listen for "filelinked code" + bot_chat.filelinked_help(bot, msg, logger) + // listen for "bye" + bot_chat.bye(bot, msg, logger) + // listen for "thank you BOT" + bot_chat.thankYou(bot, msg, logger, name) + // listen for "i love you BOT" + bot_chat.iLoveYou(bot, msg, logger, name) + // listen for "deal" + bot_chat.loveADeal(bot, msg, logger) + // listen for "football today" + bot_football.gamesToday(bot, msg, logger) + // listen for "BOT tell me a joke" + bot_joke.tellMe(bot, msg, logger, name) + // listen for "you there BOT" + bot_chat.youThere(bot, msg, logger, name) + // listen for "fuck off BOT" + bot_chat.fOff(bot, msg, logger, name) + // listen for "what sub should i buy?" + bot_questions.whatSubShouldIBuy(bot, msg, logger) - const help_filelinked = "filelinked code"; - if (msg.text && msg.text.toString().toLowerCase().includes(help_filelinked)) { - const userMention = "@" + msg.from.first_name + "<\/a>" - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked for fileLinked code"); - bot.sendMessage(msg.chat.id, "Hello " + userMention + " please PM me @" + process.env.BOT_USERNAME + " and i'll give you the code", { parse_mode: "HTML" }); - } + bot_faq_subscriptions.prices(bot, msg, logger) + + - const bye = "bye"; - if (msg.text && msg.text.toString().toLowerCase().includes(bye)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said bye"); - bot.sendMessage(msg.chat.id, "Bye " + msg.from.first_name + ", Hope to see you again."); - } + - const love = "i love you "; - const lovePlus = love + name.toLowerCase() - if (msg.text && msg.text.toString().toLowerCase().includes(lovePlus)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said they loved me"); - bot.sendMessage(msg.chat.id, "I love you too " + msg.from.first_name); - } + - const thankYou = "thank you " + name.toLowerCase(); - if (msg.text && msg.text.toString().toLowerCase().includes(thankYou)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said thank you"); - bot.sendMessage(msg.chat.id, "You're welcome " + msg.from.first_name); - } + - const footballToday = "football today"; - if (msg.text && msg.text.toString().toLowerCase().includes(footballToday)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked for football today"); - var options = { - method: 'GET', - url: 'https://football-pro.p.rapidapi.com/api/v2.0/livescores', - qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' }, - headers: { - 'x-rapidapi-host': 'football-pro.p.rapidapi.com', - 'x-rapidapi-key': process.env.RAPIDAPI_API_KEY, - useQueryString: true - }, - ttl: 18000000 //5 hours - }; - cachedRequest(options, function (error, response, body) { - // console.log(response) - if (error) throw new Error(error); - - // console.log(body); - let jsonBody = JSON.parse(body) - if (jsonBody.data.length > 0) { - bot.sendMessage(msg.chat.id, 'Yes there is!').then(() => { - return jsonBody.data.forEach(function (entry) { - var homeTeam = entry.localTeam.data.name - var awayTeam = entry.visitorTeam.data.name - var startTime = entry.time.starting_at.time - // console.log(entry); - bot.sendMessage(msg.chat.id, homeTeam + " VS " + awayTeam + " @ " + startTime) - }); - }).then(() => { - return bot.sendMessage(msg.chat.id, 'To see what channels the football is streaming on please join @footballontv') - }) - } else { - bot.sendMessage(msg.chat.id, 'Sadly there is no football today :(') - } - }) - } - - const joke = name.toLowerCase() + " tell me a joke"; - if (msg.text && msg.text.toString().toLowerCase().includes(joke)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked for a joke"); - - var options = { - method: 'GET', - url: 'https://joke3.p.rapidapi.com/v1/joke', - // qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' }, - headers: { - 'x-rapidapi-host': 'joke3.p.rapidapi.com', - 'x-rapidapi-key': process.env.RAPIDAPI_API_KEY, - useQueryString: true - }, - // ttl: 18000 //5 hours - }; - - request(options, function (error, response, body) { - // console.log(response) - - if (error) throw new Error(error); - let jsonBody = JSON.parse(body) - bot.sendMessage(msg.chat.id, jsonBody.content) - } - ) - } - - const youThere = "you there " + name.toLowerCase() + "?"; - if (msg.text && msg.text.toString().toLowerCase().includes(youThere)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked if im there"); - bot.sendMessage(msg.chat.id, "Always..."); - } - - const fuuk = "fuck off "; - const fuuckPlus = fuuk + name.toLowerCase() - if (msg.text && msg.text.toString().toLowerCase().includes(fuuckPlus)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " told me to fuck off"); - bot.sendMessage(msg.chat.id, "Fuck off yourself " + msg.from.first_name + "!"); - } - - const whatSubShouldIBuy = "what sub should i buy?" - const subs = ["VIP!", "Premium Plus!", "Old Premium!", "Gold!", "Bronze!", "New Premium!", "KDB!", "Technoid!", "Bluemoon!", "SOL!", "Gambler!", "All of em!"] - if (msg.text && msg.text.toString().toLowerCase().includes(whatSubShouldIBuy)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked what sub to buy"); - const randomSub = subs[Math.floor(Math.random() * subs.length)]; - bot.sendMessage(msg.chat.id, randomSub); - } - - const deal = "deal"; - // const me = 434187971 - // const sarah = 868225940 - // const MANC = 470861863 - if (msg.text && msg.text.toString().toLowerCase().match(/\bdeal\b/)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said we got a deal!"); - bot.sendMessage(msg.chat.id, "I LOVE it when " + msg.from.first_name + ", does a deal :)"); - } - - const subPrice = "- subscription prices"; - if (msg.text && msg.text.toString().toLowerCase() === subPrice) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Got subscription Prices"); - bot.sendMessage(msg.chat.id, "PREMIUM PLUS ----£30\nVIP-----------------------£25\nOLD PREMIUM -----£17\nBLUEMOON ---------£15\nKDB --------------------£14\nGOLD ------------------£13\nTECHNOID -----------£13\nBRONZE --------------£10\nSOL ---------------------£10") - .then(() => { - return bot.sendMessage(msg.chat.id, "All of these prices are for 12 Month subscription subs").then(() => { - return bot.sendMessage(msg.chat.id, "Keep an eye out though because we offer special deals on different subs from time to time.") - }) - }) - } + const howToSignUp = "- how to get a subscription?"; if (msg.text && msg.text.toString().toLowerCase() === howToSignUp) { diff --git a/data/bot/chat.js b/data/bot/chat.js new file mode 100644 index 0000000..b5a9380 --- /dev/null +++ b/data/bot/chat.js @@ -0,0 +1,63 @@ +module.exports = { + help: (bot, msg, logger) => { + const help = "help"; + if (msg.text && msg.text.toString().toLowerCase().includes(help)) { + const userMention = "@" + msg.from.first_name + "<\/a>" + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked for help"); + bot.sendMessage(msg.chat.id, "Hello " + userMention + " please PM me @" + process.env.BOT_USERNAME + " and i'll try to help.", { parse_mode: "HTML" }); + } + }, + filelinked_help: (bot, msg, logger) => { + const help_filelinked = "filelinked code"; + if (msg.text && msg.text.toString().toLowerCase().includes(help_filelinked)) { + const userMention = "@" + msg.from.first_name + "<\/a>" + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked for fileLinked code"); + bot.sendMessage(msg.chat.id, "Hello " + userMention + " please PM me @" + process.env.BOT_USERNAME + " and i'll give you the code", { parse_mode: "HTML" }); + } + }, + bye: (bot, msg, logger) => { + const bye = "bye"; + if (msg.text && msg.text.toString().toLowerCase().includes(bye)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said bye"); + bot.sendMessage(msg.chat.id, "Bye " + msg.from.first_name + ", Hope to see you again."); + } + }, + iLoveYou: (bot, msg, logger, name) => { + const love = "i love you "; + const lovePlus = love + name.toLowerCase() + if (msg.text && msg.text.toString().toLowerCase().includes(lovePlus)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said they loved me"); + bot.sendMessage(msg.chat.id, "I love you too " + msg.from.first_name); + } + }, + thankYou: (bot, msg, logger, name) => { + const thankYou = "thank you " + name.toLowerCase(); + if (msg.text && msg.text.toString().toLowerCase().includes(thankYou)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said thank you"); + bot.sendMessage(msg.chat.id, "You're welcome " + msg.from.first_name); + } + }, + youThere: (bot, msg, logger, name) => { + const youThere = "you there " + name.toLowerCase() + "?"; + if (msg.text && msg.text.toString().toLowerCase().includes(youThere)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked if im there"); + bot.sendMessage(msg.chat.id, "Always..."); + } + }, + fOff: (bot, msg, logger, name) => { + const fuuk = "fuck off "; + const fuuckPlus = fuuk + name.toLowerCase() + if (msg.text && msg.text.toString().toLowerCase().includes(fuuckPlus)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " told me to fuck off"); + bot.sendMessage(msg.chat.id, "Fuck off yourself " + msg.from.first_name + "!"); + } + }, + loveADeal: (bot, msg, logger) => { + const deal = "deal"; + if (msg.text && msg.text.toString().toLowerCase().match(/\bdeal\b/)) { + if (msg) + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said we got a deal!"); + bot.sendMessage(msg.chat.id, "I LOVE it when " + msg.from.first_name + ", does a deal :)"); + } + } +}; \ No newline at end of file diff --git a/data/bot/faq/subscriptions.js b/data/bot/faq/subscriptions.js new file mode 100644 index 0000000..e424240 --- /dev/null +++ b/data/bot/faq/subscriptions.js @@ -0,0 +1,38 @@ +const fs = require('fs'); +const {table} = require('table') +const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) +const t = require('obj-array-table') +const nodeHtmlToImage = require('node-html-to-image') + +var arrayToTable = require('array-to-table') + + +module.exports = { + prices: (bot, msg, logger) => { + const subPrice = "- subscription prices"; + if (msg.text && msg.text.toString().toLowerCase() === subPrice) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Got subscription Prices"); + + + let test = arrayToTable(subs) + + let t = "
" + test + "
" + + nodeHtmlToImage({ + output: './image.png', + html: t + }) + + bot.sendMessage(msg.chat.id, + `First Header | Second Header + ------------- | ------------- + Content Cell | Content Cell + Content Cell | Content Cell`, { parse_mode: "Markdown" }) + .then(() => { + return bot.sendMessage(msg.chat.id, "All of these prices are for 12 Month subscription subs").then(() => { + return bot.sendMessage(msg.chat.id, "Keep an eye out though because we offer special deals on different subs from time to time.") + }) + }) + } + } +} \ No newline at end of file diff --git a/data/bot/questions.js b/data/bot/questions.js new file mode 100644 index 0000000..0940ec2 --- /dev/null +++ b/data/bot/questions.js @@ -0,0 +1,14 @@ +const fs = require('fs'); + +module.exports = { + whatSubShouldIBuy: (bot, msg, logger) => { + const whatSubShouldIBuy = "what sub should i buy" + const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) + + if (msg.text && msg.text.toString().toLowerCase().includes(whatSubShouldIBuy)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked what sub to buy"); + const randomSub = subs[Math.floor(Math.random() * subs.length)]; + bot.sendMessage(msg.chat.id, randomSub.SUB + "!"); + } + } +} \ No newline at end of file diff --git a/data/bot/requests/football.js b/data/bot/requests/football.js new file mode 100644 index 0000000..a720040 --- /dev/null +++ b/data/bot/requests/football.js @@ -0,0 +1,47 @@ +module.exports = { + gamesToday: (bot, msg, logger) => { + const footballToday = "football today"; + if (msg.text && msg.text.toString().toLowerCase().includes(footballToday)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked for football today"); + + var options = { + method: 'GET', + url: 'https://football-pro.p.rapidapi.com/api/v2.0/livescores', + qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' }, + headers: { + 'x-rapidapi-host': 'football-pro.p.rapidapi.com', + 'x-rapidapi-key': process.env.RAPIDAPI_API_KEY, + useQueryString: true + }, + ttl: 18000000 //5 hours + }; + + cachedRequest(options, function (error, response, body) { + // console.log(response) + if (error) throw new Error(error); + + // console.log(body); + let jsonBody = JSON.parse(body) + if (jsonBody.data.length > 0) { + bot.sendMessage(msg.chat.id, 'Yes there is!').then(() => { + return jsonBody.data.forEach(function (entry) { + var homeTeam = entry.localTeam.data.name + var awayTeam = entry.visitorTeam.data.name + var startTime = entry.time.starting_at.time + // console.log(entry); + bot.sendMessage(msg.chat.id, homeTeam + " VS " + awayTeam + " @ " + startTime) + }); + }).then(() => { + return bot.sendMessage(msg.chat.id, 'To see what channels the football is streaming on please join @footballontv') + }) + } else { + bot.sendMessage(msg.chat.id, 'Sadly there is no football today :(') + } + }) + } + + + + + } +} \ No newline at end of file diff --git a/data/bot/requests/joke.js b/data/bot/requests/joke.js new file mode 100644 index 0000000..a7d2ffb --- /dev/null +++ b/data/bot/requests/joke.js @@ -0,0 +1,30 @@ +module.exports = { + tellMe: (bot, msg, logger, name) => { + const joke = name.toLowerCase() + " tell me a joke"; + if (msg.text && msg.text.toString().toLowerCase().includes(joke)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked for a joke"); + + var options = { + method: 'GET', + url: 'https://joke3.p.rapidapi.com/v1/joke', + // qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' }, + headers: { + 'x-rapidapi-host': 'joke3.p.rapidapi.com', + 'x-rapidapi-key': process.env.RAPIDAPI_API_KEY, + useQueryString: true + }, + // ttl: 18000 //5 hours + }; + + request(options, function (error, response, body) { + // console.log(response) + + if (error) throw new Error(error); + let jsonBody = JSON.parse(body) + bot.sendMessage(msg.chat.id, jsonBody.content) + } + ) + } + + } +} \ No newline at end of file diff --git a/data/bot/welcomeMesage.js b/data/bot/welcomeMesage.js new file mode 100644 index 0000000..fa4c714 --- /dev/null +++ b/data/bot/welcomeMesage.js @@ -0,0 +1,7 @@ +module.exports = { + welcomeMessage: (bot, msg, logger) => { + const newUserMention = "
@" + msg.new_chat_member.first_name + "<\/a>" + bot.sendMessage(msg.chat.id, "Hello " + newUserMention + ", Welcome to " + channel + ". \n\nPlease PM me @" + process.env.BOT_USERNAME + " to find out all needed information about our service before asking an admin or posting in here.\n\nIf you do ask questions, and its obvious you have not spoken to me, you will be booted from the room. This is IPTV, admins don't have time for hand holding.!!!", { parse_mode: "HTML" }); + logger.info("ID - " + msg.new_chat_member.id + " First Name - " + msg.new_chat_member.first_name + " joined the group"); + } +}; \ No newline at end of file diff --git a/data/group/subs.json b/data/group/subs.json new file mode 100644 index 0000000..cd2ea12 --- /dev/null +++ b/data/group/subs.json @@ -0,0 +1,57 @@ +[ + { + "SUB": "VIP", + "COST": 25, + "STATUS": 1 + }, + { + "SUB": "Premium Plus", + "COST": 30, + "STATUS": 1 + }, + { + "SUB": "Old Premium", + "COST": 17, + "STATUS": 1 + }, + { + "SUB": "Gold", + "COST": 13, + "STATUS": 1 + }, + { + "SUB": "Bronze", + "COST": 10, + "STATUS": 1 + }, + { + "SUB": "KDB", + "COST": 14, + "STATUS": 1 + }, + { + "SUB": "Technoid", + "COST": 13, + "STATUS": 1 + }, + { + "SUB": "Bluemoon", + "COST": 15, + "STATUS": 1 + }, + { + "SUB": "SOL", + "COST": 10, + "STATUS": "X" + }, + { + "SUB": "Gambler", + "COST": "X", + "STATUS": 1 + }, + { + "SUB": "All of em", + "COST": "X", + "STATUS": "X" + } + ] \ No newline at end of file diff --git a/image.png b/image.png new file mode 100644 index 0000000000000000000000000000000000000000..d109df2570b7be98c9328a8c3069c427cac09ea6 GIT binary patch literal 10985 zcmeHtX;@R|x^}GHYMqc)L1j{OYgGiC02y12ID=AUCQ)QiW{@!iVrvnUB38uIBIGC{ zLI@Es1PCN$E~bzoVuYAPCJ{n_fFXoT=ULMI?Vi2QcU|ZFKK&t=KvuHW`#$&ha{ZLk z;T22QFGZnHD~=vPyP!}DSD{d!99*&pev)%%3cf)txa@NH0IIY@e*}fvfI5o)`b_+N zF`pHz*CTM4%=}HI`>158Ti8(I(F*C`?yY)y%4oHFWxVJ0E6YtQ<8OGa-Ml20acGJA zBi*Im-+k&8eqriJXz}XaBZMaWGQvK$3pSFnFW64wqQCi4_D>Jwx9LphT@G;C#x6I3 zkN!M_AGZL7`bBo|3Ve5aXu-p-5p>a+8!knwuhws{&UHeg_pZ;t%R?-7lvv(7u~aPL z313E4|B%cgkd4YPjefhgjRjVF>jZh35>rA0D|!lgkuPHAvrN$kg-S1cnnt6LveJiX z!U=4(xVS^=uN^t0c5u@}p&TkHX=!bKpSK6>DK|+sVf)&XhIjnnn17MZ`_bRyWf0BE z-u|W}UVlJhH7dnDNRrB@IS%15^?1Du$4xhH-kiFimD)Hvkm+FDZ)|+I| zcoQs59(|`ydc0bhAb2H`8nerlvH%aAI!yQ`mMAzFu9lZ)8aZHkWxi!;ChRE!quEzm zTYD&KzfSrgrY7xIS%tgFLvK^87jl!OtV3v}l#7*gIXet3WAMk_C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js.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, - "is-absolute": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", - "integrity": "sha1-IN5p89uULvLYe5wto28XIjWxtes=", - "requires": { - "is-relative": "^0.2.1", - "is-windows": "^0.2.0" - } - }, "is-callable": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", @@ -378,6 +644,11 @@ "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==" }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, "is-regex": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", @@ -386,14 +657,6 @@ "has-symbols": "^1.0.1" } }, - "is-relative": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", - "integrity": "sha1-0n9MfVFtF1+2ENuEu+7yPDvJeqU=", - "requires": { - "is-unc-path": "^0.1.1" - } - }, "is-symbol": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", @@ -407,19 +670,6 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, - "is-unc-path": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz", - "integrity": "sha1-arBTpyVzwQJQ/0FqOBTDUXivObk=", - "requires": { - "unc-path-regex": "^0.1.0" - } - }, - "is-windows": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", - "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=" - }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -430,32 +680,44 @@ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" }, - "jade": { - "version": "0.26.3", - "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", - "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", - "requires": { - "commander": "0.6.1", - "mkdirp": "0.3.0" - }, - "dependencies": { - "commander": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", - "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=" - }, - "mkdirp": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", - "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=" - } - } - }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" }, + "jsdom": { + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-13.2.0.tgz", + "integrity": "sha512-cG1NtMWO9hWpqRNRR3dSvEQa8bFI6iLlqU2x4kwX51FQjp0qus8T9aBaAO6iGp3DeBrhdwuKxckknohkmfvsFw==", + "requires": { + "abab": "^2.0.0", + "acorn": "^6.0.4", + "acorn-globals": "^4.3.0", + "array-equal": "^1.0.0", + "cssom": "^0.3.4", + "cssstyle": "^1.1.1", + "data-urls": "^1.1.0", + "domexception": "^1.0.1", + "escodegen": "^1.11.0", + "html-encoding-sniffer": "^1.0.2", + "nwsapi": "^2.0.9", + "parse5": "5.1.0", + "pn": "^1.1.0", + "request": "^2.88.0", + "request-promise-native": "^1.0.5", + "saxes": "^3.1.5", + "symbol-tree": "^3.2.2", + "tough-cookie": "^2.5.0", + "w3c-hr-time": "^1.0.1", + "w3c-xmlserializer": "^1.0.1", + "webidl-conversions": "^4.0.2", + "whatwg-encoding": "^1.0.5", + "whatwg-mimetype": "^2.3.0", + "whatwg-url": "^7.0.0", + "ws": "^6.1.2", + "xml-name-validator": "^3.0.0" + } + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -482,15 +744,24 @@ "verror": "1.10.0" } }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=" + "lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=" }, "mime": { "version": "1.6.0", @@ -511,12 +782,11 @@ } }, "minimatch": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", - "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "requires": { - "lru-cache": "2", - "sigmund": "~1.0.0" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -532,59 +802,23 @@ "minimist": "0.0.8" } }, - "mocha": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", - "integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=", - "requires": { - "commander": "2.3.0", - "debug": "2.2.0", - "diff": "1.4.0", - "escape-string-regexp": "1.0.2", - "glob": "3.2.11", - "growl": "1.9.2", - "jade": "0.26.3", - "mkdirp": "0.5.1", - "supports-color": "1.2.0", - "to-iso-string": "0.0.2" - }, - "dependencies": { - "debug": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "requires": { - "ms": "0.7.1" - } - }, - "ms": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" - } - } - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "node-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.1.tgz", - "integrity": "sha512-bJ9nH25Z51HG2QIu66K4dMVyMs6o8bNQpviDnXzG+O/gfNxPU9IpIig0j4pzlO707GcGZ6QA4rWhlRxjJsjnZw==", - "requires": { - "clone": "2.x" - } + "neo-async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==" }, - "node-persist": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/node-persist/-/node-persist-2.1.0.tgz", - "integrity": "sha1-5lK784haBNrWo1PXQXYXfIORRwc=", + "node-html-to-image": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/node-html-to-image/-/node-html-to-image-2.1.1.tgz", + "integrity": "sha512-uGWjYeXM1V4DWAWQsmC99KcgnrE82jVHtGzLvN53BadqcovaJOe/5NwBMbn+7k28xrPNEuwbvda0jGv/DvMEwQ==", "requires": { - "is-absolute": "^0.2.6", - "mkdirp": "~0.5.1", - "q": "~1.1.1" + "handlebars": "^4.5.3", + "puppeteer": "^2.0.0" } }, "node-telegram-bot-api": { @@ -605,11 +839,31 @@ "request-promise": "^4.2.2" } }, + "numeral": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/numeral/-/numeral-2.0.6.tgz", + "integrity": "sha1-StCAk21EPCVhrtnyGX7//iX05QY=" + }, + "nwsapi": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.0.tgz", + "integrity": "sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==" + }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, + "obj-array-table": { + "version": "1.0.17", + "resolved": "https://registry.npmjs.org/obj-array-table/-/obj-array-table-1.0.17.tgz", + "integrity": "sha512-kPdSI2Y9JYYQBuB0PQLiHgKejQMmMYi7jlfNqp1WEQtCRJaTiPtBLxHr4ULHMoEqAQGN0yBSYZMEQC56B9L8kw==", + "requires": { + "dateformat-nodep": "^1.0.0", + "lodash": "^4.16.4", + "numeral": "^2.0.6" + } + }, "object-inspect": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", @@ -639,15 +893,34 @@ "wrappy": "1" } }, - "path": { - "version": "0.12.7", - "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", - "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", "requires": { - "process": "^0.11.1", - "util": "^0.10.3" + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" } }, + "parse5": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz", + "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" + }, "perfect-logger": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/perfect-logger/-/perfect-logger-2.0.1.tgz", @@ -658,16 +931,31 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, - "process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" + "pn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", + "integrity": "sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==" + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" + }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "psl": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", @@ -687,27 +975,43 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, - "q": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/q/-/q-1.1.2.tgz", - "integrity": "sha1-Y1fikSBnAdmfGXq4TlforRlvKok=" + "puppeteer": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-2.1.1.tgz", + "integrity": "sha512-LWzaDVQkk1EPiuYeTOj+CZRIjda4k2s5w4MK4xoH2+kgWV/SDlkYHmxatDdtYrciHUKSXTsGgPgPP8ILVdBsxg==", + "requires": { + "@types/mime-types": "^2.1.0", + "debug": "^4.1.0", + "extract-zip": "^1.6.6", + "https-proxy-agent": "^4.0.0", + "mime": "^2.0.3", + "mime-types": "^2.1.25", + "progress": "^2.0.1", + "proxy-from-env": "^1.0.0", + "rimraf": "^2.6.1", + "ws": "^6.1.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "mime": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz", + "integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==" + } + } }, "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" }, - "rapidapi-connect": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/rapidapi-connect/-/rapidapi-connect-0.0.6.tgz", - "integrity": "sha512-uOCBZUhnUVeWFHbwqIhUSV21bAzRfy7GaTxKnW8p6C5dfy5BhmeSWCZftm0uQ/HxSBjRwyWQ4lqDMoZuiCptmQ==", - "requires": { - "chai": "^3.5.0", - "mocha": "^2.5.3", - "request": "^2.72.0", - "ws": "^2.1.0" - } - }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -775,6 +1079,29 @@ "lodash": "^4.17.15" } }, + "request-promise-native": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.8.tgz", + "integrity": "sha512-dapwLGqkHtwL5AEbfenuzjTYg35Jd6KPytsC2/TLkVMz8rm+tNt72MGUWT1RP/aYawMpN6HqbNGBQaRcBtjQMQ==", + "requires": { + "request-promise-core": "1.1.3", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" + } + }, + "require-dir": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/require-dir/-/require-dir-1.2.0.tgz", + "integrity": "sha512-LY85DTSu+heYgDqq/mK+7zFHWkttVNRXC9NKcKGyuGLdlsfbjEPrIEYdCVrx6hqnJb+xSu3Lzaoo8VnmOhhjNA==" + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "requires": { + "glob": "^7.1.3" + } + }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -785,10 +1112,28 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "sigmund": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" + "saxes": { + "version": "3.1.11", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-3.1.11.tgz", + "integrity": "sha512-Ydydq3zC+WYDJK1+gRxRapLIED9PWeSuuS41wqyoRmzvhhh9nc+QQrVMKJYzJFULazeGhzSV0QleN2wD3boh2g==", + "requires": { + "xmlchars": "^2.1.1" + } + }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" }, "sshpk": { "version": "1.16.1", @@ -811,6 +1156,16 @@ "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=" }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, "string.prototype.trimend": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", @@ -844,21 +1199,35 @@ } } }, - "supports-color": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", - "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=" + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" + }, + "table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "requires": { + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + } }, "throttled-request": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/throttled-request/-/throttled-request-0.1.1.tgz", "integrity": "sha1-QUa3C3elrsozxGMyzxPrnHkelxs=" }, - "to-iso-string": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", - "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=" - }, "tough-cookie": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", @@ -868,6 +1237,14 @@ "punycode": "^2.1.1" } }, + "tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", + "requires": { + "punycode": "^2.1.0" + } + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -881,20 +1258,24 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, - "type-detect": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz", - "integrity": "sha1-diIXzAbbJY7EiQihKY6LlRIejqI=" + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "~1.1.2" + } }, - "ultron": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", - "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, - "unc-path-regex": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", - "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" + "uglify-js": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.10.0.tgz", + "integrity": "sha512-Esj5HG5WAyrLIdYU74Z3JdG2PxdIusvj6IWHMtlyESxc7kcDz7zYlYjpnSokn1UbpV0d/QX9fan7gkCNd/9BQA==", + "optional": true }, "uri-js": { "version": "4.2.2", @@ -904,21 +1285,6 @@ "punycode": "^2.1.0" } }, - "util": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", - "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", - "requires": { - "inherits": "2.0.3" - }, - "dependencies": { - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - } - } - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -939,25 +1305,92 @@ "extsprintf": "^1.2.0" } }, + "w3c-hr-time": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", + "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", + "requires": { + "browser-process-hrtime": "^1.0.0" + } + }, + "w3c-xmlserializer": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-1.1.2.tgz", + "integrity": "sha512-p10l/ayESzrBMYWRID6xbuCKh2Fp77+sA0doRuGn4tTIMrrZVeqfpKjXHY+oDh3K4nLdPgNwMTVP6Vp4pvqbNg==", + "requires": { + "domexception": "^1.0.1", + "webidl-conversions": "^4.0.2", + "xml-name-validator": "^3.0.0" + } + }, + "webidl-conversions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", + "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==" + }, + "whatwg-encoding": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", + "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", + "requires": { + "iconv-lite": "0.4.24" + } + }, + "whatwg-mimetype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", + "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==" + }, + "whatwg-url": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", + "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-2.3.1.tgz", - "integrity": "sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", "requires": { - "safe-buffer": "~5.0.1", - "ultron": "~1.1.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", - "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=" - } + "async-limiter": "~1.0.0" + } + }, + "xml-name-validator": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", + "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==" + }, + "xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==" + }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" } } } diff --git a/package.json b/package.json index 41e401e..46c2106 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,18 @@ "author": "", "license": "ISC", "dependencies": { + "array-to-table": "^1.0.1", "cached-request": "^2.0.1", "dotenv": "^8.2.0", "fs": "0.0.1-security", + "html-table-builder": "^1.0.1", + "node-html-to-image": "^2.1.1", "node-telegram-bot-api": "^0.50.0", + "obj-array-table": "^1.0.17", "perfect-logger": "^2.0.1", "request": "^2.88.2", + "require-dir": "^1.2.0", + "table": "^5.4.6", "throttled-request": "^0.1.1" } } From b472bed57f40884e29f28f75fb8652326123784d Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 25 Jun 2020 20:51:12 +0100 Subject: [PATCH 3/7] keep going --- app.js | 5 ++--- data/bot/faq/subscriptions.js | 37 ++++++++++------------------------ image.png | Bin 10985 -> 0 bytes 3 files changed, 13 insertions(+), 29 deletions(-) delete mode 100644 image.png diff --git a/app.js b/app.js index 67fcc07..4e9e5b2 100644 --- a/app.js +++ b/app.js @@ -16,7 +16,7 @@ const bot_welcome = require('./data/bot/welcomeMesage') const bot_questions = require('./data/bot/questions') const bot_football = require('./data/bot/requests/football') const bot_joke = require('./data/bot/requests/joke') -const bot_faq_subscriptions = require('./data/bot/faq/subscriptions') +const bot_faq_subscription = require('./data/bot/faq/subscriptions') const token = process.env.BOT_TOKEN; const name = process.env.BOT_NAME; @@ -65,8 +65,7 @@ bot.on('message', (msg) => { // listen for "what sub should i buy?" bot_questions.whatSubShouldIBuy(bot, msg, logger) - bot_faq_subscriptions.prices(bot, msg, logger) - + bot_faq_subscription.prices(bot, msg, logger) diff --git a/data/bot/faq/subscriptions.js b/data/bot/faq/subscriptions.js index e424240..5f24301 100644 --- a/data/bot/faq/subscriptions.js +++ b/data/bot/faq/subscriptions.js @@ -1,33 +1,18 @@ -const fs = require('fs'); -const {table} = require('table') -const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) -const t = require('obj-array-table') -const nodeHtmlToImage = require('node-html-to-image') - -var arrayToTable = require('array-to-table') - - module.exports = { prices: (bot, msg, logger) => { const subPrice = "- subscription prices"; if (msg.text && msg.text.toString().toLowerCase() === subPrice) { logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Got subscription Prices"); - - - let test = arrayToTable(subs) - - let t = "
" + test + "
" - - nodeHtmlToImage({ - output: './image.png', - html: t - }) - - bot.sendMessage(msg.chat.id, - `First Header | Second Header - ------------- | ------------- - Content Cell | Content Cell - Content Cell | Content Cell`, { parse_mode: "Markdown" }) + bot.sendMessage(msg.chat.id, ` + PREMIUM PLUS ----£30\n + VIP-----------------------£25\n + OLD PREMIUM -----£17\n + BLUEMOON ---------£15\n + KDB --------------------£14\n + GOLD ------------------£13\n + TECHNOID -----------£13\n + BRONZE --------------£10\n + SOL ---------------------£10`) .then(() => { return bot.sendMessage(msg.chat.id, "All of these prices are for 12 Month subscription subs").then(() => { return bot.sendMessage(msg.chat.id, "Keep an eye out though because we offer special deals on different subs from time to time.") @@ -35,4 +20,4 @@ module.exports = { }) } } -} \ No newline at end of file +} diff --git a/image.png b/image.png deleted file mode 100644 index d109df2570b7be98c9328a8c3069c427cac09ea6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10985 zcmeHtX;@R|x^}GHYMqc)L1j{OYgGiC02y12ID=AUCQ)QiW{@!iVrvnUB38uIBIGC{ zLI@Es1PCN$E~bzoVuYAPCJ{n_fFXoT=ULMI?Vi2QcU|ZFKK&t=KvuHW`#$&ha{ZLk z;T22QFGZnHD~=vPyP!}DSD{d!99*&pev)%%3cf)txa@NH0IIY@e*}fvfI5o)`b_+N zF`pHz*CTM4%=}HI`>158Ti8(I(F*C`?yY)y%4oHFWxVJ0E6YtQ<8OGa-Ml20acGJA zBi*Im-+k&8eqriJXz}XaBZMaWGQvK$3pSFnFW64wqQCi4_D>Jwx9LphT@G;C#x6I3 zkN!M_AGZL7`bBo|3Ve5aXu-p-5p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9>^hy-nO?;Aro^S6N$~r#2qfYKKFOzKFHJTE@mu z)dD6m3|NrTL1{nQvQ{?HjCGU>H7Wc}!r9Emxkk1~YbTWz_2KQ?4WI>mYyJZkJRD2- zeZSQA8SDZ0x${4D!YED8bYE>3DKG{KYgk1nMwTit-4<(?_sge;0ZchUIo2*QGAb%+ zz%5_U1WXFNg!BjmHcKs~9#|1~Ddvang>Rr|Mb^HG!ngYlWsd^TBC2qrk9| z>pCs1;51ptKJgMcBc4Ag{_oF=|Lm{-wdDM_!{xtT{O6tC?? q3n_mg Date: Thu, 25 Jun 2020 21:05:19 +0100 Subject: [PATCH 4/7] subs finished --- data/bot/faq/subscriptions.js | 25 +++++--- data/group/subs.json | 112 +++++++++++++++++----------------- 2 files changed, 71 insertions(+), 66 deletions(-) diff --git a/data/bot/faq/subscriptions.js b/data/bot/faq/subscriptions.js index 5f24301..f3094fc 100644 --- a/data/bot/faq/subscriptions.js +++ b/data/bot/faq/subscriptions.js @@ -1,18 +1,23 @@ +const fs = require('fs') +const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) + module.exports = { prices: (bot, msg, logger) => { const subPrice = "- subscription prices"; if (msg.text && msg.text.toString().toLowerCase() === subPrice) { logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Got subscription Prices"); - bot.sendMessage(msg.chat.id, ` - PREMIUM PLUS ----£30\n - VIP-----------------------£25\n - OLD PREMIUM -----£17\n - BLUEMOON ---------£15\n - KDB --------------------£14\n - GOLD ------------------£13\n - TECHNOID -----------£13\n - BRONZE --------------£10\n - SOL ---------------------£10`) + bot.sendMessage(msg.chat.id, + `- + ${subs[0].SUB} ----£${subs[0].COST}\n + ${subs[1].SUB} -----------------------£${subs[1].COST}\n + ${subs[2].SUB} -----£${subs[2].COST}\n + ${subs[3].SUB} ---------£${subs[3].COST}\n + ${subs[4].SUB} --------------------£${subs[4].COST}\n + ${subs[5].SUB} ------------------£${subs[5].COST}\n + ${subs[6].SUB} -----------£${subs[6].COST}\n + ${subs[7].SUB} --------------£${subs[7].COST}\n + ${subs[8].SUB} ---------------------£${subs[8].COST} + `) .then(() => { return bot.sendMessage(msg.chat.id, "All of these prices are for 12 Month subscription subs").then(() => { return bot.sendMessage(msg.chat.id, "Keep an eye out though because we offer special deals on different subs from time to time.") diff --git a/data/group/subs.json b/data/group/subs.json index cd2ea12..0cac5d1 100644 --- a/data/group/subs.json +++ b/data/group/subs.json @@ -1,57 +1,57 @@ [ - { - "SUB": "VIP", - "COST": 25, - "STATUS": 1 - }, - { - "SUB": "Premium Plus", - "COST": 30, - "STATUS": 1 - }, - { - "SUB": "Old Premium", - "COST": 17, - "STATUS": 1 - }, - { - "SUB": "Gold", - "COST": 13, - "STATUS": 1 - }, - { - "SUB": "Bronze", - "COST": 10, - "STATUS": 1 - }, - { - "SUB": "KDB", - "COST": 14, - "STATUS": 1 - }, - { - "SUB": "Technoid", - "COST": 13, - "STATUS": 1 - }, - { - "SUB": "Bluemoon", - "COST": 15, - "STATUS": 1 - }, - { - "SUB": "SOL", - "COST": 10, - "STATUS": "X" - }, - { - "SUB": "Gambler", - "COST": "X", - "STATUS": 1 - }, - { - "SUB": "All of em", - "COST": "X", - "STATUS": "X" - } - ] \ No newline at end of file + { + "SUB": "Premium Plus", + "COST": 30, + "STATUS": 1 + }, + { + "SUB": "VIP", + "COST": 25, + "STATUS": 1 + }, + { + "SUB": "Old Premium", + "COST": 17, + "STATUS": 1 + }, + { + "SUB": "Bluemoon", + "COST": 15, + "STATUS": 1 + }, + { + "SUB": "KDB", + "COST": 14, + "STATUS": 1 + }, + { + "SUB": "Gold", + "COST": 13, + "STATUS": 1 + }, + { + "SUB": "Technoid", + "COST": 13, + "STATUS": 1 + }, + { + "SUB": "Bronze", + "COST": 10, + "STATUS": 1 + }, + { + "SUB": "SOL", + "COST": 10, + "STATUS": "X" + }, + { + "SUB": "Gambler", + "COST": "X", + "STATUS": 1 + }, + { + "SUB": "All of em", + "COST": "X", + "STATUS": "X" + } +] From 0d88c20960f79fe80c9e3f241c3a383615eaaca4 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 25 Jun 2020 21:55:17 +0100 Subject: [PATCH 5/7] get sub status --- app.js | 14 +++----------- data/bot/questions.js | 25 +++++++++++++++++++++++-- data/bot/requests/subStatus.js | 17 +++++++++++++++++ data/group/subs.json | 2 +- 4 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 data/bot/requests/subStatus.js diff --git a/app.js b/app.js index 4e9e5b2..4d2f351 100644 --- a/app.js +++ b/app.js @@ -64,19 +64,11 @@ bot.on('message', (msg) => { bot_chat.fOff(bot, msg, logger, name) // listen for "what sub should i buy?" bot_questions.whatSubShouldIBuy(bot, msg, logger) - - bot_faq_subscription.prices(bot, msg, logger) + bot_questions.subStatus(bot, msg, logger) - - - - - - - - - + // FAQ susbcription prices + bot_faq_subscription.prices(bot, msg, logger) const howToSignUp = "- how to get a subscription?"; if (msg.text && msg.text.toString().toLowerCase() === howToSignUp) { diff --git a/data/bot/questions.js b/data/bot/questions.js index 0940ec2..35bfa81 100644 --- a/data/bot/questions.js +++ b/data/bot/questions.js @@ -1,14 +1,35 @@ -const fs = require('fs'); +const fs = require('fs') +const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) module.exports = { whatSubShouldIBuy: (bot, msg, logger) => { const whatSubShouldIBuy = "what sub should i buy" - const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) if (msg.text && msg.text.toString().toLowerCase().includes(whatSubShouldIBuy)) { logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked what sub to buy"); const randomSub = subs[Math.floor(Math.random() * subs.length)]; bot.sendMessage(msg.chat.id, randomSub.SUB + "!"); } + }, + subStatus: (bot, msg, logger, name) => { + let string = "" + const subStatus = "sub status"; + if (msg.text && msg.text.toString().toLowerCase().includes(subStatus)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription"); + subs.forEach(element => { + if (element.COST != "X") { + if (element.STATUS === 1) { + element.STATUS = "Up" + } else { + element.STATUS = "Down" + } + let catString = element.SUB + " Is " + element.STATUS + // console.log(catString) + string += '\n' + catString; + } + }); + // console.log(string) + bot.sendMessage(msg.chat.id, string) + } } } \ No newline at end of file diff --git a/data/bot/requests/subStatus.js b/data/bot/requests/subStatus.js new file mode 100644 index 0000000..4fdda1b --- /dev/null +++ b/data/bot/requests/subStatus.js @@ -0,0 +1,17 @@ +const fs = require('fs') +const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) + +module.exports = { + tellMe: (bot, msg, logger, name) => { + + const subStatus = "sub status"; + if (msg.text && msg.text.toString().toLowerCase().includes(subStatus)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription"); + + + bot.sendMessage(msg.chat.id, subs) + } + + + } +} \ No newline at end of file diff --git a/data/group/subs.json b/data/group/subs.json index 0cac5d1..69eaff2 100644 --- a/data/group/subs.json +++ b/data/group/subs.json @@ -42,7 +42,7 @@ { "SUB": "SOL", "COST": 10, - "STATUS": "X" + "STATUS": 0 }, { "SUB": "Gambler", From bcaa1ef4da4478a4a912056cd3e1c55d4be295e0 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 25 Jun 2020 22:44:18 +0100 Subject: [PATCH 6/7] sub status --- app.js | 3 ++- data/bot/requests/subStatus.js | 17 ----------------- data/bot/requests/updateSubStatus.js | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 18 deletions(-) delete mode 100644 data/bot/requests/subStatus.js create mode 100644 data/bot/requests/updateSubStatus.js diff --git a/app.js b/app.js index 4d2f351..0f3af89 100644 --- a/app.js +++ b/app.js @@ -17,6 +17,7 @@ const bot_questions = require('./data/bot/questions') const bot_football = require('./data/bot/requests/football') const bot_joke = require('./data/bot/requests/joke') const bot_faq_subscription = require('./data/bot/faq/subscriptions') +const bot_subStatus = require('./data/bot/requests/updateSubStatus') const token = process.env.BOT_TOKEN; const name = process.env.BOT_NAME; @@ -65,7 +66,7 @@ bot.on('message', (msg) => { // listen for "what sub should i buy?" bot_questions.whatSubShouldIBuy(bot, msg, logger) bot_questions.subStatus(bot, msg, logger) - + bot_subStatus.setSubStatus(bot, msg, logger) // FAQ susbcription prices bot_faq_subscription.prices(bot, msg, logger) diff --git a/data/bot/requests/subStatus.js b/data/bot/requests/subStatus.js deleted file mode 100644 index 4fdda1b..0000000 --- a/data/bot/requests/subStatus.js +++ /dev/null @@ -1,17 +0,0 @@ -const fs = require('fs') -const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) - -module.exports = { - tellMe: (bot, msg, logger, name) => { - - const subStatus = "sub status"; - if (msg.text && msg.text.toString().toLowerCase().includes(subStatus)) { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription"); - - - bot.sendMessage(msg.chat.id, subs) - } - - - } -} \ No newline at end of file diff --git a/data/bot/requests/updateSubStatus.js b/data/bot/requests/updateSubStatus.js new file mode 100644 index 0000000..19409d2 --- /dev/null +++ b/data/bot/requests/updateSubStatus.js @@ -0,0 +1,27 @@ +const fs = require('fs') +const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) + +module.exports = { + setSubStatus: (bot, msg, logger, name) => { + + const setSub = "set sub"; + if (msg.text && msg.text.toString().toLowerCase().includes(setSub)) { + logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription"); + sub = msg.text.match(/\w+(?=( \w+){2}$)/g)[0] + status = msg.text.match(/\w+(?=( \w+){0}$)/g)[0] + if (status === "up") { + status = 1 + } else { + status = 0 + } + subs.forEach(function (element, index) { + if (element.SUB.toLowerCase() === sub) { + subs[index].STATUS = status; //set the value + } + }) + console.log(subs); + fs.writeFileSync('./data/group/subs.json', subs) + bot.sendMessage(msg.chat.id, sub + " sub updated") + } + } +} \ No newline at end of file From 3271f64c925ebcc7e3b19f2f983c098e56e43abc Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Fri, 26 Jun 2020 12:16:25 +0100 Subject: [PATCH 7/7] working sub and stauts --- data/bot/questions.js | 11 ++++-- data/bot/requests/updateSubStatus.js | 7 ++-- data/group/subs.json | 58 +--------------------------- 3 files changed, 11 insertions(+), 65 deletions(-) diff --git a/data/bot/questions.js b/data/bot/questions.js index 35bfa81..dd1542f 100644 --- a/data/bot/questions.js +++ b/data/bot/questions.js @@ -1,8 +1,9 @@ const fs = require('fs') -const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) module.exports = { whatSubShouldIBuy: (bot, msg, logger) => { + let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) + const whatSubShouldIBuy = "what sub should i buy" if (msg.text && msg.text.toString().toLowerCase().includes(whatSubShouldIBuy)) { @@ -12,13 +13,15 @@ module.exports = { } }, subStatus: (bot, msg, logger, name) => { + let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) + let string = "" const subStatus = "sub status"; if (msg.text && msg.text.toString().toLowerCase().includes(subStatus)) { logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription"); subs.forEach(element => { - if (element.COST != "X") { - if (element.STATUS === 1) { + if (element.STATUS != "X") { + if (element.STATUS === 1) { element.STATUS = "Up" } else { element.STATUS = "Down" @@ -29,7 +32,7 @@ module.exports = { } }); // console.log(string) - bot.sendMessage(msg.chat.id, string) + bot.sendMessage(msg.chat.id, string, { parse_mode: "HTML" }) } } } \ No newline at end of file diff --git a/data/bot/requests/updateSubStatus.js b/data/bot/requests/updateSubStatus.js index 19409d2..8632edb 100644 --- a/data/bot/requests/updateSubStatus.js +++ b/data/bot/requests/updateSubStatus.js @@ -1,13 +1,12 @@ const fs = require('fs') -const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) module.exports = { setSubStatus: (bot, msg, logger, name) => { - + let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) const setSub = "set sub"; if (msg.text && msg.text.toString().toLowerCase().includes(setSub)) { logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription"); - sub = msg.text.match(/\w+(?=( \w+){2}$)/g)[0] + sub = msg.text.match(/(?<=set sub )(.*)(?= to (up|down))/g)[0] status = msg.text.match(/\w+(?=( \w+){0}$)/g)[0] if (status === "up") { status = 1 @@ -20,7 +19,7 @@ module.exports = { } }) console.log(subs); - fs.writeFileSync('./data/group/subs.json', subs) + fs.writeFileSync('./data/group/subs.json', JSON.stringify(subs)) bot.sendMessage(msg.chat.id, sub + " sub updated") } } diff --git a/data/group/subs.json b/data/group/subs.json index 69eaff2..52540c6 100644 --- a/data/group/subs.json +++ b/data/group/subs.json @@ -1,57 +1 @@ -[ - { - "SUB": "Premium Plus", - "COST": 30, - "STATUS": 1 - }, - { - "SUB": "VIP", - "COST": 25, - "STATUS": 1 - }, - { - "SUB": "Old Premium", - "COST": 17, - "STATUS": 1 - }, - { - "SUB": "Bluemoon", - "COST": 15, - "STATUS": 1 - }, - { - "SUB": "KDB", - "COST": 14, - "STATUS": 1 - }, - { - "SUB": "Gold", - "COST": 13, - "STATUS": 1 - }, - { - "SUB": "Technoid", - "COST": 13, - "STATUS": 1 - }, - { - "SUB": "Bronze", - "COST": 10, - "STATUS": 1 - }, - { - "SUB": "SOL", - "COST": 10, - "STATUS": 0 - }, - { - "SUB": "Gambler", - "COST": "X", - "STATUS": 1 - }, - { - "SUB": "All of em", - "COST": "X", - "STATUS": "X" - } -] +[{"SUB":"Premium Plus","COST":30,"STATUS":1},{"SUB":"VIP","COST":25,"STATUS":1},{"SUB":"Old Premium","COST":17,"STATUS":1},{"SUB":"Bluemoon","COST":15,"STATUS":1},{"SUB":"KDB","COST":14,"STATUS":1},{"SUB":"Gold","COST":13,"STATUS":1},{"SUB":"Technoid","COST":13,"STATUS":1},{"SUB":"Bronze","COST":10,"STATUS":1},{"SUB":"SOL","COST":10,"STATUS":0},{"SUB":"New Premium (tvob)","COST":"X","STATUS":0},{"SUB":"Gambler","COST":"X","STATUS":1},{"SUB":"All of em","COST":"X","STATUS":"X"}] \ No newline at end of file