Small improvements to administration.lua.
This commit is contained in:
parent
66d9caefa3
commit
73f4863bc3
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ plugins/mokubot*
|
||||
plugins/qtbot*
|
||||
plugins/mjolnir*
|
||||
plugins/antisquigbot*
|
||||
profile-pictures
|
||||
*.db
|
||||
lua-tg
|
||||
drua-tg
|
||||
|
@ -1,6 +1,6 @@
|
||||
--[[
|
||||
administration.lua
|
||||
Version 1.8.1
|
||||
Version 1.8.2
|
||||
Part of the otouto project.
|
||||
© 2016 topkecleon <drew@otou.to>
|
||||
GNU General Public License, version 2
|
||||
@ -23,6 +23,9 @@
|
||||
|
||||
1.8.1 - /rule <i> 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,12 +418,14 @@ local commands = {
|
||||
end
|
||||
|
||||
-- Last active time for group listing.
|
||||
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
|
||||
|
||||
return true
|
||||
|
||||
@ -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,22 +1096,29 @@ 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
|
||||
},
|
||||
|
||||
{ -- glist
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user