BBLBTV_Suzie/data/bot/functions/faq/whatAppToUse.js
karl.hudgell 7c650f59e3 quick fix
2020-06-30 14:29:20 +01:00

40 lines
1.3 KiB
JavaScript

const fs = require('fs')
const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
var subArray = []
subs.forEach(element => {
if (element.COST != "X") {
let arr = ["- " + element.SUB]
subArray.push(arr)
}
});
subArray.push(["- Home"])
module.exports = {
main: (bot, msg, logger) => {
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked what app to use");
bot.sendMessage(msg.chat.id, "What Subscription do you have?", {
"reply_markup": {
"keyboard": subArray
}
})
},
appSwitch: (bot, msg, logger) => {
let string = ""
if (subArray.some(v => msg.text && msg.text.toString().includes(v))) {
var checkSub = msg.text.substring(2)
if (checkSub != "Home") {
subs.forEach(element => {
if (element.SUB === checkSub) {
element.APPS.forEach(element => {
let catString = element
string += '\n' + catString;
})
}
}
);
bot.sendMessage(msg.chat.id, checkSub + " can use -" + string + "\n\nAll can be downloaded from our FileLinked")
}
}
}
}