Some moderation output changes. May rework the plugin later.

This commit is contained in:
topkecleon 2016-02-22 22:58:32 -05:00
parent 971b27335b
commit 1b95a1e0c9
3 changed files with 47 additions and 42 deletions

View File

@ -12,7 +12,6 @@ return {
simsimi_trial = true, simsimi_trial = true,
time_offset = 0, time_offset = 0,
lang = 'en', lang = 'en',
antisquig = false,
-- If you change this, make sure you also modify launch-tg.sh. -- If you change this, make sure you also modify launch-tg.sh.
cli_port = 4567, cli_port = 4567,
admin = 00000000, admin = 00000000,
@ -28,10 +27,6 @@ Send /help to get started.
results = 'No results found.', results = 'No results found.',
argument = 'Invalid argument.', argument = 'Invalid argument.',
syntax = 'Invalid syntax.', syntax = 'Invalid syntax.',
antisquig = 'This group is English only.',
moderation = 'I do not moderate this group.',
not_mod = 'This command must be run by a moderator.',
not_admin = 'This command must be run by an administrator.',
chatter_connection = 'I don\'t feel like talking right now.', chatter_connection = 'I don\'t feel like talking right now.',
chatter_response = 'I don\'t know what to say to that.' chatter_response = 'I don\'t know what to say to that.'
}, },
@ -65,8 +60,15 @@ Send /help to get started.
admins = { admins = {
['00000000'] = 'You' ['00000000'] = 'You'
}, },
errors = {
antisquig = 'This group is English-only.',
moderation = 'I do not moderate this group.',
not_mod = 'This command must be run by a moderator.',
not_admin = 'This command must be run by an administrator.',
},
admin_group = -00000000, admin_group = -00000000,
realm_name = 'My Realm' realm_name = 'My Realm',
antisquig = false
}, },
plugins = { plugins = {
'control.lua', 'control.lua',

View File

@ -930,7 +930,7 @@ for i,v in ipairs(commands) do
end end
end end
help_text = '' local help_text = ''
for i = 1, 5 do for i = 1, 5 do
help_text = help_text .. '*' .. ranks[i] .. ':*\n' help_text = help_text .. '*' .. ranks[i] .. ':*\n'
for ind,val in pairs(commands) do for ind,val in pairs(commands) do

View File

@ -7,7 +7,7 @@ if not database.moderation then
database.moderation = {} database.moderation = {}
end end
antisquig = {} local antisquig = {}
local commands = { local commands = {
@ -15,20 +15,22 @@ local commands = {
if not database.moderation[msg.chat.id_str] then return end if not database.moderation[msg.chat.id_str] then return end
local message = [[ local output = [[
/modlist - List the moderators and administrators of this group. *Users:*
Moderator commands: /modlist - List the moderators and administrators of this group.
/modkick - Kick a user from this group. *Moderators:*
/modban - Ban a user from this group. /modkick - Kick a user from this group.
Administrator commands: /modban - Ban a user from this group.
/modadd - Add this group to the moderation system. *Administrators:*
/modrem - Remove this group from the moderation system. /modadd - Add this group to the moderation system.
/modprom - Promote a user to a moderator. /modrem - Remove this group from the moderation system.
/moddem - Demote a moderator to a user. /modprom - Promote a user to a moderator.
/modcast - Send a broadcast to every moderated group. /moddem - Demote a moderator to a user.
/modcast - Send a broadcast to every moderated group.
]] ]]
output = output:gsub('\t', '')
return message sendMessage(msg.chat.id, output, true, nil, true)
end, end,
@ -36,29 +38,29 @@ local commands = {
if not database.moderation[msg.chat.id_str] then return end if not database.moderation[msg.chat.id_str] then return end
local message = '' local output = ''
for k,v in pairs(database.moderation[msg.chat.id_str]) do for k,v in pairs(database.moderation[msg.chat.id_str]) do
message = message .. ' - ' .. v .. ' (' .. k .. ')\n' output = output .. ' ' .. v .. ' (' .. k .. ')\n'
end end
if message ~= '' then if output ~= '' then
message = 'Moderators for ' .. msg.chat.title .. ':\n' .. message .. '\n' output = '*Moderators for* _' .. msg.chat.title .. '_ *:*\n' .. output
end end
message = message .. 'Administrators for ' .. config.moderation.realm_name .. ':\n' output = output .. '*Administrators for* _' .. config.moderation.realm_name .. '_ *:*\n'
for k,v in pairs(config.moderation.admins) do for k,v in pairs(config.moderation.admins) do
message = message .. ' - ' .. v .. ' (' .. k .. ')\n' output = output .. ' ' .. v .. ' (' .. k .. ')\n'
end end
return message sendMessage(msg.chat.id, output, true, nil, true)
end, end,
['^/modcast[@'..bot.username..']*'] = function(msg) ['^/modcast[@'..bot.username..']*'] = function(msg)
local message = msg.text:input() local output = msg.text:input()
if not message then if not output then
return 'You must include a message.' return 'You must include a message.'
end end
@ -67,11 +69,13 @@ local commands = {
end end
if not config.moderation.admins[msg.from.id_str] then if not config.moderation.admins[msg.from.id_str] then
return config.errors.not_admin return config.moderation.errors.not_admin
end end
output = '*Admin Broadcast:*\n' .. output
for k,v in pairs(database.moderation) do for k,v in pairs(database.moderation) do
sendMessage(k, message) sendMessage(k, output, true, nil, true)
end end
return 'Your broadcast has been sent.' return 'Your broadcast has been sent.'
@ -81,7 +85,7 @@ local commands = {
['^/modadd[@'..bot.username..']*$'] = function(msg) ['^/modadd[@'..bot.username..']*$'] = function(msg)
if not config.moderation.admins[msg.from.id_str] then if not config.moderation.admins[msg.from.id_str] then
return config.errors.not_admin return config.moderation.errors.not_admin
end end
if database.moderation[msg.chat.id_str] then if database.moderation[msg.chat.id_str] then
@ -96,11 +100,11 @@ local commands = {
['^/modrem[@'..bot.username..']*$'] = function(msg) ['^/modrem[@'..bot.username..']*$'] = function(msg)
if not config.moderation.admins[msg.from.id_str] then if not config.moderation.admins[msg.from.id_str] then
return config.errors.not_admin return config.moderation.errors.not_admin
end end
if not database.moderation[msg.chat.id_str] then if not database.moderation[msg.chat.id_str] then
return config.errors.moderation return config.moderation.errors.moderation
end end
database.moderation[msg.chat.id_str] = nil database.moderation[msg.chat.id_str] = nil
@ -113,7 +117,7 @@ local commands = {
if not database.moderation[msg.chat.id_str] then return end if not database.moderation[msg.chat.id_str] then return end
if not config.moderation.admins[msg.from.id_str] then if not config.moderation.admins[msg.from.id_str] then
return config.errors.not_admin return config.moderation.errors.not_admin
end end
if not msg.reply_to_message then if not msg.reply_to_message then
@ -142,7 +146,7 @@ local commands = {
if not database.moderation[msg.chat.id_str] then return end if not database.moderation[msg.chat.id_str] then return end
if not config.moderation.admins[msg.from.id_str] then if not config.moderation.admins[msg.from.id_str] then
return config.errors.not_admin return config.moderation.errors.not_admin
end end
local modid = msg.text:input() local modid = msg.text:input()
@ -176,7 +180,7 @@ local commands = {
if not database.moderation[msg.chat.id_str][msg.from.id_str] then if not database.moderation[msg.chat.id_str][msg.from.id_str] then
if not config.moderation.admins[msg.from.id_str] then if not config.moderation.admins[msg.from.id_str] then
return config.errors.not_mod return config.moderation.errors.not_mod
end end
end end
@ -208,7 +212,7 @@ local commands = {
if not database.moderation[msg.chat.id_str][msg.from.id_str] then if not database.moderation[msg.chat.id_str][msg.from.id_str] then
if not config.moderation.admins[msg.from.id_str] then if not config.moderation.admins[msg.from.id_str] then
return config.errors.not_mod return config.moderation.errors.not_mod
end end
end end
@ -236,7 +240,7 @@ local commands = {
} }
if config.antisquig then if config.moderation.antisquig then
commands['[\216-\219][\128-\191]'] = function(msg) commands['[\216-\219][\128-\191]'] = function(msg)
if not database.moderation[msg.chat.id_str] then return true end if not database.moderation[msg.chat.id_str] then return true end
@ -248,11 +252,10 @@ if config.antisquig then
end end
antisquig[msg.from.id] = true antisquig[msg.from.id] = true
sendReply(msg, config.errors.antisquig) sendReply(msg, config.moderation.errors.antisquig)
sendMessage(config.moderation.admin_group, '/kick ' .. msg.from.id .. ' from ' .. math.abs(msg.chat.id)) sendMessage(config.moderation.admin_group, '/kick ' .. msg.from.id .. ' from ' .. math.abs(msg.chat.id))
sendMessage(config.moderation.admin_group, 'ANTISQUIG: ' .. msg.from.first_name .. ' kicked from ' .. msg.chat.title .. '.') sendMessage(config.moderation.admin_group, 'ANTISQUIG: ' .. msg.from.first_name .. ' kicked from ' .. msg.chat.title .. '.')
end end
end end
@ -279,7 +282,7 @@ local action = function(msg)
end end
-- When a user is kicked for squigglies, his ID is added to this table. -- When a user is kicked for squiggles, his ID is added to this table.
-- That user will not be kicked again as long as his ID is in the table. -- That user will not be kicked again as long as his ID is in the table.
-- The table is emptied every five seconds. -- The table is emptied every five seconds.
-- Thus the bot will not spam the group or admin group when a user posts more than one infringing messages. -- Thus the bot will not spam the group or admin group when a user posts more than one infringing messages.