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/qtbot*
|
||||||
plugins/mjolnir*
|
plugins/mjolnir*
|
||||||
plugins/antisquigbot*
|
plugins/antisquigbot*
|
||||||
|
profile-pictures
|
||||||
*.db
|
*.db
|
||||||
lua-tg
|
lua-tg
|
||||||
drua-tg
|
drua-tg
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--[[
|
--[[
|
||||||
administration.lua
|
administration.lua
|
||||||
Version 1.8.1
|
Version 1.8.2
|
||||||
Part of the otouto project.
|
Part of the otouto project.
|
||||||
© 2016 topkecleon <drew@otou.to>
|
© 2016 topkecleon <drew@otou.to>
|
||||||
GNU General Public License, version 2
|
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.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.
|
-- Build the administration db if nonexistent.
|
||||||
@ -415,10 +418,12 @@ local commands = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Last active time for group listing.
|
-- Last active time for group listing.
|
||||||
for i,v in pairs(database.administration.activity) do
|
if msg.text:len() > 0 then
|
||||||
if v == msg.chat.id_str then
|
for i,v in pairs(database.administration.activity) do
|
||||||
table.remove(database.administration.activity, i)
|
if v == msg.chat.id_str then
|
||||||
table.insert(database.administration.activity, 1, msg.chat.id_str)
|
table.remove(database.administration.activity, i)
|
||||||
|
table.insert(database.administration.activity, 1, msg.chat.id_str)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -443,7 +448,7 @@ local commands = {
|
|||||||
local group = database.administration.groups[v]
|
local group = database.administration.groups[v]
|
||||||
if not group.flags[1] then -- no unlisted groups
|
if not group.flags[1] then -- no unlisted groups
|
||||||
if group.link then
|
if group.link then
|
||||||
output = output .. '• [' .. group.name .. '](' .. group.link .. ')\n'
|
output = output .. '• [' .. group.name:md_escape() .. '](' .. group.link .. ')\n'
|
||||||
else
|
else
|
||||||
output = output .. '• ' .. group.name .. '\n'
|
output = output .. '• ' .. group.name .. '\n'
|
||||||
end
|
end
|
||||||
@ -1091,21 +1096,28 @@ local commands = {
|
|||||||
|
|
||||||
command = 'gremove \\[chat]',
|
command = 'gremove \\[chat]',
|
||||||
privilege = 5,
|
privilege = 5,
|
||||||
interior = true,
|
interior = false,
|
||||||
|
|
||||||
action = function(msg)
|
action = function(msg)
|
||||||
local input = msg.text:input() or msg.chat.id_str
|
local input = msg.text:input() or msg.chat.id_str
|
||||||
|
local output
|
||||||
if database.administration.groups[input] then
|
if database.administration.groups[input] then
|
||||||
|
local chat_name = database.administration.groups[input].name
|
||||||
database.administration.groups[input] = nil
|
database.administration.groups[input] = nil
|
||||||
for i,v in ipairs(database.administration.activity) do
|
for i,v in ipairs(database.administration.activity) do
|
||||||
if v == input then
|
if v == input then
|
||||||
table.remove(database.administration.activity, i)
|
table.remove(database.administration.activity, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sendReply(msg, 'I am no longer administrating that group.')
|
output = 'I am no longer administrating _' .. chat_name:md_escape() .. '_.'
|
||||||
else
|
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
|
end
|
||||||
|
sendMessage(msg.chat.id, output, true, nil, true)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -255,6 +255,7 @@ markdown_escape = function(text)
|
|||||||
|
|
||||||
text = text:gsub('_', '\\_')
|
text = text:gsub('_', '\\_')
|
||||||
text = text:gsub('%[', '\\[')
|
text = text:gsub('%[', '\\[')
|
||||||
|
text = text:gsub('%]', '\\]')
|
||||||
text = text:gsub('%*', '\\*')
|
text = text:gsub('%*', '\\*')
|
||||||
text = text:gsub('`', '\\`')
|
text = text:gsub('`', '\\`')
|
||||||
return text
|
return text
|
||||||
@ -265,6 +266,7 @@ function string:md_escape()
|
|||||||
local text = self
|
local text = self
|
||||||
text = text:gsub('_', '\\_')
|
text = text:gsub('_', '\\_')
|
||||||
text = text:gsub('%[', '\\[')
|
text = text:gsub('%[', '\\[')
|
||||||
|
text = text:gsub('%]', '\\]')
|
||||||
text = text:gsub('%*', '\\*')
|
text = text:gsub('%*', '\\*')
|
||||||
text = text:gsub('`', '\\`')
|
text = text:gsub('`', '\\`')
|
||||||
return text
|
return text
|
||||||
|
Reference in New Issue
Block a user