BBLBTV_Suzie/data/bot/lib/common.js

50 lines
2.1 KiB
JavaScript
Raw Normal View History

2020-06-29 22:43:41 +01:00
const decache = require('decache');
2020-06-29 21:32:14 +01:00
module.exports = {
2020-07-04 11:59:23 +01:00
chat: async (bot, msg, input, logger) => {
2020-07-01 19:10:05 +01:00
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " did - " + input);
2020-06-29 22:43:41 +01:00
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a> "
let commands = require('../../group/commands')
2020-07-04 11:59:23 +01:00
let chat = require('../../group/chat')
let jointArray = commands.concat(chat)
for (const x of jointArray) {
2020-06-29 22:43:41 +01:00
if (x.NAME === input) {
let n = x.NAME
let t = x.TEXT
for (const m of t) {
let a = userMention.concat(m)
await bot.sendMessage(msg.chat.id, a, { parse_mode: "HTML" })
}
decache('../../group/commands');
commands = require('../../group/commands')
2020-06-29 21:32:14 +01:00
}
2020-06-29 22:43:41 +01:00
}
2020-06-30 10:41:39 +01:00
},
2020-07-04 11:59:23 +01:00
faq: async (bot, msg, input, logger) => {
2020-07-01 19:10:05 +01:00
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked - " + input);
2020-06-30 10:41:39 +01:00
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a> "
let commands = require('../../group/commands')
2020-06-30 13:34:58 +01:00
let navigation = require('../../group/FAQ')
2020-07-04 11:59:23 +01:00
let jointArray = commands.concat(navigation)
2020-06-30 13:34:58 +01:00
for (const x of jointArray) {
2020-06-30 10:41:39 +01:00
if (x.NAME === input) {
let n = x.NAME
let t = x.TEXT
let m = JSON.parse(x.MENU)
2020-06-30 13:34:58 +01:00
for (const d of t) {
2020-06-30 10:41:39 +01:00
let a = userMention.concat(m)
2020-06-30 13:34:58 +01:00
await bot.sendMessage(msg.chat.id, d, {
2020-06-30 10:41:39 +01:00
parse_mode: "HTML",
"reply_markup": {
2020-06-30 13:34:58 +01:00
"keyboard": m
2020-06-30 10:41:39 +01:00
}
2020-06-30 13:34:58 +01:00
})
2020-06-30 10:41:39 +01:00
}
decache('../../group/commands');
2020-06-30 13:34:58 +01:00
decache('../../group/chat');
2020-06-30 10:41:39 +01:00
commands = require('../../group/commands')
2020-06-30 13:34:58 +01:00
commands = require('../../group/FAQ')
2020-06-30 10:41:39 +01:00
}
}
2020-06-29 21:32:14 +01:00
}
};