-
Notifications
You must be signed in to change notification settings - Fork 15
/
Plugin_Installer.xml
225 lines (169 loc) · 5.17 KB
/
Plugin_Installer.xml
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 28, 2008, 1:40 PM -->
<!-- MuClient version 4.29 -->
<!-- Plugin "Plugin_Installer" generated by Plugin Wizard -->
<muclient>
<plugin
name="Plugin_Installer"
author="Nick Gammon"
id="50c7d6499597808803009442"
language="Lua"
purpose="Installs plugins"
date_written="2008-06-28 13:34:20"
requires="4.29"
version="1.0"
save_state="y"
>
<description trim="y">
<![CDATA[
This plugins scans a subdirectory and loads all plugins found in it, if not already loaded.
Aliases:
check_plugins -- Rescans the subdirectory, installing any new plugins found.
disable_plugins -- Disable all plugins (except this one) for testing or building, etc.
enable_plugins -- Enable all plugins to return to normal operation
reload_plugins -- Reload all plugins, in case you downloaded a new one
]]>
</description>
</plugin>
<aliases>
<alias
name="disable_plugins"
script="disable_plugins"
match="disable_plugins"
enabled="y"
sequence="100"
>
</alias>
<alias
name="enable_plugins"
script="enable_plugins"
match="enable_plugins"
enabled="y"
sequence="100"
>
</alias>
<alias
name="reload_plugins"
script="reload_plugins"
match="reload_plugins"
enabled="y"
sequence="100"
>
</alias>
<alias
name="check_plugins"
script="check_installed_plugins_now"
match="check_plugins"
enabled="y"
sequence="100"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
SUBDIRECTORY = "Aardwolf"
function disable_plugins (name, line, wildcards)
-- find installed plugins
local plugins = GetPluginList() or {}
-- for each plugin, disable it, unless it is us
local count = 0
local already = 0
for _, p in ipairs (plugins) do
if p ~= GetPluginID () then
if GetPluginInfo (p, 17) then
check (EnablePlugin (p, false))
count = count + 1
else
already = already + 1
end
end -- if not us
end -- each plugin file
ColourNote ("white", "blue", string.format ("%i plugin(s) disabled.", count))
ColourNote ("white", "blue", string.format ("%i plugin(s) already disabled.", already))
end -- disable_plugins
function enable_plugins (name, line, wildcards)
-- find installed plugins
local plugins = GetPluginList() or {}
-- for each plugin, enable it
local count = 0
local already = 0
for _, p in ipairs (plugins) do
if p ~= GetPluginID () then
if not GetPluginInfo (p, 17) then
check (EnablePlugin (p, true))
count = count + 1
else
already = already + 1
end
end -- not us (we must be enabled)
end -- each plugin file
ColourNote ("white", "blue", string.format ("%i plugin(s) enabled.", count))
ColourNote ("white", "blue", string.format ("%i plugin(s) already enabled.", already))
end -- enable_plugins
function reload_plugins (name, line, wildcards)
-- find installed plugins
local plugins = GetPluginList() or {}
-- for each plugin, reload it
local count = 0
for _, p in ipairs (plugins) do
if p ~= GetPluginID () then
local status = ReloadPlugin (p)
if status ~= error_code.eOK then
ColourNote ("red", "", "Could not reload plugin ID: " ..
(p or "unknown") .. ", name: " .. (GetPluginInfo (p, 1) or "unknown"))
check (status)
end -- no good
count = count + 1
end -- not us (we can't be reloadeed)
end -- each plugin file
ColourNote ("white", "blue", string.format ("%i plugin(s) reloaded.", count))
end -- reload_plugins
function check_installed_plugins_now ()
-- look for plugins under program install folder
local dir = GetInfo (57) .. "plugins\\" .. SUBDIRECTORY .. "\\"
-- find all xml files in that directory
local t = utils.readdir (dir .. "*.xml")
-- none? just warn them
if not t then
ColourNote ("white", "blue", "No plugins found in " .. dir)
return
end -- if
-- build list of file names
local plugins = {}
-- copy from keys of the table of names, into a new table, dropping files starting with "."
for k in pairs (t) do
if k:sub (1, 1) ~= "." then
table.insert (plugins, k)
end -- not temporary files
end -- for adding each one
-- may as well do in alphabetic order
table.sort (plugins)
-- find installed plugins
local installed_plugins = GetPluginList() or {}
-- for each file, see if it is already installed
for i, p in ipairs (plugins) do
local installed = false
-- check installed list
for _, v in pairs (installed_plugins) do
if GetPluginInfo (v, 6) == (dir .. p) then
installed = true
end -- if already installed
end
-- not there? load it
if not installed then
ColourNote ("white", "green", "Installing plugin " .. p)
check (LoadPlugin (dir .. p)) -- load it
end -- if
end -- each plugin file
end -- check_installed_plugins_now
function OnPluginInstall ()
-- give them time to load
DoAfterSpecial (2,
"check_installed_plugins_now ()",
sendto.script)
end -- function OnPluginInstall
]]>
</script>
</muclient>