-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbackItUp.xml
348 lines (335 loc) · 13.1 KB
/
backItUp.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
<MudletPackage version="1.001">
<TriggerPackage>
<TriggerGroup isActive="yes" isFolder="yes" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>BackItUp</name>
<script></script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList />
<regexCodePropertyList />
<Trigger isActive="no" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>BackItUp_CaptureStartCanary</name>
<script>enableTrigger("BackItUp_CaptureOrg")
disableTrigger("BackItUp_CaptureScrollList")
enableTrigger("BackItUp_Prompt")</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>----- BACKITUP! -----</string>
</regexCodeList>
<regexCodePropertyList>
<integer>3</integer>
</regexCodePropertyList>
</Trigger>
<Trigger isActive="no" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>BackItUp_CaptureOrg</name>
<script>if matches[2] == '----- BACKITUP! -----' then return end
if not backItUp.orgname then
backItUp.orgname = matches[2]
disableTrigger("BackItUp_CaptureOrg")
enableTrigger("BackItUp_CaptureScrollList")
end</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>^(.+)$</string>
</regexCodeList>
<regexCodePropertyList>
<integer>1</integer>
</regexCodePropertyList>
</Trigger>
<Trigger isActive="no" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>BackItUp_CaptureScrollList</name>
<script>if isPrompt() then return end
if matches[2] == backItUp.orgname then return end
backItUp.scrolls = backItUp.scrolls or {}
for item in string.gmatch(matches[2], "%a+") do
if item:len() > 0 then
table.insert(backItUp.scrolls, item)
end
end
</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>^(.+)$</string>
</regexCodeList>
<regexCodePropertyList>
<integer>1</integer>
</regexCodePropertyList>
</Trigger>
<Trigger isActive="no" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>BackItUp_Prompt</name>
<script>disableTrigger("BackItUp_CaptureScrollList")
disableTrigger("BackItUp_Prompt")
disableTrigger("BackItUp_CaptureStartCanary")
backItUp.scrollsTotal = #backItUp.scrolls
cecho("\n<orange,DarkSlateGrey>Found " .. backItUp.scrollsTotal .. " scrolls for " .. backItUp.orgname .. "\n")
cecho("\n<orange,DarkSlateGrey>Starting backup... \n")
tempTimer(0.3, backItUp.nextScroll)</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>return isPrompt()</string>
</regexCodeList>
<regexCodePropertyList>
<integer>4</integer>
</regexCodePropertyList>
</Trigger>
<Trigger isActive="no" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>BackItUp_ScrollStartLine</name>
<script>disableTrigger("BackItUp_ScrollStartLine")
enableTrigger("BackItUp_ScrollContent")
enableTrigger("BackItUp_ScrollMorePrompt")
enableTrigger("BackItUp_ScrollEndPrompt")</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>^Composed by: (.+)</string>
<string>[File continued via MORE]</string>
<string>There appears to be no help scroll by that name.</string>
<string>----- BACKITUP-SCROLL! -----</string>
</regexCodeList>
<regexCodePropertyList>
<integer>1</integer>
<integer>3</integer>
<integer>3</integer>
<integer>3</integer>
</regexCodePropertyList>
</Trigger>
<Trigger isActive="no" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>BackItUp_ScrollContent</name>
<script>if not isPrompt() then
deleteLine()
if matches[2] then
local isTypeMore = string.find(matches[2], "%[Type MORE if you wish to continue reading. %(%d+%% shown%)%]")
local isFileContinued = string.find(matches[2], "%[File continued via MORE%]")
local isPreamble = matches[2] == "----- BACKITUP-SCROLL! -----"
if isTypeMore or isFileContinued or isPreamble then -- skip MORE!
return
else
backItUp.scrollContents[backItUp.thisScroll] = backItUp.scrollContents[backItUp.thisScroll] .. matches[2] .. "\n"
end
else
backItUp.scrollContents[backItUp.thisScroll] = backItUp.scrollContents[backItUp.thisScroll] .. "\n"
end
end</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>^(.+)$</string>
<string>^$</string>
</regexCodeList>
<regexCodePropertyList>
<integer>1</integer>
<integer>1</integer>
</regexCodePropertyList>
</Trigger>
<Trigger isActive="no" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>BackItUp_ScrollMorePrompt</name>
<script>backItUp.wantsMore = true</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>^\[Type MORE if you wish to continue reading. \(\d+% shown\)\]$</string>
</regexCodeList>
<regexCodePropertyList>
<integer>1</integer>
</regexCodePropertyList>
</Trigger>
<Trigger isActive="no" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>BackItUp_ScrollEndPrompt</name>
<script>disableTrigger("BackItUp_ScrollMorePrompt")
disableTrigger("BackItUp_ScrollContent")
disableTrigger("BackItUp_ScrollEndPrompt")
tempTimer(0.3, backItUp.nextScroll)</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>return isPrompt()</string>
</regexCodeList>
<regexCodePropertyList>
<integer>4</integer>
</regexCodePropertyList>
</Trigger>
</TriggerGroup>
</TriggerPackage>
<TimerPackage />
<AliasPackage>
<AliasGroup isActive="yes" isFolder="yes">
<name>BackItUp</name>
<script></script>
<command></command>
<packageName></packageName>
<regex></regex>
<Alias isActive="yes" isFolder="no">
<name>BackItUp_Init</name>
<script>backItUp.init(matches[2])</script>
<command></command>
<packageName></packageName>
<regex>^backup (\w+)$</regex>
</Alias>
</AliasGroup>
</AliasPackage>
<ActionPackage />
<ScriptPackage>
<ScriptGroup isActive="yes" isFolder="yes">
<name>BackItUp</name>
<packageName></packageName>
<script></script>
<eventHandlerList />
<Script isActive="yes" isFolder="no">
<name>BackItUp</name>
<packageName></packageName>
<script>backItUp = {}
backItUp.CommandSeparator = "|" -- FIXME: Change this whatever you have on CONFIG CommandSeparator
backItUp.init = function(which)
backItUp.orgname = nil
backItUp.scrollsTotal = 0
backItUp.scrolls = {}
backItUp.scrollContents = {}
backItUp.wantsMore = false
backItUp.which = which
enableTrigger("BackItUp_CaptureStartCanary")
send("ECHO ----- BACKITUP! -----" .. backItUp.CommandSeparator .. which)
end
backItUp.nextScroll = function()
if #backItUp.scrolls > 0 then
enableTrigger("BackItUp_ScrollStartLine")
if backItUp.wantsMore then
cecho("\n<orange,DarkSlateGrey>Collecting MOAR!\n")
backItUp.wantsMore = false
send("MORE")
else
backItUp.thisScroll = table.remove(backItUp.scrolls, 1)
cecho("\n<orange,DarkSlateGrey>Collecting " .. (backItUp.scrollsTotal - #backItUp.scrolls) .. " out of " .. backItUp.scrollsTotal .. " scrolls...\n")
backItUp.scrollContents[backItUp.thisScroll] = ""
send("ECHO ----- BACKITUP-SCROLL! -----" .. backItUp.CommandSeparator .. backItUp.which .. " " .. backItUp.thisScroll)
end
else
backItUp.saveScrolls()
end
end
backItUp.saveScrolls = function()
cecho("<orange,DarkSlateGrey>Saving ...\n")
local errors = {}
if not io.exists(getMudletHomeDir() .. "/backItUp") then
lfs.mkdir(getMudletHomeDir() .. "/backItUp")
end
local orgFolderName = db:safe_name(backItUp.orgname)
orgFolderName = getMudletHomeDir() .. "/backItUp/" .. orgFolderName
if not io.exists(orgFolderName) then
local x = lfs.mkdir(orgFolderName)
if not x then
table.insert(errors, "<red,DarkSlateGrey>Eep eep there was an error with creating this folder: " .. orgFolderName .. "\n")
end
end
for scroll, contents in pairs(backItUp.scrollContents) do
local scrollFile = db:safe_name(scroll) .. ".txt"
if contents ~= "There appears to be no help scroll by that name." then
local scrollFHandle = io.open(orgFolderName .. "/" .. scrollFile, 'w')
if scrollFHandle then
scrollFHandle:write(contents)
scrollFHandle:flush()
scrollFHandle:close()
else
table.insert(errors, "<red,DarkSlateGrey>Eep eep there was an error with creating this file: " .. orgFolderName .. "/" .. scrollFile .. "\n")
end
end
end
backItUp.orgname = nil
backItUp.scrolls = {}
backItUp.scrollContents = {}
if #errors > 0 then
echo("\n")
for _, err in ipairs(errors) do
cecho(err)
end
else
cecho("\n<orange,DarkSlateGrey>All done! We've slurped everything real good. Yum yum yum!\n")
cecho("<orange,DarkSlateGrey>The stuff was saved here: " .. orgFolderName)
end
end</script>
<eventHandlerList />
</Script>
</ScriptGroup>
</ScriptPackage>
<KeyPackage />
<VariablePackage>
<HiddenVariables />
</VariablePackage>
</MudletPackage>