quick commit
This commit is contained in:
parent
a021c61222
commit
c84bc6f03b
28
app.js
28
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) => {
|
||||
|
@ -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')
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
@ -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)
|
||||
|
@ -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"]
|
||||
// ]
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
|
||||
|
6
test.js
6
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")
|
||||
}
|
||||
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user