corrade-lsl-templates – Diff between revs 41 and 42

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 41 Rev 42
1 /////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 // 2 // Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 //
3 /////////////////////////////////////////////////////////////////////////// 3 ///////////////////////////////////////////////////////////////////////////
4 // 4 //
5 // A module that bans group members using fuzzy name matching. 5 // A module that bans group members using fuzzy name matching.
6 // 6 //
7 /////////////////////////////////////////////////////////////////////////// 7 ///////////////////////////////////////////////////////////////////////////
8   8  
9 /////////////////////////////////////////////////////////////////////////// 9 ///////////////////////////////////////////////////////////////////////////
10 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 10 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
11 /////////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////////
12 string wasKeyValueGet(string k, string data) { 12 string wasKeyValueGet(string k, string data) {
13 if(llStringLength(data) == 0) return ""; 13 if(llStringLength(data) == 0) return "";
14 if(llStringLength(k) == 0) return ""; 14 if(llStringLength(k) == 0) return "";
15 list a = llParseStringKeepNulls(data, ["&", "="], []); 15 list a = llParseString2List(data, ["&", "="], []);
16 integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]); 16 integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]);
17 if(i != -1) return llList2String(a, 2*i+1); 17 if(i != -1) return llList2String(a, 2*i+1);
18 return ""; 18 return "";
19 } 19 }
20 20
21 /////////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////////
22 // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // 22 // Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 //
23 /////////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////////
24 string wasKeyValueEncode(list data) { 24 string wasKeyValueEncode(list data) {
25 list k = llList2ListStrided(data, 0, -1, 2); 25 list k = llList2ListStrided(data, 0, -1, 2);
26 list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); 26 list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2);
27 data = []; 27 data = [];
28 do { 28 do {
29 data += llList2String(k, 0) + "=" + llList2String(v, 0); 29 data += llList2String(k, 0) + "=" + llList2String(v, 0);
30 k = llDeleteSubList(k, 0, 0); 30 k = llDeleteSubList(k, 0, 0);
31 v = llDeleteSubList(v, 0, 0); 31 v = llDeleteSubList(v, 0, 0);
32 } while(llGetListLength(k) != 0); 32 } while(llGetListLength(k) != 0);
33 return llDumpList2String(data, "&"); 33 return llDumpList2String(data, "&");
34 } 34 }
35   35  
36 /////////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////////
37 // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // 37 // Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 //
38 /////////////////////////////////////////////////////////////////////////// 38 ///////////////////////////////////////////////////////////////////////////
39 // http://was.fm/secondlife/wanderer 39 // http://was.fm/secondlife/wanderer
40 vector wasCirclePoint(float radius) { 40 vector wasCirclePoint(float radius) {
41 float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); 41 float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
42 float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); 42 float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2);
43 if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) 43 if(llPow(x,2) + llPow(y,2) <= llPow(radius,2))
44 return <x, y, 0>; 44 return <x, y, 0>;
45 return wasCirclePoint(radius); 45 return wasCirclePoint(radius);
46 } 46 }
47   47  
48 /////////////////////////////////////////////////////////////////////////// 48 ///////////////////////////////////////////////////////////////////////////
49 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 49 // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 //
50 /////////////////////////////////////////////////////////////////////////// 50 ///////////////////////////////////////////////////////////////////////////
51 // escapes a string in conformance with RFC1738 51 // escapes a string in conformance with RFC1738
52 string wasURLEscape(string i) { 52 string wasURLEscape(string i) {
53 string o = ""; 53 string o = "";
54 do { 54 do {
55 string c = llGetSubString(i, 0, 0); 55 string c = llGetSubString(i, 0, 0);
56 i = llDeleteSubString(i, 0, 0); 56 i = llDeleteSubString(i, 0, 0);
57 if(c == "") jump continue; 57 if(c == "") jump continue;
58 if(c == " ") { 58 if(c == " ") {
59 o += "+"; 59 o += "+";
60 jump continue; 60 jump continue;
61 } 61 }
62 if(c == "\n") { 62 if(c == "\n") {
63 o += "%0D" + llEscapeURL(c); 63 o += "%0D" + llEscapeURL(c);
64 jump continue; 64 jump continue;
65 } 65 }
66 o += llEscapeURL(c); 66 o += llEscapeURL(c);
67 @continue; 67 @continue;
68 } while(i != ""); 68 } while(i != "");
69 return o; 69 return o;
70 } 70 }
71   71  
72 /////////////////////////////////////////////////////////////////////////// 72 ///////////////////////////////////////////////////////////////////////////
73 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 73 // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 //
74 /////////////////////////////////////////////////////////////////////////// 74 ///////////////////////////////////////////////////////////////////////////
75 list wasCSVToList(string csv) { 75 list wasCSVToList(string csv) {
76 list l = []; 76 list l = [];
77 list s = []; 77 list s = [];
78 string m = ""; 78 string m = "";
79 do { 79 do {
80 string a = llGetSubString(csv, 0, 0); 80 string a = llGetSubString(csv, 0, 0);
81 csv = llDeleteSubString(csv, 0, 0); 81 csv = llDeleteSubString(csv, 0, 0);
82 if(a == ",") { 82 if(a == ",") {
83 if(llList2String(s, -1) != "\"") { 83 if(llList2String(s, -1) != "\"") {
84 l += m; 84 l += m;
85 m = ""; 85 m = "";
86 jump continue; 86 jump continue;
87 } 87 }
88 m += a; 88 m += a;
89 jump continue; 89 jump continue;
90 } 90 }
91 if(a == "\"" && llGetSubString(csv, 0, 0) == a) { 91 if(a == "\"" && llGetSubString(csv, 0, 0) == a) {
92 m += a; 92 m += a;
93 csv = llDeleteSubString(csv, 0, 0); 93 csv = llDeleteSubString(csv, 0, 0);
94 jump continue; 94 jump continue;
95 } 95 }
96 if(a == "\"") { 96 if(a == "\"") {
97 if(llList2String(s, -1) != a) { 97 if(llList2String(s, -1) != a) {
98 s += a; 98 s += a;
99 jump continue; 99 jump continue;
100 } 100 }
101 s = llDeleteSubList(s, -1, -1); 101 s = llDeleteSubList(s, -1, -1);
102 jump continue; 102 jump continue;
103 } 103 }
104 m += a; 104 m += a;
105 @continue; 105 @continue;
106 } while(csv != ""); 106 } while(csv != "");
107 // postcondition: length(s) = 0 107 // postcondition: length(s) = 0
108 return l + m; 108 return l + m;
109 } 109 }
110   110  
111 /////////////////////////////////////////////////////////////////////////// 111 ///////////////////////////////////////////////////////////////////////////
112 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 112 // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 //
113 /////////////////////////////////////////////////////////////////////////// 113 ///////////////////////////////////////////////////////////////////////////
114 string wasListToCSV(list l) { 114 string wasListToCSV(list l) {
115 list v = []; 115 list v = [];
116 do { 116 do {
117 string a = llDumpList2String( 117 string a = llDumpList2String(
118 llParseStringKeepNulls( 118 llParseStringKeepNulls(
119 llList2String( 119 llList2String(
120 l, 120 l,
121 0 121 0
122 ), 122 ),
123 ["\""], 123 ["\""],
124 [] 124 []
125 ), 125 ),
126 "\"\"" 126 "\"\""
127 ); 127 );
128 if(llParseStringKeepNulls( 128 if(llParseStringKeepNulls(
129 a, 129 a,
130 [" ", ",", "\n", "\""], [] 130 [" ", ",", "\n", "\""], []
131 ) != 131 ) !=
132 (list) a 132 (list) a
133 ) a = "\"" + a + "\""; 133 ) a = "\"" + a + "\"";
134 v += a; 134 v += a;
135 l = llDeleteSubList(l, 0, 0); 135 l = llDeleteSubList(l, 0, 0);
136 } while(l != []); 136 } while(l != []);
137 return llDumpList2String(v, ","); 137 return llDumpList2String(v, ",");
138 } 138 }
139   139  
140 /////////////////////////////////////////////////////////////////////////// 140 ///////////////////////////////////////////////////////////////////////////
141 // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // 141 // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 //
142 /////////////////////////////////////////////////////////////////////////// 142 ///////////////////////////////////////////////////////////////////////////
143 // unescapes a string in conformance with RFC1738 143 // unescapes a string in conformance with RFC1738
144 string wasURLUnescape(string i) { 144 string wasURLUnescape(string i) {
145 return llUnescapeURL( 145 return llUnescapeURL(
146 llDumpList2String( 146 llDumpList2String(
147 llParseString2List( 147 llParseString2List(
148 llDumpList2String( 148 llDumpList2String(
149 llParseString2List( 149 llParseString2List(
150 i, 150 i,
151 ["+"], 151 ["+"],
152 [] 152 []
153 ), 153 ),
154 " " 154 " "
155 ), 155 ),
156 ["%0D%0A"], 156 ["%0D%0A"],
157 [] 157 []
158 ), 158 ),
159 "\n" 159 "\n"
160 ) 160 )
161 ); 161 );
162 } 162 }
163   163  
164 /////////////////////////////////////////////////////////////////////////// 164 ///////////////////////////////////////////////////////////////////////////
165 // Copyright (C) 2017 Wizardry and Steamworks - License: CC BY 2.0 // 165 // Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 //
166 /////////////////////////////////////////////////////////////////////////// 166 ///////////////////////////////////////////////////////////////////////////
167 list wasSetIntersect(list a, list b) { 167 list wasSetIntersect(list a, list b) {
168 if(llGetListLength(a) == 0) return []; 168 if(llGetListLength(a) == 0) return [];
169 string i = llList2String(a, 0); 169 string i = llList2String(a, 0);
170 a = llDeleteSubList(a, 0, 0); 170 a = llDeleteSubList(a, 0, 0);
171 if(llListFindList(b, (list)i) == -1) 171 if(llListFindList(b, (list)i) == -1)
172 return wasSetIntersect(a, b); 172 return wasSetIntersect(a, b);
173 return i + wasSetIntersect(a, b); 173 return i + wasSetIntersect(a, b);
174 } 174 }
175   175  
176 // configuration data 176 // configuration data
177 string configuration = ""; 177 string configuration = "";
178 // callback URL -  
179 string URL = ""; -  
180 // store message over state. 178 // store message over state.
181 string data = ""; 179 string data = "";
182 // banee 180 // banee
183 string firstname = ""; 181 string firstname = "";
184 string lastname = ""; 182 string lastname = "";
185 integer bantime = 4320; 183 integer bantime = 4320;
186   184  
187 default { 185 default {
188 state_entry() { 186 state_entry() {
189 llOwnerSay("[Softban] Starting..."); 187 llOwnerSay("[Softban] Starting...");
190 llSetTimerEvent(10); 188 llSetTimerEvent(10);
191 } 189 }
192 link_message(integer sender, integer num, string message, key id) { 190 link_message(integer sender, integer num, string message, key id) {
193 if(id != "configuration") return; 191 if(id != "configuration") return;
194 llOwnerSay("[Softban] Got configuration..."); 192 llOwnerSay("[Softban] Got configuration...");
195 configuration = message; 193 configuration = message;
196 state listen_group; 194 state listen_group;
197 } 195 }
198 timer() { 196 timer() {
199 llOwnerSay("[Softban] Requesting configuration..."); 197 llOwnerSay("[Softban] Requesting configuration...");
200 llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY); 198 llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY);
201 } 199 }
202 on_rez(integer num) { 200 on_rez(integer num) {
203 llResetScript(); 201 llResetScript();
204 } 202 }
205 changed(integer change) { 203 changed(integer change) {
206 if((change & CHANGED_INVENTORY) || 204 if((change & CHANGED_INVENTORY) ||
207 (change & CHANGED_REGION_START) || 205 (change & CHANGED_REGION_START) ||
208 (change & CHANGED_OWNER)) { 206 (change & CHANGED_OWNER)) {
209 llResetScript(); 207 llResetScript();
210 } 208 }
211 } 209 }
212 state_exit() { 210 state_exit() {
213 llSetTimerEvent(0); 211 llSetTimerEvent(0);
214 } 212 }
215 } 213 }
216   214  
217 state listen_group { 215 state listen_group {
218 state_entry() { 216 state_entry() {
219 // DEBUG 217 // DEBUG
220 llOwnerSay("[Softban] Waiting for group messages..."); 218 llOwnerSay("[Softban] Waiting for group messages...");
221 } 219 }
222 link_message(integer sender, integer num, string message, key id) { 220 link_message(integer sender, integer num, string message, key id) {
223 // We only care about notifications now. 221 // We only care about notifications now.
224 if(id != "notification") 222 if(id != "notification")
225 return; 223 return;
226 224
227 // This script only processes group notifications. 225 // This script only processes group notifications.
228 if(wasKeyValueGet("type", message) != "group") 226 if(wasKeyValueGet("type", message) != "group" ||
-   227 (wasKeyValueGet("type", message) == "group" &&
-   228 wasURLUnescape(wasKeyValueGet("group", message)) !=
-   229 wasKeyValueGet("group", configuration)))
229 return; 230 return;
230 231
231 // Get the sent message. 232 // Get the sent message.
232 data = wasURLUnescape( 233 data = wasURLUnescape(
233 wasKeyValueGet( 234 wasKeyValueGet(
234 "message", 235 "message",
235 message 236 message
236 ) 237 )
237 ); 238 );
238 239
239 // Check if this is an eggdrop command. 240 // Check if this is an eggdrop command.
240 if(llGetSubString(data, 0, 0) != 241 if(llGetSubString(data, 0, 0) !=
241 wasKeyValueGet("command", configuration)) 242 wasKeyValueGet("command", configuration))
242 return; 243 return;
243 244
244 // Check if the command matches the current module. 245 // Check if the command matches the current module.
245 list command = llParseString2List(data, [" "], []); 246 list command = llParseString2List(data, [" "], []);
246 if(llList2String(command, 0) != 247 if(llList2String(command, 0) !=
247 wasKeyValueGet("command", configuration) + "softban") 248 wasKeyValueGet("command", configuration) + "softban")
248 return; 249 return;
249 250
250 // Remove command. 251 // Remove command.
251 command = llDeleteSubList(command, 0, 0); 252 command = llDeleteSubList(command, 0, 0);
252 253
253 firstname = wasKeyValueGet("firstname", message); 254 firstname = wasKeyValueGet("firstname", message);
254 lastname = wasKeyValueGet("lastname", message); 255 lastname = wasKeyValueGet("lastname", message);
255 256
256 if(firstname == "" || lastname == "") { 257 if(firstname == "" || lastname == "") {
257 data = "And who would yarr be?"; 258 data = "And who would yarr be?";
258 state tell; 259 state tell;
259 } 260 }
260 261
261 // Dump the rest of the message. 262 // Dump the rest of the message.
262 data = llDumpList2String(command, " "); 263 data = llDumpList2String(command, " ");
263 264
264 // Get an URL. -  
265 state url; -  
266 } -  
267 on_rez(integer num) { -  
268 llResetScript(); -  
269 } -  
270 changed(integer change) { -  
271 if((change & CHANGED_INVENTORY) || -  
272 (change & CHANGED_REGION_START) || -  
273 (change & CHANGED_OWNER)) { -  
274 llResetScript(); -  
275 } -  
276 } -  
277 } -  
278   -  
279 state url { -  
280 state_entry() { -  
281 // DEBUG -  
282 llOwnerSay("[Softban] Requesting URL..."); -  
283 llRequestURL(); -  
284 } -  
285 http_request(key id, string method, string body) { -  
286 if(method != URL_REQUEST_GRANTED) return; -  
287 URL = body; -  
288 // DEBUG -  
289 llOwnerSay("[Softban] Got URL..."); 265 // Get roles of callers.
290 state get_caller_roles; 266 state get_caller_roles;
291 } 267 }
292 on_rez(integer num) { 268 on_rez(integer num) {
293 llResetScript(); 269 llResetScript();
294 } 270 }
295 changed(integer change) { 271 changed(integer change) {
296 if((change & CHANGED_INVENTORY) || 272 if((change & CHANGED_INVENTORY) ||
297 (change & CHANGED_REGION_START) || 273 (change & CHANGED_REGION_START) ||
298 (change & CHANGED_OWNER)) { 274 (change & CHANGED_OWNER)) {
299 llResetScript(); 275 llResetScript();
300 } 276 }
301 } 277 }
302 } 278 }
303   279  
304 state get_caller_roles { 280 state get_caller_roles {
305 state_entry() { 281 state_entry() {
306 // DEBUG 282 // DEBUG
307 llOwnerSay("[Softban] Searching for caller..."); 283 llOwnerSay("[Softban] Searching for caller...");
308 llInstantMessage( 284 llInstantMessage(
309 wasKeyValueGet( 285 wasKeyValueGet(
310 "corrade", 286 "corrade",
311 configuration 287 configuration
312 ), 288 ),
313 wasKeyValueEncode( 289 wasKeyValueEncode(
314 [ 290 [
315 "command", "getmemberroles", 291 "command", "getmemberroles",
316 "group", wasURLEscape( 292 "group", wasURLEscape(
317 wasKeyValueGet( 293 wasKeyValueGet(
318 "group", 294 "group",
319 configuration 295 configuration
320 ) 296 )
321 ), 297 ),
322 "password", wasURLEscape( 298 "password", wasURLEscape(
323 wasKeyValueGet( 299 wasKeyValueGet(
324 "password", 300 "password",
325 configuration 301 configuration
326 ) 302 )
327 ), 303 ),
328 "firstname", firstname, 304 "firstname", firstname,
329 "lastname", lastname, 305 "lastname", lastname,
330 "callback", wasURLEscape(URL) 306 "callback", wasURLEscape(
-   307 wasKeyValueGet(
-   308 "URL",
-   309 configuration
-   310 )
-   311 )
331 ] 312 ]
332 ) 313 )
333 ); 314 );
334 llSetTimerEvent(60); 315 llSetTimerEvent(60);
335 } 316 }
336 http_request(key id, string method, string body) { 317 link_message(integer sender, integer num, string body, key id) {
337 llHTTPResponse(id, 200, "OK"); 318 // Only process callbacks for the database command.
338 if(wasKeyValueGet("command", body) != "getmemberroles" || 319 if(id != "callback" || wasKeyValueGet("command", body) != "getmemberroles")
-   320 return;
-   321
339 wasKeyValueGet("success", body) != "True") { 322 if(wasKeyValueGet("success", body) != "True") {
340 // DEBUG 323 // DEBUG
341 llOwnerSay("[Softban] Unable to get member roles: " + 324 llOwnerSay("[Softban] Unable to get member roles: " +
342 wasURLUnescape( 325 wasURLUnescape(
343 wasKeyValueGet("error", body) 326 wasKeyValueGet("error", body)
344 ) 327 )
345 ); 328 );
346 llReleaseURL(URL); -  
347 state listen_group; 329 state listen_group;
348 } 330 }
349 331
350 // Dump the roles to a list. 332 // Dump the roles to a list.
351 list roles = wasCSVToList( 333 list roles = wasCSVToList(
352 wasURLUnescape( 334 wasURLUnescape(
353 wasKeyValueGet("data", body) 335 wasKeyValueGet("data", body)
354 ) 336 )
355 ); 337 );
356 338
357 if(llGetListLength( 339 if(llGetListLength(
358 wasSetIntersect(roles, 340 wasSetIntersect(roles,
359 wasCSVToList( 341 wasCSVToList(
360 wasKeyValueGet( 342 wasKeyValueGet(
361 "admin roles", configuration 343 "admin roles", configuration
362 ) 344 )
363 ) 345 )
364 ) 346 )
365 ) == 0) { 347 ) == 0) {
366 data = "You ain't got the cojones!"; 348 data = "You ain't got the cojones!";
367 llReleaseURL(URL); -  
368 state tell; 349 state tell;
369 } 350 }
370 351
371 list banee = llParseString2List(data, [" "], []); 352 list banee = llParseString2List(data, [" "], []);
372 353
373 firstname = llList2String(banee, 0); 354 firstname = llList2String(banee, 0);
374 banee = llDeleteSubList(banee, 0, 0); 355 banee = llDeleteSubList(banee, 0, 0);
375 lastname = llList2String(banee, 0); 356 lastname = llList2String(banee, 0);
376 banee = llDeleteSubList(banee, 0, 0); 357 banee = llDeleteSubList(banee, 0, 0);
377 358
378 if(firstname == "" || lastname == "") { 359 if(firstname == "" || lastname == "") {
379 data = "Full name required."; 360 data = "Full name required.";
380 state tell; 361 state tell;
381 } 362 }
382 363
383 if(llGetListLength(banee) != 0 && llList2Integer(banee, 0) != 0) { 364 if(llGetListLength(banee) != 0 && llList2Integer(banee, 0) != 0) {
384 bantime = llList2Integer(banee, 0); 365 bantime = llList2Integer(banee, 0);
385 banee = llDeleteSubList(banee, 0, 0); 366 banee = llDeleteSubList(banee, 0, 0);
386 } 367 }
387 368
388 // GC 369 // GC
389 banee = []; 370 banee = [];
390 state get_banee_roles; 371 state get_banee_roles;
391 } 372 }
392 timer() { 373 timer() {
393 llReleaseURL(URL); -  
394 state listen_group; 374 state listen_group;
395 } 375 }
396 on_rez(integer num) { 376 on_rez(integer num) {
397 llResetScript(); 377 llResetScript();
398 } 378 }
399 changed(integer change) { 379 changed(integer change) {
400 if((change & CHANGED_INVENTORY) || 380 if((change & CHANGED_INVENTORY) ||
401 (change & CHANGED_REGION_START) || 381 (change & CHANGED_REGION_START) ||
402 (change & CHANGED_OWNER)) { 382 (change & CHANGED_OWNER)) {
403 llResetScript(); 383 llResetScript();
404 } 384 }
405 } 385 }
406 state_exit() { 386 state_exit() {
407 llSetTimerEvent(0); 387 llSetTimerEvent(0);
408 } 388 }
409 } 389 }
410   390  
411 state get_banee_roles { 391 state get_banee_roles {
412 state_entry() { 392 state_entry() {
413 // DEBUG 393 // DEBUG
414 llOwnerSay("[Softban] Searching for banee..."); 394 llOwnerSay("[Softban] Searching for banee...");
415 llInstantMessage( 395 llInstantMessage(
416 wasKeyValueGet( 396 wasKeyValueGet(
417 "corrade", 397 "corrade",
418 configuration 398 configuration
419 ), 399 ),
420 wasKeyValueEncode( 400 wasKeyValueEncode(
421 [ 401 [
422 "command", "getmemberroles", 402 "command", "getmemberroles",
423 "group", wasURLEscape( 403 "group", wasURLEscape(
424 wasKeyValueGet( 404 wasKeyValueGet(
425 "group", 405 "group",
426 configuration 406 configuration
427 ) 407 )
428 ), 408 ),
429 "password", wasURLEscape( 409 "password", wasURLEscape(
430 wasKeyValueGet( 410 wasKeyValueGet(
431 "password", 411 "password",
432 configuration 412 configuration
433 ) 413 )
434 ), 414 ),
435 "firstname", firstname, 415 "firstname", firstname,
436 "lastname", lastname, 416 "lastname", lastname,
437 "callback", wasURLEscape(URL) 417 "callback", wasURLEscape(
-   418 wasKeyValueGet(
-   419 "URL",
-   420 configuration
-   421 )
-   422 )
438 ] 423 ]
439 ) 424 )
440 ); 425 );
441 llSetTimerEvent(60); 426 llSetTimerEvent(60);
442 } 427 }
443 http_request(key id, string method, string body) { 428 link_message(integer sender, integer num, string body, key id) {
444 llHTTPResponse(id, 200, "OK"); 429 // Only process callbacks for the database command.
445 if(wasKeyValueGet("command", body) != "getmemberroles" || 430 if(id != "callback" || wasKeyValueGet("command", body) != "getmemberroles")
-   431 return;
-   432
446 wasKeyValueGet("success", body) != "True") { 433 if(wasKeyValueGet("success", body) != "True") {
447 if(wasKeyValueGet("status", body) == "19862") { 434 if(wasKeyValueGet("status", body) == "19862") {
448 // DEBUG 435 // DEBUG
449 llOwnerSay("[Softban] User not in group, but proceeding anyway..."); 436 llOwnerSay("[Softban] User not in group, but proceeding anyway...");
450 jump continue; 437 jump continue;
451 } 438 }
452 // DEBUG 439 // DEBUG
453 llOwnerSay("[Softban] Unable to get member roles: " + 440 llOwnerSay("[Softban] Unable to get member roles: " +
454 wasURLUnescape( 441 wasURLUnescape(
455 wasKeyValueGet("error", body) 442 wasKeyValueGet("error", body)
456 ) 443 )
457 ); 444 );
458 llReleaseURL(URL); -  
459 state listen_group; 445 state listen_group;
460 } 446 }
461 447
462 @continue; 448 @continue;
463 string result = wasURLUnescape( 449 string result = wasURLUnescape(
464 wasKeyValueGet("data", body) 450 wasKeyValueGet("data", body)
465 ); 451 );
466 452
467 if(result != "" && llListFindList(wasCSVToList(result), (list)"Owners") != -1) { 453 if(result != "" && llListFindList(wasCSVToList(result), (list)"Owners") != -1) {
468 data = "Ejectee is an owner. I'm not gunna open the pod bay doors."; 454 data = "Ejectee is an owner. I'm not gunna open the pod bay doors.";
469 llReleaseURL(URL); -  
470 state tell; 455 state tell;
471 } 456 }
472 457
473 state ban; 458 state ban;
474 } 459 }
475 timer() { 460 timer() {
476 llReleaseURL(URL); -  
477 state listen_group; 461 state listen_group;
478 } 462 }
479 on_rez(integer num) { 463 on_rez(integer num) {
480 llResetScript(); 464 llResetScript();
481 } 465 }
482 changed(integer change) { 466 changed(integer change) {
483 if((change & CHANGED_INVENTORY) || 467 if((change & CHANGED_INVENTORY) ||
484 (change & CHANGED_REGION_START) || 468 (change & CHANGED_REGION_START) ||
485 (change & CHANGED_OWNER)) { 469 (change & CHANGED_OWNER)) {
486 llResetScript(); 470 llResetScript();
487 } 471 }
488 } 472 }
489 state_exit() { 473 state_exit() {
490 llSetTimerEvent(0); 474 llSetTimerEvent(0);
491 } 475 }
492 } 476 }
493   477  
494 state ban { 478 state ban {
495 state_entry() { 479 state_entry() {
496 // DEBUG 480 // DEBUG
497 llOwnerSay("[Softban] Banning..."); 481 llOwnerSay("[Softban] Banning...");
498 llInstantMessage( 482 llInstantMessage(
499 wasKeyValueGet( 483 wasKeyValueGet(
500 "corrade", 484 "corrade",
501 configuration 485 configuration
502 ), 486 ),
503 wasKeyValueEncode( 487 wasKeyValueEncode(
504 [ 488 [
505 "command", "softban", 489 "command", "softban",
506 "group", wasURLEscape( 490 "group", wasURLEscape(
507 wasKeyValueGet( 491 wasKeyValueGet(
508 "group", 492 "group",
509 configuration 493 configuration
510 ) 494 )
511 ), 495 ),
512 "password", wasURLEscape( 496 "password", wasURLEscape(
513 wasKeyValueGet( 497 wasKeyValueGet(
514 "password", 498 "password",
515 configuration 499 configuration
516 ) 500 )
517 ), 501 ),
518 "action", "ban", 502 "action", "ban",
519 "avatars", wasURLEscape( 503 "avatars", wasURLEscape(
520 wasListToCSV( 504 wasListToCSV(
521 [ 505 [
522 firstname + " " + lastname 506 firstname + " " + lastname
523 ] 507 ]
524 ) 508 )
525 ), 509 ),
526 "time", wasURLEscape( 510 "time", wasURLEscape(
527 wasListToCSV( 511 wasListToCSV(
528 [ 512 [
529 bantime 513 bantime
530 ] 514 ]
531 ) 515 )
532 ), 516 ),
533 "callback", wasURLEscape(URL) 517 "callback", wasURLEscape(
-   518 wasKeyValueGet(
-   519 "URL",
-   520 configuration
-   521 )
-   522 )
534 ] 523 ]
535 ) 524 )
536 ); 525 );
537 llSetTimerEvent(60); 526 llSetTimerEvent(60);
538 } 527 }
539 http_request(key id, string method, string body) { 528 link_message(integer sender, integer num, string body, key id) {
540 llHTTPResponse(id, 200, "OK"); 529 // Only process callbacks for the database command.
-   530 if(id != "callback" || wasKeyValueGet("command", body) != "softban")
541 llReleaseURL(URL); 531 return;
-   532
542 if(wasKeyValueGet("command", body) != "softban" || 533 if(wasKeyValueGet("command", body) != "softban" ||
543 wasKeyValueGet("success", body) != "True") { 534 wasKeyValueGet("success", body) != "True") {
544 // DEBUG 535 // DEBUG
545 llOwnerSay("[Softban] Unable to soft ban member: " + 536 llOwnerSay("[Softban] Unable to soft ban member: " +
546 wasURLUnescape( 537 wasURLUnescape(
547 wasKeyValueGet("error", body) 538 wasKeyValueGet("error", body)
548 ) 539 )
549 ); 540 );
550 state listen_group; 541 state listen_group;
551 } 542 }
552 543
553 data = "Hasta la vista, baby!"; 544 data = "Hasta la vista, baby!";
554 545
555 state tell; 546 state tell;
556 } 547 }
557 timer() { 548 timer() {
558 llReleaseURL(URL); -  
559 state listen_group; 549 state listen_group;
560 } 550 }
561 on_rez(integer num) { 551 on_rez(integer num) {
562 llResetScript(); 552 llResetScript();
563 } 553 }
564 changed(integer change) { 554 changed(integer change) {
565 if((change & CHANGED_INVENTORY) || 555 if((change & CHANGED_INVENTORY) ||
566 (change & CHANGED_REGION_START) || 556 (change & CHANGED_REGION_START) ||
567 (change & CHANGED_OWNER)) { 557 (change & CHANGED_OWNER)) {
568 llResetScript(); 558 llResetScript();
569 } 559 }
570 } 560 }
571 state_exit() { 561 state_exit() {
572 llSetTimerEvent(0); 562 llSetTimerEvent(0);
573 } 563 }
574 } 564 }
575   565  
576 state tell { 566 state tell {
577 state_entry() { 567 state_entry() {
578 // DEBUG 568 // DEBUG
579 llOwnerSay("[Softban] Sending to group."); 569 llOwnerSay("[Softban] Sending to group.");
580 llInstantMessage( 570 llInstantMessage(
581 wasKeyValueGet( 571 wasKeyValueGet(
582 "corrade", 572 "corrade",
583 configuration 573 configuration
584 ), 574 ),
585 wasKeyValueEncode( 575 wasKeyValueEncode(
586 [ 576 [
587 "command", "tell", 577 "command", "tell",
588 "group", wasURLEscape( 578 "group", wasURLEscape(
589 wasKeyValueGet( 579 wasKeyValueGet(
590 "group", 580 "group",
591 configuration 581 configuration
592 ) 582 )
593 ), 583 ),
594 "password", wasURLEscape( 584 "password", wasURLEscape(
595 wasKeyValueGet( 585 wasKeyValueGet(
596 "password", 586 "password",
597 configuration 587 configuration
598 ) 588 )
599 ), 589 ),
600 "entity", "group", 590 "entity", "group",
601 "message", wasURLEscape(data) 591 "message", wasURLEscape(data)
602 ] 592 ]
603 ) 593 )
604 ); 594 );
605 595
606 // reset variables. 596 // reset variables.
607 bantime = 4320; 597 bantime = 4320;
608 598
609 state listen_group; 599 state listen_group;
610 } 600 }
611 } 601 }
612   602