corrade-lsl-templates – Diff between revs 41 and 42
?pathlinks?
Rev 41 | Rev 42 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
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 unbans group members using fuzzy name matching. |
5 | // A module that unbans group members using fuzzy name matching. |
|
6 | // |
6 | // |
|
7 | /////////////////////////////////////////////////////////////////////////// |
7 | /////////////////////////////////////////////////////////////////////////// |
|
Line 17... | Line 17... | |||
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 | } |
|
Line 20... | Line 20... | |||
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); |
|
Line 32... | Line 32... | |||
32 | } while(llGetListLength(k) != 0); |
32 | } while(llGetListLength(k) != 0); |
|
33 | return llDumpList2String(data, "&"); |
33 | return llDumpList2String(data, "&"); |
|
34 | } |
34 | } |
|
Line 35... | Line 35... | |||
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); |
|
Line 44... | Line 44... | |||
44 | return <x, y, 0>; |
44 | return <x, y, 0>; |
|
45 | return wasCirclePoint(radius); |
45 | return wasCirclePoint(radius); |
|
46 | } |
46 | } |
|
Line 47... | Line 47... | |||
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 = ""; |
|
Line 68... | Line 68... | |||
68 | } while(i != ""); |
68 | } while(i != ""); |
|
69 | return o; |
69 | return o; |
|
70 | } |
70 | } |
|
Line 71... | Line 71... | |||
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 = []; |
|
Line 107... | Line 107... | |||
107 | // postcondition: length(s) = 0 |
107 | // postcondition: length(s) = 0 |
|
108 | return l + m; |
108 | return l + m; |
|
109 | } |
109 | } |
|
Line 110... | Line 110... | |||
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 { |
|
Line 136... | Line 136... | |||
136 | } while(l != []); |
136 | } while(l != []); |
|
137 | return llDumpList2String(v, ","); |
137 | return llDumpList2String(v, ","); |
|
138 | } |
138 | } |
|
Line 139... | Line 139... | |||
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( |
|
Line 160... | Line 160... | |||
160 | ) |
160 | ) |
|
161 | ); |
161 | ); |
|
162 | } |
162 | } |
|
Line 163... | Line 163... | |||
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); |
|
Line 173... | Line 173... | |||
173 | return i + wasSetIntersect(a, b); |
173 | return i + wasSetIntersect(a, b); |
|
174 | } |
174 | } |
|
Line 175... | Line 175... | |||
175 | |
175 | |
|
176 | // configuration data |
176 | // configuration data |
|
177 | string configuration = ""; |
- | ||
178 | // callback URL |
- | ||
179 | string URL = ""; |
177 | string configuration = ""; |
|
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 = ""; |
|
Line 223... | Line 221... | |||
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; |
|
Line 226... | Line 224... | |||
226 | |
224 | |
|
227 | // This script only processes group notifications. |
225 | // This script only processes group notifications. |
|
- | 226 | if(wasKeyValueGet("type", message) != "group" || |
||
- | 227 | (wasKeyValueGet("type", message) == "group" && |
||
- | 228 | wasURLUnescape(wasKeyValueGet("group", message)) != |
||
228 | if(wasKeyValueGet("type", message) != "group") |
229 | wasKeyValueGet("group", configuration))) |
|
Line 229... | Line 230... | |||
229 | return; |
230 | return; |
|
230 | |
231 | |
|
231 | // Get the sent message. |
232 | // Get the sent message. |
|
Line 259... | Line 260... | |||
259 | } |
260 | } |
|
Line 260... | Line 261... | |||
260 | |
261 | |
|
261 | // Dump the rest of the message. |
262 | // Dump the rest of the message. |
|
Line 262... | Line 263... | |||
262 | data = llDumpList2String(command, " "); |
263 | data = llDumpList2String(command, " "); |
|
263 | |
- | ||
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("[Unban] 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 |
264 | |
|
289 | llOwnerSay("[Unban] Got URL..."); |
265 | // Get roles of caller. |
|
290 | state get_caller_roles; |
266 | state get_caller_roles; |
|
291 | } |
267 | } |
|
292 | on_rez(integer num) { |
268 | on_rez(integer num) { |
|
Line 325... | Line 301... | |||
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("[Unban] Unable to get member roles: " + |
324 | llOwnerSay("[Unban] 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 | } |
|
Line 349... | Line 331... | |||
349 | |
331 | |
|
350 | // Dump the roles to a list. |
332 | // Dump the roles to a list. |
|
Line 362... | Line 344... | |||
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 | } |
|
Line 370... | Line 351... | |||
370 | |
351 | |
|
Line 389... | Line 370... | |||
389 | // GC |
370 | // GC |
|
390 | banee = []; |
371 | banee = []; |
|
391 | state get_banee_roles; |
372 | state get_banee_roles; |
|
392 | } |
373 | } |
|
393 | timer() { |
374 | timer() { |
|
394 | llReleaseURL(URL); |
- | ||
395 | state listen_group; |
375 | state listen_group; |
|
396 | } |
376 | } |
|
397 | on_rez(integer num) { |
377 | on_rez(integer num) { |
|
398 | llResetScript(); |
378 | llResetScript(); |
|
399 | } |
379 | } |
|
Line 433... | Line 413... | |||
433 | configuration |
413 | configuration |
|
434 | ) |
414 | ) |
|
435 | ), |
415 | ), |
|
436 | "firstname", firstname, |
416 | "firstname", firstname, |
|
437 | "lastname", lastname, |
417 | "lastname", lastname, |
|
438 | "callback", wasURLEscape(URL) |
418 | "callback", wasURLEscape( |
|
- | 419 | wasKeyValueGet( |
||
- | 420 | "URL", |
||
- | 421 | configuration |
||
- | 422 | ) |
||
- | 423 | ) |
||
439 | ] |
424 | ] |
|
440 | ) |
425 | ) |
|
441 | ); |
426 | ); |
|
442 | llSetTimerEvent(60); |
427 | llSetTimerEvent(60); |
|
443 | } |
428 | } |
|
444 | http_request(key id, string method, string body) { |
429 | link_message(integer sender, integer num, string body, key id) { |
|
445 | llHTTPResponse(id, 200, "OK"); |
430 | // Only process callbacks for the database command. |
|
446 | if(wasKeyValueGet("command", body) != "getmemberroles" || |
431 | if(id != "callback" || wasKeyValueGet("command", body) != "getmemberroles") |
|
- | 432 | return; |
||
- | 433 | |
||
447 | wasKeyValueGet("success", body) != "True") { |
434 | if(wasKeyValueGet("success", body) != "True") { |
|
448 | if(wasKeyValueGet("status", body) == "19862") { |
435 | if(wasKeyValueGet("status", body) == "19862") { |
|
449 | // DEBUG |
436 | // DEBUG |
|
450 | llOwnerSay("[Unban] User not in group, but proceeding anyway..."); |
437 | llOwnerSay("[Unban] User not in group, but proceeding anyway..."); |
|
451 | jump continue; |
438 | jump continue; |
|
452 | } |
439 | } |
|
Line 454... | Line 441... | |||
454 | llOwnerSay("[Unban] Unable to get member roles: " + |
441 | llOwnerSay("[Unban] Unable to get member roles: " + |
|
455 | wasURLUnescape( |
442 | wasURLUnescape( |
|
456 | wasKeyValueGet("error", body) |
443 | wasKeyValueGet("error", body) |
|
457 | ) |
444 | ) |
|
458 | ); |
445 | ); |
|
459 | llReleaseURL(URL); |
- | ||
- | 446 | |
||
460 | state listen_group; |
447 | state listen_group; |
|
461 | } |
448 | } |
|
Line 462... | Line 449... | |||
462 | |
449 | |
|
463 | string result = wasURLUnescape( |
450 | string result = wasURLUnescape( |
|
464 | wasKeyValueGet("data", body) |
451 | wasKeyValueGet("data", body) |
|
Line 465... | Line 452... | |||
465 | ); |
452 | ); |
|
466 | |
453 | |
|
467 | if(result != "" && llListFindList(wasCSVToList(result), (list)"Owners") != -1) { |
- | ||
468 | data = "Ejectee is an owner. I'm not gonna open the pod bay doors."; |
454 | if(result != "" && llListFindList(wasCSVToList(result), (list)"Owners") != -1) { |
|
469 | llReleaseURL(URL); |
455 | data = "Ejectee is an owner. I'm not gonna open the pod bay doors."; |
|
Line 470... | Line 456... | |||
470 | state tell; |
456 | state tell; |
|
Line 471... | Line 457... | |||
471 | } |
457 | } |
|
472 | |
458 | |
|
473 | @continue; |
459 | @continue; |
|
474 | |
- | ||
475 | state unban; |
460 | |
|
476 | } |
461 | state unban; |
|
477 | timer() { |
462 | } |
|
478 | llReleaseURL(URL); |
463 | timer() { |
|
479 | state listen_group; |
464 | state listen_group; |
|
Line 524... | Line 509... | |||
524 | [ |
509 | [ |
|
525 | firstname + " " + lastname |
510 | firstname + " " + lastname |
|
526 | ] |
511 | ] |
|
527 | ) |
512 | ) |
|
528 | ), |
513 | ), |
|
529 | "callback", wasURLEscape(URL) |
514 | "callback", wasURLEscape( |
|
- | 515 | wasKeyValueGet( |
||
- | 516 | "URL", |
||
- | 517 | configuration |
||
- | 518 | ) |
||
- | 519 | ) |
||
530 | ] |
520 | ] |
|
531 | ) |
521 | ) |
|
532 | ); |
522 | ); |
|
533 | llSetTimerEvent(60); |
523 | llSetTimerEvent(60); |
|
534 | } |
524 | } |
|
535 | http_request(key id, string method, string body) { |
525 | link_message(integer sender, integer num, string body, key id) { |
|
536 | llHTTPResponse(id, 200, "OK"); |
526 | // Only process callbacks for the database command. |
|
537 | llReleaseURL(URL); |
- | ||
538 | if(wasKeyValueGet("command", body) != "ban" || |
527 | if(id != "callback" || wasKeyValueGet("command", body) != "ban") |
|
- | 528 | return; |
||
- | 529 | |
||
539 | wasKeyValueGet("success", body) != "True") { |
530 | if(wasKeyValueGet("success", body) != "True") { |
|
540 | // DEBUG |
531 | // DEBUG |
|
541 | llOwnerSay("[Unban] Unable to ban member: " + |
532 | llOwnerSay("[Unban] Unable to ban member: " + |
|
542 | wasURLUnescape( |
533 | wasURLUnescape( |
|
543 | wasKeyValueGet("error", body) |
534 | wasKeyValueGet("error", body) |
|
544 | ) |
535 | ) |
|
Line 549... | Line 540... | |||
549 | data = "They'll be bak!"; |
540 | data = "They'll be bak!"; |
|
Line 550... | Line 541... | |||
550 | |
541 | |
|
551 | state tell; |
542 | state tell; |
|
552 | } |
543 | } |
|
553 | timer() { |
- | ||
554 | llReleaseURL(URL); |
544 | timer() { |
|
555 | state listen_group; |
545 | state listen_group; |
|
556 | } |
546 | } |
|
557 | on_rez(integer num) { |
547 | on_rez(integer num) { |
|
558 | llResetScript(); |
548 | llResetScript(); |