From 73f4863bc3359c3491d6b216746efe45deb1f743 Mon Sep 17 00:00:00 2001 From: topkecleon Date: Wed, 20 Apr 2016 16:43:08 -0400 Subject: [PATCH] Small improvements to administration.lua. --- .gitignore | 1 + plugins/administration.lua | 30 +++++++++++++++++++++--------- utilities.lua | 2 ++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 4fd526d..86b10b3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ plugins/mokubot* plugins/qtbot* plugins/mjolnir* plugins/antisquigbot* +profile-pictures *.db lua-tg drua-tg diff --git a/plugins/administration.lua b/plugins/administration.lua index c974ccd..eb1e0e1 100644 --- a/plugins/administration.lua +++ b/plugins/administration.lua @@ -1,6 +1,6 @@ --[[ administration.lua - Version 1.8.1 + Version 1.8.2 Part of the otouto project. © 2016 topkecleon GNU General Public License, version 2 @@ -23,6 +23,9 @@ 1.8.1 - /rule will return that numbered rule, if it exists. + 1.8.2 - Will now attempt to unban users kicked from supergroups. Other small + changes. + ]]-- -- Build the administration db if nonexistent. @@ -415,10 +418,12 @@ local commands = { end -- Last active time for group listing. - for i,v in pairs(database.administration.activity) do - if v == msg.chat.id_str then - table.remove(database.administration.activity, i) - table.insert(database.administration.activity, 1, msg.chat.id_str) + if msg.text:len() > 0 then + for i,v in pairs(database.administration.activity) do + if v == msg.chat.id_str then + table.remove(database.administration.activity, i) + table.insert(database.administration.activity, 1, msg.chat.id_str) + end end end @@ -443,7 +448,7 @@ local commands = { local group = database.administration.groups[v] if not group.flags[1] then -- no unlisted groups if group.link then - output = output .. '• [' .. group.name .. '](' .. group.link .. ')\n' + output = output .. '• [' .. group.name:md_escape() .. '](' .. group.link .. ')\n' else output = output .. '• ' .. group.name .. '\n' end @@ -1091,21 +1096,28 @@ local commands = { command = 'gremove \\[chat]', privilege = 5, - interior = true, + interior = false, action = function(msg) local input = msg.text:input() or msg.chat.id_str + local output if database.administration.groups[input] then + local chat_name = database.administration.groups[input].name database.administration.groups[input] = nil for i,v in ipairs(database.administration.activity) do if v == input then table.remove(database.administration.activity, i) end end - sendReply(msg, 'I am no longer administrating that group.') + output = 'I am no longer administrating _' .. chat_name:md_escape() .. '_.' else - sendReply(msg, 'I do not administrate that group.') + if input == msg.chat.id_str then + output = 'I do not administrate this group.' + else + output = 'I do not administrate that group.' + end end + sendMessage(msg.chat.id, output, true, nil, true) end }, diff --git a/utilities.lua b/utilities.lua index 8f1db19..62bcfc9 100755 --- a/utilities.lua +++ b/utilities.lua @@ -255,6 +255,7 @@ markdown_escape = function(text) text = text:gsub('_', '\\_') text = text:gsub('%[', '\\[') + text = text:gsub('%]', '\\]') text = text:gsub('%*', '\\*') text = text:gsub('`', '\\`') return text @@ -265,6 +266,7 @@ function string:md_escape() local text = self text = text:gsub('_', '\\_') text = text:gsub('%[', '\\[') + text = text:gsub('%]', '\\]') text = text:gsub('%*', '\\*') text = text:gsub('`', '\\`') return text