BBLBTV_Suzie/data/bot/lib/common.js

48 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-06-29 22:43:41 +01:00
const decache = require('decache');
2020-06-29 21:32:14 +01:00
module.exports = {
2020-06-29 22:43:41 +01:00
commands: 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
for (const m of t) {
let a = userMention.concat(m)
await bot.sendMessage(msg.chat.id, a, { parse_mode: "HTML" })
}
decache('../../group/commands');
commands = require('../../group/commands')
2020-06-29 21:32:14 +01:00
}
2020-06-29 22:43:41 +01:00
}
2020-06-30 10:41:39 +01:00
},
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')
2020-06-30 13:34:58 +01:00
let navigation = require('../../group/FAQ')
let chat = require('../../group/chat')
let jointArray = commands.concat(navigation, chat)
for (const x of jointArray) {
2020-06-30 10:41:39 +01:00
if (x.NAME === input) {
let n = x.NAME
let t = x.TEXT
let m = JSON.parse(x.MENU)
2020-06-30 13:34:58 +01:00
for (const d of t) {
2020-06-30 10:41:39 +01:00
let a = userMention.concat(m)
2020-06-30 13:34:58 +01:00
await bot.sendMessage(msg.chat.id, d, {
2020-06-30 10:41:39 +01:00
parse_mode: "HTML",
"reply_markup": {
2020-06-30 13:34:58 +01:00
"keyboard": m
2020-06-30 10:41:39 +01:00
}
2020-06-30 13:34:58 +01:00
})
2020-06-30 10:41:39 +01:00
}
decache('../../group/commands');
2020-06-30 13:34:58 +01:00
decache('../../group/chat');
2020-06-30 10:41:39 +01:00
commands = require('../../group/commands')
2020-06-30 13:34:58 +01:00
commands = require('../../group/FAQ')
2020-06-30 10:41:39 +01:00
}
}
2020-06-29 21:32:14 +01:00
}
};