administration.lua 1.10.4
/flags now accepts multiple arguments. control.lua - bugfix The readme changed but I don't remember how.
This commit is contained in:
parent
f17455a505
commit
444ff18cac
@ -16,6 +16,8 @@ otouto is free software; you are free to redistribute it and/or modify it under
|
|||||||
| [Group Administration](#group-administration) | [Output style](#output-style) |
|
| [Group Administration](#group-administration) | [Output style](#output-style) |
|
||||||
| [List of plugins](#list-of-plugins) | [Contributors](#contributors) |
|
| [List of plugins](#list-of-plugins) | [Contributors](#contributors) |
|
||||||
|
|
||||||
|
* * *
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
You _must_ have Lua (5.2+), luasocket, luasec, multipart-post, and dkjson installed. You should also have lpeg, though it is not required. It is recommended you install these with LuaRocks.
|
You _must_ have Lua (5.2+), luasocket, luasec, multipart-post, and dkjson installed. You should also have lpeg, though it is not required. It is recommended you install these with LuaRocks.
|
||||||
|
|
||||||
@ -190,6 +192,7 @@ Additionally, antiflood can be configured to automatically ban a user after he h
|
|||||||
| `patterns.lua` | /s/‹from›/‹to›/ | Search-and-replace using Lua patterns. |
|
| `patterns.lua` | /s/‹from›/‹to›/ | Search-and-replace using Lua patterns. |
|
||||||
| `me.lua` | /me | Returns user-specific data stored by the bot. |
|
| `me.lua` | /me | Returns user-specific data stored by the bot. |
|
||||||
| `remind.lua` | /remind <duration> <message> | Reminds a user of something after a duration of minutes. |
|
| `remind.lua` | /remind <duration> <message> | Reminds a user of something after a duration of minutes. |
|
||||||
|
| `channel.lua` | /ch <channel> \n <message> | Sends a markdown-enabled message to a channel. |
|
||||||
|
|
||||||
* * *
|
* * *
|
||||||
|
|
||||||
@ -284,7 +287,7 @@ Title lines should be **bold**, including any names and trailing punctuation (su
|
|||||||
|
|
||||||
> **Star Wars: Episode IV - A New Hope (1977)**
|
> **Star Wars: Episode IV - A New Hope (1977)**
|
||||||
>
|
>
|
||||||
> **Search results for** _star wars_**:**
|
> **Search results for** _star wars_ **:**
|
||||||
>
|
>
|
||||||
> **Changelog for otouto (**[Github](http://github.com/topkecleon/otouto)**):**
|
> **Changelog for otouto (**[Github](http://github.com/topkecleon/otouto)**):**
|
||||||
|
|
||||||
|
@ -39,6 +39,9 @@
|
|||||||
"/gadd 1 4 5" will add a grouo with the unlisted, antibot, and antiflood
|
"/gadd 1 4 5" will add a grouo with the unlisted, antibot, and antiflood
|
||||||
flags.
|
flags.
|
||||||
|
|
||||||
|
1.10.4 - Kick notifications now include user IDs. Errors are silenced.
|
||||||
|
/flags can now be used with multiple arguments, similar to /gadd.
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
local JSON = require('dkjson')
|
local JSON = require('dkjson')
|
||||||
@ -125,15 +128,15 @@ function administration.init_flags(cmd_pat) return {
|
|||||||
} end
|
} end
|
||||||
|
|
||||||
administration.antiflood = {
|
administration.antiflood = {
|
||||||
text = 10,
|
text = 5,
|
||||||
voice = 10,
|
voice = 5,
|
||||||
audio = 10,
|
audio = 5,
|
||||||
contact = 10,
|
contact = 5,
|
||||||
photo = 20,
|
photo = 10,
|
||||||
video = 20,
|
video = 10,
|
||||||
location = 20,
|
location = 10,
|
||||||
document = 20,
|
document = 10,
|
||||||
sticker = 30
|
sticker = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
administration.ranks = {
|
administration.ranks = {
|
||||||
@ -767,6 +770,38 @@ function administration.init_command(self_, config)
|
|||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ -- /setmotd
|
||||||
|
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('setmotd', true).table,
|
||||||
|
|
||||||
|
command = 'setmotd <motd>',
|
||||||
|
privilege = 2,
|
||||||
|
interior = true,
|
||||||
|
doc = 'Sets the group\'s message of the day. Markdown is supported. Pass "--" to delete the message.',
|
||||||
|
|
||||||
|
action = function(self, msg, group, config)
|
||||||
|
local input = utilities.input(msg.text)
|
||||||
|
if not input and msg.reply_to_message and msg.reply_to_message.text:len() > 0 then
|
||||||
|
input = msg.reply_to_message.text
|
||||||
|
end
|
||||||
|
if input then
|
||||||
|
if input == '--' or input == utilities.char.em_dash then
|
||||||
|
group.motd = nil
|
||||||
|
utilities.send_reply(self, msg, 'The MOTD has been cleared.')
|
||||||
|
else
|
||||||
|
input = utilities.trim(input)
|
||||||
|
group.motd = input
|
||||||
|
local output = '*MOTD for ' .. msg.chat.title .. ':*\n' .. input
|
||||||
|
utilities.send_message(self, msg.chat.id, output, true, nil, true)
|
||||||
|
end
|
||||||
|
if group.grouptype == 'supergroup' then
|
||||||
|
administration.update_desc(self, msg.chat.id, config)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
utilities.send_reply(self, msg, 'Please specify the new message of the day.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
},
|
||||||
|
|
||||||
{ -- /setrules
|
{ -- /setrules
|
||||||
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('setrules', true).table,
|
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('setrules', true).table,
|
||||||
|
|
||||||
@ -834,38 +869,6 @@ function administration.init_command(self_, config)
|
|||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- /setmotd
|
|
||||||
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('setmotd', true).table,
|
|
||||||
|
|
||||||
command = 'setmotd <motd>',
|
|
||||||
privilege = 2,
|
|
||||||
interior = true,
|
|
||||||
doc = 'Sets the group\'s message of the day. Markdown is supported. Pass "--" to delete the message.',
|
|
||||||
|
|
||||||
action = function(self, msg, group, config)
|
|
||||||
local input = utilities.input(msg.text)
|
|
||||||
if not input and msg.reply_to_message and msg.reply_to_message.text:len() > 0 then
|
|
||||||
input = msg.reply_to_message.text
|
|
||||||
end
|
|
||||||
if input then
|
|
||||||
if input == '--' or input == utilities.char.em_dash then
|
|
||||||
group.motd = nil
|
|
||||||
utilities.send_reply(self, msg, 'The MOTD has been cleared.')
|
|
||||||
else
|
|
||||||
input = utilities.trim(input)
|
|
||||||
group.motd = input
|
|
||||||
local output = '*MOTD for ' .. msg.chat.title .. ':*\n' .. input
|
|
||||||
utilities.send_message(self, msg.chat.id, output, true, nil, true)
|
|
||||||
end
|
|
||||||
if group.grouptype == 'supergroup' then
|
|
||||||
administration.update_desc(self, msg.chat.id, config)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
utilities.send_reply(self, msg, 'Please specify the new message of the day.')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
},
|
|
||||||
|
|
||||||
{ -- /setlink
|
{ -- /setlink
|
||||||
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('setlink', true).table,
|
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('setlink', true).table,
|
||||||
|
|
||||||
@ -910,34 +913,40 @@ function administration.init_command(self_, config)
|
|||||||
{ -- /flags
|
{ -- /flags
|
||||||
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('flags?', true).table,
|
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('flags?', true).table,
|
||||||
|
|
||||||
command = 'flag \\[i]',
|
command = 'flag \\[i] ...',
|
||||||
privilege = 3,
|
privilege = 3,
|
||||||
interior = true,
|
interior = true,
|
||||||
doc = 'Returns a list of flags or toggles the specified flag.',
|
doc = 'Returns a list of flags or toggles the specified flags.',
|
||||||
|
|
||||||
action = function(self, msg, group, config)
|
action = function(self, msg, group, config)
|
||||||
|
local output = ''
|
||||||
local input = utilities.input(msg.text)
|
local input = utilities.input(msg.text)
|
||||||
if input then
|
if input then
|
||||||
input = utilities.get_word(input, 1)
|
local index = utilities.index(input)
|
||||||
input = tonumber(input)
|
for _, i in ipairs(index) do
|
||||||
if not input or not administration.flags[input] then
|
n = tonumber(i)
|
||||||
|
if n and administration.flags[n] then
|
||||||
|
if group.flags[n] == true then
|
||||||
|
group.flags[n] = false
|
||||||
|
output = output .. administration.flags[n].disabled .. '\n'
|
||||||
|
else
|
||||||
|
group.flags[n] = true
|
||||||
|
output = output .. administration.flags[n].enabled .. '\n'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if output == '' then
|
||||||
input = false
|
input = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not input then
|
if not input then
|
||||||
local output = '*Flags for ' .. msg.chat.title .. ':*\n'
|
output = '*Flags for ' .. msg.chat.title .. ':*\n'
|
||||||
for i,v in ipairs(administration.flags) do
|
for i, flag in ipairs(administration.flags) do
|
||||||
local status = group.flags[i] or false
|
local status = group.flags[i] or false
|
||||||
output = output .. '`[' .. i .. ']` *' .. v.name .. '*` = ' .. tostring(status) .. '`\n• ' .. v.desc .. '\n'
|
output = output .. '*' .. i .. '. ' .. flag.name .. '* `[' .. tostring(status) .. ']`\n• ' .. flag.desc .. '\n'
|
||||||
end
|
end
|
||||||
utilities.send_message(self, msg.chat.id, output, true, nil, true)
|
|
||||||
elseif group.flags[input] == true then
|
|
||||||
group.flags[input] = false
|
|
||||||
utilities.send_reply(self, msg, administration.flags[input].disabled)
|
|
||||||
else
|
|
||||||
group.flags[input] = true
|
|
||||||
utilities.send_reply(self, msg, administration.flags[input].enabled)
|
|
||||||
end
|
end
|
||||||
|
utilities.send_message(self, msg.chat.id, output, true, nil, true)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1208,10 +1217,10 @@ function administration.init_command(self_, config)
|
|||||||
{ -- /gadd
|
{ -- /gadd
|
||||||
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('gadd', true).table,
|
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('gadd', true).table,
|
||||||
|
|
||||||
command = 'gadd [i] ...',
|
command = 'gadd \\[i] ...',
|
||||||
privilege = 5,
|
privilege = 5,
|
||||||
interior = false,
|
interior = false,
|
||||||
doc = 'Adds a group to the administration system. Pass numbers as arguments to enable those flags immediately. For example, this would add the group and enable the unlisted flag, antibot, and antiflood:\n/gadd 1 4 5',
|
doc = 'Adds a group to the administration system. Pass numbers as arguments to enable those flags immediately.\nExample usage:\n\t/gadd 1 4 5\nThis would add a group and enable the unlisted flag, antibot, and antiflood.',
|
||||||
|
|
||||||
action = function(self, msg, group, config)
|
action = function(self, msg, group, config)
|
||||||
if msg.chat.id == msg.from.id then
|
if msg.chat.id == msg.from.id then
|
||||||
@ -1219,6 +1228,7 @@ function administration.init_command(self_, config)
|
|||||||
elseif self.database.administration.groups[msg.chat.id_str] then
|
elseif self.database.administration.groups[msg.chat.id_str] then
|
||||||
utilities.send_reply(self, msg, 'I am already administrating this group.')
|
utilities.send_reply(self, msg, 'I am already administrating this group.')
|
||||||
else
|
else
|
||||||
|
local output = 'I am now administrating this group.'
|
||||||
local flags = {}
|
local flags = {}
|
||||||
for i = 1, #administration.flags do
|
for i = 1, #administration.flags do
|
||||||
flags[i] = false
|
flags[i] = false
|
||||||
@ -1227,9 +1237,10 @@ function administration.init_command(self_, config)
|
|||||||
if input then
|
if input then
|
||||||
local index = utilities.index(input)
|
local index = utilities.index(input)
|
||||||
for _, i in ipairs(index) do
|
for _, i in ipairs(index) do
|
||||||
i = tonumber(i)
|
n = tonumber(i)
|
||||||
if i and i < #administration.flags and i > 0 then
|
if n and administration.flags[n] and flags[n] ~= true then
|
||||||
flags[i] = true
|
flags[n] = true
|
||||||
|
output = output .. '\n' .. administration.flags[n].short
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1249,7 +1260,7 @@ function administration.init_command(self_, config)
|
|||||||
}
|
}
|
||||||
administration.update_desc(self, msg.chat.id, config)
|
administration.update_desc(self, msg.chat.id, config)
|
||||||
table.insert(self.database.administration.activity, msg.chat.id_str)
|
table.insert(self.database.administration.activity, msg.chat.id_str)
|
||||||
utilities.send_reply(self, msg, 'I am now administrating this group.')
|
utilities.send_reply(self, msg, output)
|
||||||
drua.channel_set_admin(msg.chat.id, self.info.id, 2)
|
drua.channel_set_admin(msg.chat.id, self.info.id, 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1334,18 +1345,6 @@ function administration.init_command(self_, config)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
},
|
|
||||||
|
|
||||||
{ -- /buildwall :^)
|
|
||||||
triggers = utilities.triggers(self_.info.username, config.cmd_pat):t('buildwall').table,
|
|
||||||
privilege = 3,
|
|
||||||
interior = true,
|
|
||||||
action = function(self, msg, group, config)
|
|
||||||
for i = 2, 5 do
|
|
||||||
group.flags[i] = true
|
|
||||||
end
|
|
||||||
utilities.send_message(self, msg.chat.id, 'antisquig, antisquig++, antibot, and antiflood have been enabled.')
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ function control:action(msg, config)
|
|||||||
for command in input:gmatch('(.-)\n') do
|
for command in input:gmatch('(.-)\n') do
|
||||||
command = utilities.trim(command)
|
command = utilities.trim(command)
|
||||||
msg.text = command
|
msg.text = command
|
||||||
bot.on_msg_receive(self, msg)
|
bot.on_msg_receive(self, msg, config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user