merge upstream
LoWeR cAsE Show red error if loading plugin fails
This commit is contained in:
parent
38268496e0
commit
281d01859b
14
bot/bot.lua
14
bot/bot.lua
@ -112,7 +112,7 @@ function match_plugin(plugin, plugin_name, msg)
|
|||||||
|
|
||||||
-- Go over patterns. If one matches is enough.
|
-- Go over patterns. If one matches is enough.
|
||||||
for k, pattern in pairs(plugin.patterns) do
|
for k, pattern in pairs(plugin.patterns) do
|
||||||
local matches = match_pattern(pattern, msg.text)
|
local matches = match_pattern(pattern, msg.text, true)
|
||||||
if matches then
|
if matches then
|
||||||
print("Nachricht stimmt überein mit ", pattern)
|
print("Nachricht stimmt überein mit ", pattern)
|
||||||
|
|
||||||
@ -249,8 +249,16 @@ end
|
|||||||
function load_plugins()
|
function load_plugins()
|
||||||
for k, v in pairs(_config.enabled_plugins) do
|
for k, v in pairs(_config.enabled_plugins) do
|
||||||
print("Lade Plugin", v)
|
print("Lade Plugin", v)
|
||||||
local t = loadfile("plugins/"..v..'.lua')()
|
|
||||||
plugins[v] = t
|
local ok, err = pcall(function()
|
||||||
|
local t = loadfile("plugins/"..v..'.lua')()
|
||||||
|
plugins[v] = t
|
||||||
|
end)
|
||||||
|
|
||||||
|
if not ok then
|
||||||
|
print('\27[31mFehler beim laden des Plugins '..v..'\27[39m')
|
||||||
|
print('\27[31m'..err..'\27[39m')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -430,12 +430,17 @@ function send_large_msg_callback(cb_extra, success, result)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns a table with matches or nil
|
-- Returns a table with matches or nil
|
||||||
function match_pattern(pattern, text)
|
function match_pattern(pattern, text, lower_case)
|
||||||
if text then
|
if text then
|
||||||
local matches = { string.match(text, pattern) }
|
local matches = {}
|
||||||
if next(matches) then
|
if lower_case then
|
||||||
return matches
|
matches = { string.match(text:lower(), pattern) }
|
||||||
end
|
else
|
||||||
|
matches = { string.match(text, pattern) }
|
||||||
|
end
|
||||||
|
if next(matches) then
|
||||||
|
return matches
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- nil
|
-- nil
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user