-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathRandom_Socials.xml
324 lines (246 loc) · 6.62 KB
/
Random_Socials.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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient [
<!ENTITY socials_command "socials" >
<!ENTITY end_socials_regexp "\>" >
<!ENTITY timer_interval "30" >
]>
<!--
Customising (change above entities) ...
Change "socials_command" to whatever sends a list of socials.
Default: socials
Change "end_socials_regexp" to whatever will *not* be in a socials line.
Default: >
Change "timer_interval" to be the number of seconds between checking for socials.
Default: 10 seconds
(Note - every "timer_interval" seconds there is a 20% chance that the social will be sent.)
-->
<muclient>
<plugin name="Random_Socials"
author="Nick Gammon"
language="vbscript"
id = "982581e59ab42844527eec80"
purpose = "Displays a random social from time to time"
save_state = "y"
version = "1.1"
>
<description trim="y">
<![CDATA[
This plugin checks to see if it has a list of socials (in the "socials" variable).
If not, it sends "socials" to the MUD to build a list.
Then, every 10 seconds it has a 20% chance of displaying one picked at random.
Commands
--------
socials:help - shows this description in the output window
socials:remove:all - removes all socials (ie. reloads the list)
socials:remove X - removes social X from the list (eg. social:remove burp)
]]>
</description>
</plugin>
<!-- Get our standard VB constants -->
<include name="constants.vbs"/>
<!-- =============================================
Sub "SocialsList" - collects a list of socials.
============================================= -->
<script>
<![CDATA[
dim SocialsList ' store list of socials
Randomize ' Initialize random-number generator.
sub GetSocials
world.setvariable "socials", ""
world.enabletrigger "Collect_Socials", 1
'
' cancel CDATA so we can use the entity (from DOCTYPE header)
'
]]>
world.send "&socials_command;"
<![CDATA[
world.note "Collecting list of socials ..."
end sub
]]>
</script>
<!-- =============================================
Timer: RandomSocial
Script: DoRandomSocial
Purpose: Chooses a social at random, builds the list if necessary
============================================= -->
<timers>
<timer
name="RandomSocial"
script="DoRandomSocial"
enabled="y"
second="&timer_interval;"
>
</timer>
</timers>
<script>
<![CDATA[
Sub DoRandomSocial (strTimerName)
'
' Wait a minute after connecting to let them put in the character name and password
'
If DateDiff ("n", World.GetInfo (301), Now) < 1 Then
Exit Sub
End If
'
' If collecting socials, list, just wait for it to finish
'
If World.GetTriggerInfo ("Collect_Socials", 8) then
Exit Sub
End If
'
' If no socials list, get one
'
If IsEmpty (SocialsList) Then
If world.getvariable ("socials") = "" Then
Call GetSocials
Else
SocialsList = split (world.getvariable ("socials"))
End If
Exit Sub
End If
'
' Do a random social
'
If Rnd < 0.2 Then
World.Send SocialsList ( Rnd * Ubound (SocialsList))
End If
End Sub
]]>
</script>
<!-- =============================================
Trigger: Collect_Socials
Script: Do_Collect_Socials
Purpose: Matches a line of socials
============================================= -->
<triggers>
<trigger
custom_colour="2"
match="^[A-Za-z ]+$"
name="Collect_Socials"
regexp="y"
script="Do_Collect_Socials"
sequence="100"
>
</trigger>
</triggers>
<script>
<![CDATA[
sub Do_Collect_Socials (sName, sLine, wildcards)
world.enabletrigger "End_Socials", 1
sLine = Trim (sLine)
while Instr (sLine, " ") > 0
sLine = world.Replace (sLine, " ", " ", 1)
wend
world.setvariable "socials", _
world.getvariable ("socials") & " " & sLine
end sub
]]>
</script>
<!-- =============================================
Trigger: End_Socials
Script: Do_End_Socials
Purpose: Detects end of socials list - in this case we look for the < at the
start of a MUD prompt, but you could look for anything that wouldn't be
a social line.
============================================= -->
<triggers>
<trigger
custom_colour="1"
match="&end_socials_regexp;"
name="End_Socials"
regexp="y"
script="Do_End_Socials"
sequence="100"
>
</trigger>
</triggers>
<script>
<![CDATA[
sub Do_End_Socials (sName, sLine, wildcards)
world.note "End of socials list detected. Random socials now active."
world.enabletrigger "Collect_Socials", 0
world.enabletrigger "End_Socials", 0
SocialsList = split (world.getvariable ("socials"))
end sub
]]>
</script>
<!-- =============================================
Alias: Remove_Social
Script: Do_Remove_Social
Purpose: Removes a social from the list (eg. it might be inappropriate)
============================================= -->
<aliases>
<alias
name="Remove_Social"
script="Do_Remove_Social"
match="^socials\:remove ([A-Za-z]+)$"
enabled="y"
regexp="y"
>
</alias>
</aliases>
<script>
<![CDATA[
sub Do_Remove_Social (sName, sLine, wildcards)
If not Instr (world.GetVariable ("socials") & " ", wildcards (1) & " ") > 0 then
world.note "Social " & wildcards (1) & " was not in the list."
Exit Sub
End If
'
' Remove the specified social from the list
'
world.SetVariable "socials", _
Trim (world.Replace (world.GetVariable ("socials") & " ", _
wildcards (1) & " ", "", 1))
world.note "Removed social " & wildcards (1) & " from the list."
'
' Regenerate the list
'
SocialsList = split (world.getvariable ("socials"))
end sub
]]>
</script>
<!-- =============================================
Alias: Remove_All_Socials
Script: Do_Remove_All_Socials
Purpose: Removes all socials (ie. forces list to be regenerated)
============================================= -->
<aliases>
<alias
name="Remove_All_Socials"
script="Do_Remove_All_Socials"
match="socials:remove:all"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
sub Do_Remove_All_Socials (sName, sLine, wildcards)
World.SetVariable "socials", ""
SocialsList = Empty
World.Note "All socials removed from list."
end sub
]]>
</script>
<!-- =============================================
Alias: socials:help
Script: OnHelp
Purpose: Shows plugin help
============================================= -->
<aliases>
<alias
script="OnHelp"
match="socials:help"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
sub OnHelp (sName, sLine, wildcards)
world.note world.getplugininfo (world.getpluginid, 3)
end sub
]]>
</script>
</muclient>