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 222... | Line 220... | |||
222 | // We only care about notifications now. |
220 | // We only care about notifications now. |
|
223 | if(id != "notification") |
221 | if(id != "notification") |
|
224 | return; |
222 | return; |
|
Line 225... | Line 223... | |||
225 | |
223 | |
|
226 | // This script only processes group notifications. |
224 | // This script only processes group notifications. |
|
- | 225 | if(wasKeyValueGet("type", message) != "group" || |
||
- | 226 | (wasKeyValueGet("type", message) == "group" && |
||
- | 227 | wasURLUnescape(wasKeyValueGet("group", message)) != |
||
227 | if(wasKeyValueGet("type", message) != "group") |
228 | wasKeyValueGet("group", configuration))) |
|
Line 228... | Line 229... | |||
228 | return; |
229 | return; |
|
229 | |
230 | |
|
230 | // Get the sent message. |
231 | // Get the sent message. |
|
Line 258... | Line 259... | |||
258 | } |
259 | } |
|
Line 259... | Line 260... | |||
259 | |
260 | |
|
260 | // Dump the rest of the message. |
261 | // Dump the rest of the message. |
|
Line 261... | Line 262... | |||
261 | data = llDumpList2String(command, " "); |
262 | data = llDumpList2String(command, " "); |
|
262 | |
- | ||
263 | // Get an URL. |
- | ||
264 | state url; |
- | ||
265 | } |
- | ||
266 | on_rez(integer num) { |
- | ||
267 | llResetScript(); |
- | ||
268 | } |
- | ||
269 | changed(integer change) { |
- | ||
270 | if((change & CHANGED_INVENTORY) || |
- | ||
271 | (change & CHANGED_REGION_START) || |
- | ||
272 | (change & CHANGED_OWNER)) { |
- | ||
273 | llResetScript(); |
- | ||
274 | } |
- | ||
275 | } |
- | ||
276 | } |
- | ||
277 | |
- | ||
278 | state url { |
- | ||
279 | state_entry() { |
- | ||
280 | // DEBUG |
- | ||
281 | llOwnerSay("[Softunban] Requesting URL..."); |
- | ||
282 | llRequestURL(); |
- | ||
283 | } |
- | ||
284 | http_request(key id, string method, string body) { |
- | ||
285 | if(method != URL_REQUEST_GRANTED) return; |
- | ||
286 | URL = body; |
- | ||
287 | // DEBUG |
263 | |
|
288 | llOwnerSay("[Softunban] Got URL..."); |
264 | // Get roles of caller. |
|
289 | state get_caller_roles; |
265 | state get_caller_roles; |
|
290 | } |
266 | } |
|
291 | on_rez(integer num) { |
267 | on_rez(integer num) { |
|
Line 324... | Line 300... | |||
324 | configuration |
300 | configuration |
|
325 | ) |
301 | ) |
|
326 | ), |
302 | ), |
|
327 | "firstname", firstname, |
303 | "firstname", firstname, |
|
328 | "lastname", lastname, |
304 | "lastname", lastname, |
|
329 | "callback", wasURLEscape(URL) |
305 | "callback", wasURLEscape( |
|
- | 306 | wasKeyValueGet( |
||
- | 307 | "URL", |
||
- | 308 | configuration |
||
- | 309 | ) |
||
- | 310 | ) |
||
330 | ] |
311 | ] |
|
331 | ) |
312 | ) |
|
332 | ); |
313 | ); |
|
333 | llSetTimerEvent(60); |
314 | llSetTimerEvent(60); |
|
334 | } |
315 | } |
|
335 | http_request(key id, string method, string body) { |
316 | link_message(integer sender, integer num, string body, key id) { |
|
336 | llHTTPResponse(id, 200, "OK"); |
317 | // Only process callbacks for the database command. |
|
337 | if(wasKeyValueGet("command", body) != "getmemberroles" || |
318 | if(id != "callback" || wasKeyValueGet("command", body) != "getmemberroles") |
|
- | 319 | return; |
||
- | 320 | |
||
338 | wasKeyValueGet("success", body) != "True") { |
321 | if(wasKeyValueGet("success", body) != "True") { |
|
339 | // DEBUG |
322 | // DEBUG |
|
340 | llOwnerSay("[Softunban] Unable to get member roles: " + |
323 | llOwnerSay("[Softunban] Unable to get member roles: " + |
|
341 | wasURLUnescape( |
324 | wasURLUnescape( |
|
342 | wasKeyValueGet("error", body) |
325 | wasKeyValueGet("error", body) |
|
343 | ) |
326 | ) |
|
344 | ); |
327 | ); |
|
345 | llReleaseURL(URL); |
- | ||
346 | state listen_group; |
328 | state listen_group; |
|
347 | } |
329 | } |
|
Line 348... | Line 330... | |||
348 | |
330 | |
|
349 | // Dump the roles to a list. |
331 | // Dump the roles to a list. |
|
Line 361... | Line 343... | |||
361 | ) |
343 | ) |
|
362 | ) |
344 | ) |
|
363 | ) |
345 | ) |
|
364 | ) == 0) { |
346 | ) == 0) { |
|
365 | data = "You ain't got the cojones!"; |
347 | data = "You ain't got the cojones!"; |
|
366 | llReleaseURL(URL); |
- | ||
367 | state tell; |
348 | state tell; |
|
368 | } |
349 | } |
|
Line 369... | Line 350... | |||
369 | |
350 | |
|
Line 380... | Line 361... | |||
380 | // GC |
361 | // GC |
|
381 | banee = []; |
362 | banee = []; |
|
382 | state get_banee_roles; |
363 | state get_banee_roles; |
|
383 | } |
364 | } |
|
384 | timer() { |
365 | timer() { |
|
385 | llReleaseURL(URL); |
- | ||
386 | state listen_group; |
366 | state listen_group; |
|
387 | } |
367 | } |
|
388 | on_rez(integer num) { |
368 | on_rez(integer num) { |
|
389 | llResetScript(); |
369 | llResetScript(); |
|
390 | } |
370 | } |
|
Line 424... | Line 404... | |||
424 | configuration |
404 | configuration |
|
425 | ) |
405 | ) |
|
426 | ), |
406 | ), |
|
427 | "firstname", firstname, |
407 | "firstname", firstname, |
|
428 | "lastname", lastname, |
408 | "lastname", lastname, |
|
429 | "callback", wasURLEscape(URL) |
409 | "callback", wasURLEscape( |
|
- | 410 | wasKeyValueGet( |
||
- | 411 | "URL", |
||
- | 412 | configuration |
||
- | 413 | ) |
||
- | 414 | ) |
||
430 | ] |
415 | ] |
|
431 | ) |
416 | ) |
|
432 | ); |
417 | ); |
|
433 | llSetTimerEvent(60); |
418 | llSetTimerEvent(60); |
|
434 | } |
419 | } |
|
435 | http_request(key id, string method, string body) { |
420 | link_message(integer sender, integer num, string body, key id) { |
|
436 | llHTTPResponse(id, 200, "OK"); |
421 | // Only process callbacks for the database command. |
|
437 | if(wasKeyValueGet("command", body) != "getmemberroles" || |
422 | if(id != "callback" || wasKeyValueGet("command", body) != "getmemberroles") |
|
- | 423 | return; |
||
- | 424 | |
||
438 | wasKeyValueGet("success", body) != "True") { |
425 | if(wasKeyValueGet("success", body) != "True") { |
|
439 | if(wasKeyValueGet("status", body) == "19862") { |
426 | if(wasKeyValueGet("status", body) == "19862") { |
|
440 | // DEBUG |
427 | // DEBUG |
|
441 | llOwnerSay("[Softunban] User not in group, but proceeding anyway..."); |
428 | llOwnerSay("[Softunban] User not in group, but proceeding anyway..."); |
|
442 | jump continue; |
429 | jump continue; |
|
443 | } |
430 | } |
|
Line 445... | Line 432... | |||
445 | llOwnerSay("[Softunban] Unable to get member roles: " + |
432 | llOwnerSay("[Softunban] Unable to get member roles: " + |
|
446 | wasURLUnescape( |
433 | wasURLUnescape( |
|
447 | wasKeyValueGet("error", body) |
434 | wasKeyValueGet("error", body) |
|
448 | ) |
435 | ) |
|
449 | ); |
436 | ); |
|
450 | llReleaseURL(URL); |
- | ||
451 | state listen_group; |
437 | state listen_group; |
|
452 | } |
438 | } |
|
Line 453... | Line 439... | |||
453 | |
439 | |
|
454 | string result = wasURLUnescape( |
440 | string result = wasURLUnescape( |
|
455 | wasKeyValueGet("data", body) |
441 | wasKeyValueGet("data", body) |
|
Line 456... | Line 442... | |||
456 | ); |
442 | ); |
|
457 | |
443 | |
|
458 | if(result != "" && llListFindList(wasCSVToList(result), (list)"Owners") != -1) { |
- | ||
459 | data = "Ejectee is an owner. I'm not gonna open the pod bay doors."; |
444 | if(result != "" && llListFindList(wasCSVToList(result), (list)"Owners") != -1) { |
|
460 | llReleaseURL(URL); |
445 | data = "Ejectee is an owner. I'm not gonna open the pod bay doors."; |
|
Line 461... | Line 446... | |||
461 | state tell; |
446 | state tell; |
|
Line 462... | Line 447... | |||
462 | } |
447 | } |
|
463 | |
448 | |
|
464 | @continue; |
449 | @continue; |
|
465 | |
- | ||
466 | state unban; |
450 | |
|
467 | } |
451 | state unban; |
|
468 | timer() { |
452 | } |
|
469 | llReleaseURL(URL); |
453 | timer() { |
|
470 | state listen_group; |
454 | state listen_group; |
|
Line 514... | Line 498... | |||
514 | [ |
498 | [ |
|
515 | firstname + " " + lastname |
499 | firstname + " " + lastname |
|
516 | ] |
500 | ] |
|
517 | ) |
501 | ) |
|
518 | ), |
502 | ), |
|
519 | "callback", wasURLEscape(URL) |
503 | "callback", wasURLEscape( |
|
- | 504 | wasKeyValueGet( |
||
- | 505 | "URL", |
||
- | 506 | configuration |
||
- | 507 | ) |
||
- | 508 | ) |
||
520 | ] |
509 | ] |
|
521 | ) |
510 | ) |
|
522 | ); |
511 | ); |
|
523 | llSetTimerEvent(60); |
512 | llSetTimerEvent(60); |
|
524 | } |
513 | } |
|
525 | http_request(key id, string method, string body) { |
514 | link_message(integer sender, integer num, string body, key id) { |
|
526 | llHTTPResponse(id, 200, "OK"); |
515 | // Only process callbacks for the database command. |
|
527 | llReleaseURL(URL); |
- | ||
528 | if(wasKeyValueGet("command", body) != "softban" || |
516 | if(id != "callback" || wasKeyValueGet("command", body) != "softban") |
|
- | 517 | return; |
||
- | 518 | |
||
529 | wasKeyValueGet("success", body) != "True") { |
519 | if(wasKeyValueGet("success", body) != "True") { |
|
530 | // DEBUG |
520 | // DEBUG |
|
531 | llOwnerSay("[Softunban] Unable to ban member: " + |
521 | llOwnerSay("[Softunban] Unable to ban member: " + |
|
532 | wasURLUnescape( |
522 | wasURLUnescape( |
|
533 | wasKeyValueGet("error", body) |
523 | wasKeyValueGet("error", body) |
|
534 | ) |
524 | ) |
|
Line 539... | Line 529... | |||
539 | data = "They'll be bak!"; |
529 | data = "They'll be bak!"; |
|
Line 540... | Line 530... | |||
540 | |
530 | |
|
541 | state tell; |
531 | state tell; |
|
542 | } |
532 | } |
|
543 | timer() { |
- | ||
544 | llReleaseURL(URL); |
533 | timer() { |
|
545 | state listen_group; |
534 | state listen_group; |
|
546 | } |
535 | } |
|
547 | on_rez(integer num) { |
536 | on_rez(integer num) { |
|
548 | llResetScript(); |
537 | llResetScript(); |