-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.lua
64 lines (54 loc) · 1.4 KB
/
plugin.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
plugin = {}
plugin.__index = plugin
function plugin.init()
local data = {}
setmetatable( data, plugin )
data.name = "plugin"
data.author = "mariom"
data.version = "0.1"
data.type = { "cmd" }
data.cmd = cmdChar .. "plugin"
return data
end
function plugin:actionCmd()
opt=msg.msg:match( "%w+", 9 )
plug=msg.msg:match( "%w+$" )
if opt == "load" then
if self:check( plug ) == 0 then
return msg.nick .. ": plugin already loaded!"
else
core:pluginLoad( plug )
return msg.nick .. ": plugin " .. plug .. " loaded"
end
elseif opt == "unload" then
if self:check( plug ) ~= 0 then
return msg.nick .. ": plugin not loaded!"
else
core:pluginUnload( plug )
return msg.nick .. ": plugin " .. plug .. " unloaded"
end
elseif opt == "reload" then
if self:check( plug ) == 0 then
core:pluginUnload( plug )
core:pluginLoad( plug )
return msg.nick .. ": plugin " .. plug .. " reloaded"
else
return msg.nick .. ": plugin " .. plug .. " not loaded!"
end
elseif opt == "list" then
load=""
for i, v in pairs( core.plugins ) do
load= load .. v .. ", "
end
return msg.nick .. ": loaded plugins: " .. load
else
return msg.nick ": use: load, unload, list"
end
end
function plugin:check( _plugin )
for i, v in pairs( core.plugins ) do
if _plugin == v then
return 0
end
end
end