Auf Upstream aktualisiert (Otouto 3.10)
This commit is contained in:
commit
d9d148001f
@ -21,7 +21,9 @@ Sende /hilfe, um zu starten
|
|||||||
-- The symbol that starts a command. Usually noted as '/' in documentation.
|
-- The symbol that starts a command. Usually noted as '/' in documentation.
|
||||||
cmd_pat = '/',
|
cmd_pat = '/',
|
||||||
|
|
||||||
|
<<<<<<< HEAD:config.lua.example
|
||||||
errors = { -- Generic error messages used in various plugins.
|
errors = { -- Generic error messages used in various plugins.
|
||||||
|
generic = 'An unexpected error occurred.',
|
||||||
connection = 'Verbindungsfehler.',
|
connection = 'Verbindungsfehler.',
|
||||||
quotaexceeded = 'API-Quota aufgebraucht.',
|
quotaexceeded = 'API-Quota aufgebraucht.',
|
||||||
results = 'Keine Ergebnisse gefunden.',
|
results = 'Keine Ergebnisse gefunden.',
|
||||||
@ -30,7 +32,7 @@ Sende /hilfe, um zu starten
|
|||||||
syntax = 'Invalide Syntax.',
|
syntax = 'Invalide Syntax.',
|
||||||
chatter_connection = 'Ich möchte gerade nicht reden',
|
chatter_connection = 'Ich möchte gerade nicht reden',
|
||||||
chatter_response = 'Ich weiß nicht, was ich darauf antworten soll.'
|
chatter_response = 'Ich weiß nicht, was ich darauf antworten soll.'
|
||||||
},
|
}
|
||||||
|
|
||||||
plugins = { -- To enable a plugin, add its name to the list.
|
plugins = { -- To enable a plugin, add its name to the list.
|
||||||
'control',
|
'control',
|
||||||
|
@ -69,21 +69,28 @@ function bot:on_msg_receive(msg, config) -- The fn run whenever a message is rec
|
|||||||
msg.text_lower = msg.text:lower()
|
msg.text_lower = msg.text:lower()
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,v in ipairs(self.plugins) do
|
for _, plugin in ipairs(self.plugins) do
|
||||||
for _,w in pairs(v.triggers) do
|
for _, trigger in pairs(plugin.triggers) do
|
||||||
if string.match(msg.text_lower, w) then
|
if string.match(msg.text_lower, trigger) then
|
||||||
local success, result = pcall(function()
|
local success, result = pcall(function()
|
||||||
-- trying to port matches to otouto
|
-- trying to port matches to otouto
|
||||||
for k, pattern in pairs(v.triggers) do
|
for k, pattern in pairs(plugin.triggers) do
|
||||||
matches = match_pattern(pattern, msg.text)
|
matches = match_pattern(pattern, msg.text)
|
||||||
if matches then
|
if matches then
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return v.action(self, msg, config, matches)
|
return plugin.action(self, msg, config, matches)
|
||||||
end)
|
end)
|
||||||
if not success then
|
if not success then
|
||||||
utilities.send_reply(self, msg, 'Ein unbekannter Fehler ist aufgetreten, bitte [melde diesen Bug](https://github.com/Brawl345/Brawlbot-v2/issues).', true)
|
-- If the plugin has an error message, send it. If it does
|
||||||
|
-- not, use the generic one specified in config. If it's set
|
||||||
|
-- to false, do nothing.
|
||||||
|
if plugin.error then
|
||||||
|
utilities.send_reply(self, msg, plugin.error)
|
||||||
|
elseif plugin.error == nil then
|
||||||
|
utilities.send_reply(self, msg, config.errors.generic, true)
|
||||||
|
end
|
||||||
utilities.handle_exception(self, result, msg.from.id .. ': ' .. msg.text, config)
|
utilities.handle_exception(self, result, msg.from.id .. ': ' .. msg.text, config)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -71,6 +71,9 @@ function administration:init(config)
|
|||||||
|
|
||||||
administration.doc = '`Returns a list of administrated groups.\nUse '..config.cmd_pat..'ahelp for more administrative commands.`'
|
administration.doc = '`Returns a list of administrated groups.\nUse '..config.cmd_pat..'ahelp for more administrative commands.`'
|
||||||
|
|
||||||
|
-- In the worst case, don't send errors in reply to random messages.
|
||||||
|
administration.error = false
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function administration.init_flags(cmd_pat) return {
|
function administration.init_flags(cmd_pat) return {
|
||||||
@ -265,7 +268,7 @@ function administration:kick_user(chat, target, reason, config)
|
|||||||
victim = utilities.build_name(
|
victim = utilities.build_name(
|
||||||
self.database.users[tostring(target)].first_name,
|
self.database.users[tostring(target)].first_name,
|
||||||
self.database.users[tostring(target)].last_name
|
self.database.users[tostring(target)].last_name
|
||||||
)
|
) .. ' [' .. victim .. ']'
|
||||||
end
|
end
|
||||||
local group = self.database.administration.groups[tostring(chat)].name
|
local group = self.database.administration.groups[tostring(chat)].name
|
||||||
utilities.handle_exception(self, victim..' kicked from '..group, reason, config)
|
utilities.handle_exception(self, victim..' kicked from '..group, reason, config)
|
||||||
@ -917,7 +920,9 @@ function administration.init_command(self_, config)
|
|||||||
if input then
|
if input then
|
||||||
input = utilities.get_word(input, 1)
|
input = utilities.get_word(input, 1)
|
||||||
input = tonumber(input)
|
input = tonumber(input)
|
||||||
if not input or not administration.flags[input] then input = false end
|
if not input or not administration.flags[input] then
|
||||||
|
input = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if not input then
|
if not input then
|
||||||
local output = '*Flags for ' .. msg.chat.title .. ':*\n'
|
local output = '*Flags for ' .. msg.chat.title .. ':*\n'
|
||||||
@ -1209,7 +1214,9 @@ function administration.init_command(self_, config)
|
|||||||
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. For example, this would add the group and enable the unlisted flag, antibot, and antiflood:\n/gadd 1 4 5',
|
||||||
|
|
||||||
action = function(self, msg, group, config)
|
action = function(self, msg, group, config)
|
||||||
if self.database.administration.groups[msg.chat.id_str] then
|
if msg.chat.id == msg.from.id then
|
||||||
|
utilities.send_message(self, msg.chat.id, 'No.')
|
||||||
|
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 flags = {}
|
local flags = {}
|
||||||
@ -1327,6 +1334,18 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ patterns.triggers = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function patterns:action(msg)
|
function patterns:action(msg)
|
||||||
if not msg.reply_to_message then return end
|
if not msg.reply_to_message then return true end
|
||||||
local output = msg.reply_to_message.text
|
local output = msg.reply_to_message.text
|
||||||
if msg.reply_to_message.from.id == self.info.id then
|
if msg.reply_to_message.from.id == self.info.id then
|
||||||
output = output:gsub('Did you mean:\n"', '')
|
output = output:gsub('Did you mean:\n"', '')
|
||||||
@ -22,8 +22,7 @@ function patterns:action(msg)
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
if res == false then
|
if res == false then
|
||||||
output = 'Malformed pattern!'
|
utilities.send_reply(self, msg, 'Malformed pattern!')
|
||||||
utilities.send_reply(self, msg, output)
|
|
||||||
else
|
else
|
||||||
output = output:sub(1, 4000)
|
output = output:sub(1, 4000)
|
||||||
output = 'Did you mean:\n"' .. output .. '"'
|
output = 'Did you mean:\n"' .. output .. '"'
|
||||||
|
Reference in New Issue
Block a user