quick commit

This commit is contained in:
karl.hudgell 2020-06-30 10:41:39 +01:00
parent a021c61222
commit c84bc6f03b
5 changed files with 70 additions and 20 deletions

28
app.js
View File

@ -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) => {

View File

@ -16,5 +16,27 @@ module.exports = {
commands = require('../../group/commands')
}
}
},
chat: async (bot, msg, input) => {
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
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')
}
}
}
};

View File

@ -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)

View File

@ -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"]
// ]
// }
// })
// })
// })
// })

View File

@ -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")
}
})