2018-05-04 14:21:51 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const warn = require('../actions/warn');
|
2018-11-20 11:47:30 +05:30
|
|
|
const ban = require('../actions/ban');
|
2019-01-31 20:19:39 +01:00
|
|
|
const batchBan = require('../actions/batchBan');
|
2018-11-20 11:47:30 +05:30
|
|
|
const { scheduleDeletion } = require('../utils/tg');
|
2018-05-04 14:21:51 +02:00
|
|
|
|
2018-11-20 11:47:30 +05:30
|
|
|
const {
|
|
|
|
warnInlineKeyboard,
|
|
|
|
deleteWarnsAfter = false,
|
|
|
|
deleteBansAfter = false,
|
|
|
|
} = require('../config');
|
2018-05-04 14:21:51 +02:00
|
|
|
|
2018-11-20 11:47:30 +05:30
|
|
|
const normalisedDeleteWarnsAfter = typeof deleteWarnsAfter === 'object'
|
|
|
|
? { auto: false, manual: false, ...deleteWarnsAfter }
|
|
|
|
: { auto: deleteWarnsAfter, manual: deleteWarnsAfter };
|
|
|
|
|
|
|
|
const reply_markup = { inline_keyboard: warnInlineKeyboard };
|
2018-05-04 14:21:51 +02:00
|
|
|
|
|
|
|
module.exports = {
|
2018-11-20 11:47:30 +05:30
|
|
|
async ban({ admin, reason, userToBan }) {
|
|
|
|
const banMessage = await ban({ admin, reason, userToBan });
|
|
|
|
return this.replyWithHTML(banMessage)
|
|
|
|
.then(scheduleDeletion(deleteBansAfter));
|
|
|
|
},
|
2019-01-31 20:19:39 +01:00
|
|
|
batchBan({ admin, reason, targets }) {
|
|
|
|
return batchBan({ admin, reason, targets })
|
|
|
|
.then(this.replyWithHTML)
|
|
|
|
.then(scheduleDeletion(deleteBansAfter));
|
|
|
|
},
|
2019-05-31 17:02:00 +02:00
|
|
|
async warn({ admin, amend, reason, userToWarn, mode }) {
|
|
|
|
const warnMessage = await warn({ admin, amend, reason, userToWarn });
|
2018-11-20 11:47:30 +05:30
|
|
|
return this.replyWithHTML(warnMessage, { reply_markup })
|
|
|
|
.then(scheduleDeletion(normalisedDeleteWarnsAfter[mode]));
|
2018-05-04 14:21:51 +02:00
|
|
|
},
|
2020-02-19 08:11:32 +01:00
|
|
|
|
|
|
|
replyWithCopy(content, options) {
|
|
|
|
return this.tg.sendCopy(this.chat.id, content, options);
|
|
|
|
},
|
2018-05-04 14:21:51 +02:00
|
|
|
};
|