Locals on plugins
This commit is contained in:
parent
c19c30933d
commit
0277d3bab7
@ -1,4 +1,6 @@
|
|||||||
function enable_plugin( filename )
|
do
|
||||||
|
|
||||||
|
local function enable_plugin( filename )
|
||||||
-- Check if plugin is enabled
|
-- Check if plugin is enabled
|
||||||
if plugin_enabled(filename) then
|
if plugin_enabled(filename) then
|
||||||
return 'Plugin '..filename..' is enabled'
|
return 'Plugin '..filename..' is enabled'
|
||||||
@ -15,7 +17,7 @@ function enable_plugin( filename )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function disable_plugin( name )
|
local function disable_plugin( name )
|
||||||
-- Check if plugins exists
|
-- Check if plugins exists
|
||||||
if not plugin_exists(name) then
|
if not plugin_exists(name) then
|
||||||
return 'Plugin '..name..' does not exists'
|
return 'Plugin '..name..' does not exists'
|
||||||
@ -31,14 +33,14 @@ function disable_plugin( name )
|
|||||||
return reload_plugins(true)
|
return reload_plugins(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function reload_plugins( )
|
local function reload_plugins( )
|
||||||
plugins = {}
|
plugins = {}
|
||||||
load_plugins()
|
load_plugins()
|
||||||
return list_plugins(true)
|
return list_plugins(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Retruns the key (index) in the config.enabled_plugins table
|
-- Retruns the key (index) in the config.enabled_plugins table
|
||||||
function plugin_enabled( name )
|
local function plugin_enabled( name )
|
||||||
for k,v in pairs(_config.enabled_plugins) do
|
for k,v in pairs(_config.enabled_plugins) do
|
||||||
if name == v then
|
if name == v then
|
||||||
return k
|
return k
|
||||||
@ -49,7 +51,7 @@ function plugin_enabled( name )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Returns true if file exists in plugins folder
|
-- Returns true if file exists in plugins folder
|
||||||
function plugin_exists( name )
|
local function plugin_exists( name )
|
||||||
for k,v in pairs(plugins_names()) do
|
for k,v in pairs(plugins_names()) do
|
||||||
if name..'.lua' == v then
|
if name..'.lua' == v then
|
||||||
return true
|
return true
|
||||||
@ -58,7 +60,7 @@ function plugin_exists( name )
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function list_plugins(only_enabled)
|
local function list_plugins(only_enabled)
|
||||||
local text = ''
|
local text = ''
|
||||||
for k, v in pairs( plugins_names( )) do
|
for k, v in pairs( plugins_names( )) do
|
||||||
-- ✔ enabled, ❌ disabled
|
-- ✔ enabled, ❌ disabled
|
||||||
@ -78,7 +80,7 @@ function list_plugins(only_enabled)
|
|||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
function run(msg, matches)
|
local function run(msg, matches)
|
||||||
-- Show the available plugins
|
-- Show the available plugins
|
||||||
if matches[1] == '!plugins' then
|
if matches[1] == '!plugins' then
|
||||||
return list_plugins()
|
return list_plugins()
|
||||||
@ -113,4 +115,6 @@ return {
|
|||||||
"^!plugins? (reload)$" },
|
"^!plugins? (reload)$" },
|
||||||
run = run,
|
run = run,
|
||||||
privileged = true
|
privileged = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end
|
Reference in New Issue
Block a user