2017-09-23 20:57:32 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Utils
|
2017-09-23 21:29:09 +02:00
|
|
|
const { link } = require('../../utils/tg');
|
2017-09-23 20:57:32 +02:00
|
|
|
|
|
|
|
// DB
|
2017-09-23 21:29:09 +02:00
|
|
|
const { allAdmins } = require('../../stores/admin');
|
2017-09-23 20:57:32 +02:00
|
|
|
|
|
|
|
const reportHandler = async ctx => {
|
|
|
|
const msg = ctx.message;
|
|
|
|
if (!msg.reply_to_message) {
|
|
|
|
return ctx.reply('Reply to message you\'d like to report');
|
|
|
|
}
|
|
|
|
const admins = await allAdmins();
|
|
|
|
const adminObjects = admins.map(user => ({
|
|
|
|
first_name: '⭐️', // small hack to be able to use link function
|
|
|
|
id: user.user_id,
|
|
|
|
}));
|
|
|
|
const stars = adminObjects.map(link).join('');
|
|
|
|
const s = `${link(ctx.from)} reported the message to admins: ${stars}`;
|
|
|
|
return ctx.replyWithHTML(s, {
|
|
|
|
reply_to_message_id: msg.reply_to_message.message_id
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = reportHandler;
|