CampFirePlay/commands/report.js
Degradin baa0b5f3a9 global refactoring
Все переведено в модули
2023-10-08 23:43:12 +03:00

31 lines
1.0 KiB
JavaScript

const {
Telegraf,
Markup
} = require('telegraf')
const bot = new Telegraf(process.env.BOT_TOKEN)
const {
UserModel,
ReportModel,
adminList
} = require('/workspace/degradin/Dev/Telegram/CampFire Play/config')
const shortid = require('shortid');
module.exports = async (ctx) => {
let user = await UserModel.findByPk(ctx.from.id)
ctx.args = ctx.update.message.text.split(' ')
if (!ctx.args[1]) return ctx.reply(`/report [Текст обращения]`)
let uID = shortid.generate()
await ReportModel.create({
uid: uID,
author: user.telegram_id,
text: ctx.payload,
status: 1
})
let report = await ReportModel.findOne({
where: {
uid: uID
}
})
await bot.telegram.sendMessage(adminList[0], `Обращение от пользователя ${user.username}\nТекст обращения:\n${ctx.payload}\n\nДля ответа /answer ${report.id} [Ответ]`)
return await ctx.reply(`Обращение #${report.id}[${report.uid}] создано.`)
}