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) => {
|
// bot.onText(/^(\/start|\/help|- Home)$/, (msg) => {
|
||||||
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Started a Chat with me");
|
// 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(() => {
|
// 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, "I'm the " + channel + " Bot, and can answer your questions").then(() => {
|
||||||
return bot.sendMessage(msg.chat.id, "Please use the buttons below to navigate", {
|
// return bot.sendMessage(msg.chat.id, "Please use the buttons below to navigate", {
|
||||||
"reply_markup": {
|
// "reply_markup": {
|
||||||
"keyboard": [
|
// "keyboard": [
|
||||||
["- FAQ", "- Applications"]
|
// ["- FAQ", "- Applications"]
|
||||||
]
|
// ]
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
|
||||||
|
|
||||||
bot.onText(/^- FAQ$/, (msg) => {
|
bot.onText(/^- FAQ$/, (msg) => {
|
||||||
|
@ -16,5 +16,27 @@ module.exports = {
|
|||||||
commands = require('../../group/commands')
|
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,
|
'x-rapidapi-key': process.env.RAPIDAPI_API_KEY,
|
||||||
useQueryString: true
|
useQueryString: true
|
||||||
},
|
},
|
||||||
// ttl: 18000 //5 hours
|
|
||||||
};
|
};
|
||||||
|
|
||||||
request(options, function (error, response, body) {
|
request(options, function (error, response, body) {
|
||||||
// console.log(response)
|
|
||||||
|
|
||||||
if (error) throw new Error(error);
|
if (error) throw new Error(error);
|
||||||
let jsonBody = JSON.parse(body)
|
let jsonBody = JSON.parse(body)
|
||||||
bot.sendMessage(msg.chat.id, jsonBody.content)
|
bot.sendMessage(msg.chat.id, jsonBody.content)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
const name = process.env.BOT_NAME
|
||||||
|
const channel = process.env.CHANNEL
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
"NAME": "/help",
|
"NAME": "/help",
|
||||||
@ -9,13 +12,37 @@ const commands = [
|
|||||||
"NAME": "/sub_status",
|
"NAME": "/sub_status",
|
||||||
"TEXT": []
|
"TEXT": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"NAME": "#FAQ",
|
||||||
|
"TEXT": [
|
||||||
|
"Please use the buttons below to navigate"
|
||||||
|
],
|
||||||
|
"MENU": '[["- FAQ", "- Applications"]]'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"NAME": "/start",
|
"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;
|
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)
|
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")) {
|
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