2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-24 19:07:17 +00:00

32 lines
817 B
JavaScript
Raw Normal View History

2017-09-23 20:57:32 +02:00
'use strict';
// Utils
const { link } = require('../../utils/tg');
2017-09-23 20:57:32 +02:00
2017-09-24 14:32:27 +03:30
// Bot
const { replyOptions } = require('../../bot/options');
2017-09-23 20:57:32 +02:00
// DB
2017-09-27 00:11:20 +03:30
const { getAdmins } = require('../../stores/user');
2017-09-23 20:57:32 +02:00
const reportHandler = async ctx => {
const msg = ctx.message;
if (!msg.reply_to_message) {
2017-09-24 14:32:27 +03:30
return ctx.reply(' <b>Reply to message you\'d like to report</b>',
replyOptions);
2017-09-23 20:57:32 +02:00
}
2017-09-27 00:11:20 +03:30
const admins = await getAdmins();
2017-09-23 20:57:32 +02:00
const adminObjects = admins.map(user => ({
first_name: '⭐️', // small hack to be able to use link function
id: user.id,
2017-09-23 20:57:32 +02:00
}));
const stars = adminObjects.map(link).join('');
2017-09-24 14:32:27 +03:30
const s = `📋 ${link(ctx.from)} <b>reported the message to admins:</b> ` +
`${stars}`;
2017-09-23 20:57:32 +02:00
return ctx.replyWithHTML(s, {
reply_to_message_id: msg.reply_to_message.message_id
});
};
module.exports = reportHandler;