get sub status

This commit is contained in:
karl.hudgell 2020-06-25 21:55:17 +01:00
parent 51af65dd31
commit 0d88c20960
4 changed files with 44 additions and 14 deletions

14
app.js
View File

@ -64,20 +64,12 @@ bot.on('message', (msg) => {
bot_chat.fOff(bot, msg, logger, name) bot_chat.fOff(bot, msg, logger, name)
// listen for "what sub should i buy?" // listen for "what sub should i buy?"
bot_questions.whatSubShouldIBuy(bot, msg, logger) bot_questions.whatSubShouldIBuy(bot, msg, logger)
bot_questions.subStatus(bot, msg, logger)
// FAQ susbcription prices
bot_faq_subscription.prices(bot, msg, logger) bot_faq_subscription.prices(bot, msg, logger)
const howToSignUp = "- how to get a subscription?"; const howToSignUp = "- how to get a subscription?";
if (msg.text && msg.text.toString().toLowerCase() === howToSignUp) { if (msg.text && msg.text.toString().toLowerCase() === howToSignUp) {
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription"); logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription");

View File

@ -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 = { module.exports = {
whatSubShouldIBuy: (bot, msg, logger) => { whatSubShouldIBuy: (bot, msg, logger) => {
const whatSubShouldIBuy = "what sub should i buy" 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)) { 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"); 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)]; const randomSub = subs[Math.floor(Math.random() * subs.length)];
bot.sendMessage(msg.chat.id, randomSub.SUB + "!"); 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)
}
} }
} }

View File

@ -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)
}
}
}

View File

@ -42,7 +42,7 @@
{ {
"SUB": "SOL", "SUB": "SOL",
"COST": 10, "COST": 10,
"STATUS": "X" "STATUS": 0
}, },
{ {
"SUB": "Gambler", "SUB": "Gambler",