2017-09-21 13:57:49 +04:30
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Utils
|
2017-09-23 21:40:58 +03:30
|
|
|
const { link } = require('../../utils/tg');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
|
|
|
// Bot
|
2017-09-23 21:40:58 +03:30
|
|
|
const { replyOptions } = require('../../bot/options');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
|
|
|
// DB
|
2017-09-23 21:40:58 +03:30
|
|
|
const Warn = require('../../stores/warn');
|
|
|
|
const admins = require('../../stores/admin');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
2017-09-21 23:47:26 +04:30
|
|
|
const getWarnsHandler = async ({ message, reply }) => {
|
2017-09-21 13:57:49 +04:30
|
|
|
if (!await admins.isAdmin(message.from)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (!message.reply_to_message) {
|
|
|
|
return reply('Reply to a message');
|
|
|
|
}
|
|
|
|
let i = 0;
|
|
|
|
const theUser = message.reply_to_message.from;
|
2017-09-21 23:47:26 +04:30
|
|
|
return reply('Warns for ' + link(theUser) + ':\n\n' +
|
2017-09-21 13:57:49 +04:30
|
|
|
(await Warn.getWarns(theUser))
|
|
|
|
.map(x => ++i + '. ' + x)
|
2017-09-21 23:47:26 +04:30
|
|
|
.join('\n\n'), replyOptions);
|
2017-09-21 13:57:49 +04:30
|
|
|
};
|
|
|
|
|
2017-09-21 23:47:26 +04:30
|
|
|
module.exports = getWarnsHandler;
|