diff --git a/app.js b/app.js index 7fddc57..1cd6722 100644 --- a/app.js +++ b/app.js @@ -288,20 +288,20 @@ Do not clear data, otherwise you will have to enter your sub details into the ap } }), - bot.onText(/^(\/start|\/help|- Home)$/, (msg) => { - logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Started a Chat with me"); - bot.sendMessage(msg.chat.id, "I'm " + name).then(() => { - return bot.sendMessage(msg.chat.id, "I'm the " + channel + " Bot, and can answer your questions").then(() => { - return bot.sendMessage(msg.chat.id, "Please use the buttons below to navigate", { - "reply_markup": { - "keyboard": [ - ["- FAQ", "- Applications"] - ] - } - }) - }) - }) - }) + // bot.onText(/^(\/start|\/help|- Home)$/, (msg) => { + // logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Started a Chat with me"); + // bot.sendMessage(msg.chat.id, "I'm " + name).then(() => { + // return bot.sendMessage(msg.chat.id, "I'm the " + channel + " Bot, and can answer your questions").then(() => { + // return bot.sendMessage(msg.chat.id, "Please use the buttons below to navigate", { + // "reply_markup": { + // "keyboard": [ + // ["- FAQ", "- Applications"] + // ] + // } + // }) + // }) + // }) + // }) bot.onText(/^- FAQ$/, (msg) => { diff --git a/data/bot/lib/common.js b/data/bot/lib/common.js index 9859cf3..0f71d66 100644 --- a/data/bot/lib/common.js +++ b/data/bot/lib/common.js @@ -16,5 +16,27 @@ module.exports = { commands = require('../../group/commands') } } + }, + chat: async (bot, msg, input) => { + const userMention = "@" + 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 + let m = JSON.parse(x.MENU) + for (const m of t) { + let a = userMention.concat(m) + await bot.sendMessage(msg.chat.id, m, { + parse_mode: "HTML", + "reply_markup": { + "keyboard": m + } + }) + } + decache('../../group/commands'); + commands = require('../../group/commands') + } + } } }; \ No newline at end of file diff --git a/data/bot/lib/requests.js b/data/bot/lib/requests.js index fb2db14..db7a0b0 100644 --- a/data/bot/lib/requests.js +++ b/data/bot/lib/requests.js @@ -53,12 +53,9 @@ module.exports = { 'x-rapidapi-key': process.env.RAPIDAPI_API_KEY, useQueryString: true }, - // ttl: 18000 //5 hours }; request(options, function (error, response, body) { - // console.log(response) - if (error) throw new Error(error); let jsonBody = JSON.parse(body) bot.sendMessage(msg.chat.id, jsonBody.content) diff --git a/data/group/commands.js b/data/group/commands.js index b44b4fe..d21c058 100644 --- a/data/group/commands.js +++ b/data/group/commands.js @@ -1,3 +1,6 @@ +const name = process.env.BOT_NAME +const channel = process.env.CHANNEL + const commands = [ { "NAME": "/help", @@ -9,13 +12,37 @@ const commands = [ "NAME": "/sub_status", "TEXT": [] }, + { + "NAME": "#FAQ", + "TEXT": [ + "Please use the buttons below to navigate" + ], + "MENU": '[["- FAQ", "- Applications"]]' + }, { "NAME": "/start", - "TEXT": [] + "TEXT": [ + "I'm " + name, + "I'm the " + channel + " Bot, and can answer your questions", + "Please type #FAQ to open the buttons", + ] } ] module.exports = commands; - +// bot.onText(/^(\/start|\/help|- Home)$/, (msg) => { +// logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Started a Chat with me"); +// bot.sendMessage(msg.chat.id, "I'm " + name).then(() => { +// return bot.sendMessage(msg.chat.id, "I'm the " + channel + " Bot, and can answer your questions").then(() => { +// return bot.sendMessage(msg.chat.id, "Please use the buttons below to navigate", { +// "reply_markup": { +// "keyboard": [ +// ["- FAQ", "- Applications"] +// ] +// } +// }) +// }) +// }) +// }) diff --git a/test.js b/test.js index ac17795..764ffbb 100644 --- a/test.js +++ b/test.js @@ -38,8 +38,12 @@ bot.on('message', (msg) => { requests.joke(bot, msg, logger) } + if (msg.text && msg.text.toString().includes("#FAQ")) { + common.chat(bot, msg, "#FAQ") + } + if (msg.text && msg.text.toString().includes("/start")) { - common.commands(bot, msg, logger) + common.chat(bot, msg, "/start") } }) \ No newline at end of file