BBLBTV_Suzie/data/bot/lib/questions.js

73 lines
2.8 KiB
JavaScript
Raw Normal View History

2020-06-25 21:55:17 +01:00
const fs = require('fs')
2020-08-03 20:00:59 +01:00
const Nato = require('nato');
2020-06-25 19:45:38 +01:00
module.exports = {
whatSubShouldIBuy: (bot, msg, logger) => {
2020-06-26 12:16:25 +01:00
let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
2020-06-25 19:45:38 +01:00
const whatSubShouldIBuy = "what sub should i buy"
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 + "!");
}
2020-06-25 21:55:17 +01:00
},
2025-04-21 07:46:35 +00:00
subStatus: async (bot, msg, logger, notify = false) => {
2020-06-26 12:16:25 +01:00
let subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))
2020-06-25 21:55:17 +01:00
let string = ""
const subStatus = "sub status";
2020-08-03 20:00:59 +01:00
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription");
subs.forEach(element => {
if (element.STATUS != "X") {
if (element.STATUS === 1) {
element.STATUS = "Up"
} else {
element.STATUS = "Down"
2020-06-25 21:55:17 +01:00
}
2020-08-03 20:00:59 +01:00
let catString = element.SUB + " Is " + element.STATUS
// console.log(catString)
string += '\n' + catString;
}
});
// console.log(string)
2025-04-21 07:46:35 +00:00
data = await bot.sendMessage(msg.chat.id, string, { parse_mode: "HTML", disable_notification: notify })
if (notify == true) {
bot.pinChatMessage(process.env.CHANNEL_ID, data.message_id)
}
2020-08-03 20:00:59 +01:00
},
adminStatus: (bot, msg, logger, name) => {
let admins = JSON.parse(fs.readFileSync('./data/group/admins.json', 'utf8'))
let string = ""
const subStatus = "sub status";
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription");
admins.forEach(element => {
if (element.STATUS != "X") {
if (element.STATUS === 1) {
element.STATUS = "Here"
} else {
element.STATUS = "Away"
}
let catString = element.NAME + " Is " + element.STATUS
// console.log(catString)
string += '\n' + catString;
}
});
// console.log(string)
bot.sendMessage(msg.chat.id, string, { parse_mode: "HTML" })
},
password: (bot, msg, match, logger) => {
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked how to get a subscription");
// console.log(string)
2025-04-21 07:46:35 +00:00
2020-08-03 20:00:59 +01:00
let sendString = new Nato(match)
2025-04-21 07:46:35 +00:00
bot.sendMessage(msg.chat.id, sendString.nato, {
2020-08-03 20:00:59 +01:00
force_reply: true,
parse_mode: "HTML"
2025-04-21 07:46:35 +00:00
})
2020-08-03 20:00:59 +01:00
}
}