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",