sub status
This commit is contained in:
parent
0d88c20960
commit
bcaa1ef4da
3
app.js
3
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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
27
data/bot/requests/updateSubStatus.js
Normal file
27
data/bot/requests/updateSubStatus.js
Normal file
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user