MiWatch_MiWatchBot/data/bot/faq/whatAppToUse.js

43 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2020-06-28 21:34:24 +01:00
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) => {
const whatAppShouldIUse = "- what app should i use?";
if (msg.text && msg.text.toString().toLowerCase() === whatAppShouldIUse) {
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
}
})
}
},
2020-06-28 21:43:40 +01:00
appSwitch: (bot, msg, logger) => {
2020-06-28 21:34:24 +01:00
let string = ""
2020-06-28 22:22:41 +01:00
if (subArray.some(v => msg.text.toString().includes(v))) {
2020-06-28 21:34:24 +01:00
var checkSub = msg.text.substring(2)
2020-06-28 22:22:41 +01:00
if (checkSub != "Home") {
2020-06-29 09:12:03 +01:00
subs.forEach(element => {
if (element.SUB === checkSub) {
element.APPS.forEach(element => {
let catString = element
string += '\n' + catString;
})
}
2020-06-28 21:34:24 +01:00
}
2020-06-29 09:12:03 +01:00
);
bot.sendMessage(msg.chat.id, checkSub + " can use -" + string + "\n\nAll can be downloaded from our FileLinked")
2020-06-28 21:34:24 +01:00
}
2020-06-29 09:12:03 +01:00
}
2020-06-28 21:34:24 +01:00
}
}