Karl a662c68ecf
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 19s
initial rework and cleanup
2025-07-30 09:51:32 +01:00

48 lines
1.9 KiB
JavaScript

const utils = require('./utils');
module.exports = {
commands: async (bot, msg, input, logger) => {
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " did - " + input);
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a> "
let commands = utils.loadCommands();
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" })
}
commands = utils.loadCommands();
}
}
},
chat: async (bot, msg, input, logger) => {
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " asked - " + input);
const userMention = "<a href=\"tg:\/\/user?id=" + msg.from.id + "\">@" + msg.from.first_name + "<\/a> "
let commands = utils.loadCommands();
let navigation = utils.loadFAQ();
let chat = utils.loadChat();
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
},
disable_web_page_preview: true
})
}
commands = utils.loadCommands();
navigation = utils.loadFAQ();
}
}
}
};