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

26 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const {
Telegraf
} = require('telegraf')
const bot = new Telegraf(process.env.BOT_TOKEN)
const {
UserModel,
ReportModel
} = require('/workspace/degradin/Dev/Telegram/CampFire Play/config')
module.exports = async (ctx) => {
let user = await UserModel.findByPk(ctx.from.id)
if(user.status != 'admin') return await ctx.reply(`Admin Only.`)
ctx.args = ctx.update.message.text.split(' ')
if (!ctx.args[1]) return ctx.reply(`Нужен номер обращения`)
let report = await ReportModel.findByPk(ctx.args[1])
if (report === null) return await ctx.reply(`Нет обращения с таким ID.`)
if (report.status == 0) return await ctx.reply(`Данное обращение уже закрыто.`)
let answer = ctx.args
answer.shift()
answer.shift()
answer = answer.join(' ')
await bot.telegram.sendMessage(report.author, `Ответ на обращение #${report.id}[${report.uid}]\n\n` + answer)
report.status = 0
report.save()
return await ctx.reply(`Ответ отправлен, обращение закрыто!`)
}