Merge pull request #77 from bb010g/record-mod-reason

Record moderation reasoning to log when possible.
This commit is contained in:
Drew 2016-08-26 23:26:59 -04:00 committed by GitHub
commit a05ad2b4ac

View File

@ -223,7 +223,7 @@ function administration:get_targets(msg, config)
target.name = utilities.build_name(target.first_name, target.last_name) target.name = utilities.build_name(target.first_name, target.last_name)
target.id_str = tostring(target.id) target.id_str = tostring(target.id)
target.rank = administration.get_rank(self, target.id, msg.chat.id, config) target.rank = administration.get_rank(self, target.id, msg.chat.id, config)
return { target } return { target }, utilities.input(msg.text)
else else
local input = utilities.input(msg.text) local input = utilities.input(msg.text)
if input then if input then
@ -809,8 +809,9 @@ function administration.init_command(self_, config_)
doc = 'Removes a user from the group. The target may be specified via reply, username, or ID.', doc = 'Removes a user from the group. The target may be specified via reply, username, or ID.',
action = function(self, msg, group, config) action = function(self, msg, group, config)
local targets = administration.get_targets(self, msg, config) local targets, reason = administration.get_targets(self, msg, config)
if targets then if targets then
reason = reason and ': ' .. utilities.trim(reason) or ''
local output = '' local output = ''
local s = drua.sopen() local s = drua.sopen()
for _, target in ipairs(targets) do for _, target in ipairs(targets) do
@ -820,7 +821,7 @@ function administration.init_command(self_, config_)
output = output .. target.name .. ' is too privileged to be kicked.\n' output = output .. target.name .. ' is too privileged to be kicked.\n'
else else
output = output .. target.name .. ' has been kicked.\n' output = output .. target.name .. ' has been kicked.\n'
administration.kick_user(self, msg.chat.id, target.id, 'kicked by ' .. utilities.build_name(msg.from.first_name, msg.from.last_name) .. ' [' .. msg.from.id .. ']', config, s) administration.kick_user(self, msg.chat.id, target.id, 'kicked by ' .. utilities.build_name(msg.from.first_name, msg.from.last_name) .. ' [' .. msg.from.id .. ']' .. reason, config, s)
if msg.chat.type == 'supergroup' then if msg.chat.type == 'supergroup' then
bindings.unbanChatMember{ chat_id = msg.chat.id, user_id = target.id } bindings.unbanChatMember{ chat_id = msg.chat.id, user_id = target.id }
end end
@ -843,8 +844,9 @@ function administration.init_command(self_, config_)
doc = 'Bans a user from the group. The target may be specified via reply, username, or ID.', doc = 'Bans a user from the group. The target may be specified via reply, username, or ID.',
action = function(self, msg, group, config) action = function(self, msg, group, config)
local targets = administration.get_targets(self, msg, config) local targets, reason = administration.get_targets(self, msg, config)
if targets then if targets then
reason = reason and ': ' .. utilities.trim(reason) or ''
local output = '' local output = ''
local s = drua.sopen() local s = drua.sopen()
for _, target in ipairs(targets) do for _, target in ipairs(targets) do
@ -856,7 +858,7 @@ function administration.init_command(self_, config_)
output = output .. target.name .. ' is too privileged to be banned.\n' output = output .. target.name .. ' is too privileged to be banned.\n'
else else
output = output .. target.name .. ' has been banned.\n' output = output .. target.name .. ' has been banned.\n'
administration.kick_user(self, msg.chat.id, target.id, 'banned by ' .. utilities.build_name(msg.from.first_name, msg.from.last_name) .. ' [' .. msg.from.id .. ']', config, s) administration.kick_user(self, msg.chat.id, target.id, 'banned by ' .. utilities.build_name(msg.from.first_name, msg.from.last_name) .. ' [' .. msg.from.id .. ']' .. reason, config, s)
group.mods[target.id_str] = nil group.mods[target.id_str] = nil
group.bans[target.id_str] = true group.bans[target.id_str] = true
end end
@ -1306,8 +1308,9 @@ Use this command to configure the point values for each message type. When a use
doc = 'Bans a user from all groups. The target may be specified via reply, username, or ID.', doc = 'Bans a user from all groups. The target may be specified via reply, username, or ID.',
action = function(self, msg, group, config) action = function(self, msg, group, config)
local targets = administration.get_targets(self, msg, config) local targets, reason = administration.get_targets(self, msg, config)
if targets then if targets then
reason = reason and ': ' .. utilities.trim(reason) or ''
local output = '' local output = ''
local s = drua.sopen() local s = drua.sopen()
for _, target in ipairs(targets) do for _, target in ipairs(targets) do
@ -1319,8 +1322,8 @@ Use this command to configure the point values for each message type. When a use
output = output .. target.name .. ' is too privileged to be globally banned.\n' output = output .. target.name .. ' is too privileged to be globally banned.\n'
else else
if group then if group then
local reason = 'hammered by ' .. utilities.build_name(msg.from.first_name, msg.from.last_name) .. ' [' .. msg.from.id .. ']' local reason_ = 'hammered by ' .. utilities.build_name(msg.from.first_name, msg.from.last_name) .. ' [' .. msg.from.id .. ']' .. reason
administration.kick_user(self, msg.chat.id, target.id, reason, config) administration.kick_user(self, msg.chat.id, target.id, reason_, config)
end end
for k,v in pairs(self.database.administration.groups) do for k,v in pairs(self.database.administration.groups) do
if not v.flags[6] then if not v.flags[6] then