50 lines
2.1 KiB
JavaScript
Raw Normal View History

2020-06-30 16:25:55 +00:00
const decache = require('decache');
module.exports = {
commands: async (bot, msg, input) => {
2020-07-01 18:13:04 +00:00
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " did - " + input);
2020-06-30 16:25:55 +00:00
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a> "
let commands = require('../../group/commands')
for (const x of commands) {
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')
}
}
},
chat: async (bot, msg, input) => {
2020-07-01 18:13:04 +00:00
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked - " + input);
2020-06-30 16:25:55 +00:00
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a> "
let commands = require('../../group/commands')
let navigation = require('../../group/FAQ')
let chat = require('../../group/chat')
let jointArray = commands.concat(navigation, chat)
for (const x of jointArray) {
if (x.NAME === input) {
let n = x.NAME
let t = x.TEXT
let m = JSON.parse(x.MENU)
for (const d of t) {
let a = userMention.concat(m)
await bot.sendMessage(msg.chat.id, d, {
parse_mode: "HTML",
"reply_markup": {
"keyboard": m
}
})
}
decache('../../group/commands');
decache('../../group/chat');
commands = require('../../group/commands')
commands = require('../../group/FAQ')
}
}
}
};