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 invites people to the group members. |
5 | // A module that invites people to the group members. |
|
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 161... | Line 161... | |||
161 | ); |
161 | ); |
|
162 | } |
162 | } |
|
Line 163... | Line 163... | |||
163 | |
163 | |
|
164 | // configuration data |
164 | // configuration data |
|
165 | string configuration = ""; |
- | ||
166 | // callback URL |
- | ||
167 | string URL = ""; |
165 | string configuration = ""; |
|
168 | // store message over state. |
166 | // store message over state. |
|
169 | string data = ""; |
167 | string data = ""; |
|
170 | string firstname = ""; |
168 | string firstname = ""; |
|
Line 209... | Line 207... | |||
209 | // We only care about notifications now. |
207 | // We only care about notifications now. |
|
210 | if(id != "notification") |
208 | if(id != "notification") |
|
211 | return; |
209 | return; |
|
Line 212... | Line 210... | |||
212 | |
210 | |
|
213 | // This script only processes group notifications. |
211 | // This script only processes group notifications. |
|
- | 212 | if(wasKeyValueGet("type", message) != "group" || |
||
- | 213 | (wasKeyValueGet("type", message) == "group" && |
||
- | 214 | wasURLUnescape(wasKeyValueGet("group", message)) != |
||
214 | if(wasKeyValueGet("type", message) != "group") |
215 | wasKeyValueGet("group", configuration))) |
|
Line 215... | Line 216... | |||
215 | return; |
216 | return; |
|
216 | |
217 | |
|
217 | // Get the sent message. |
218 | // Get the sent message. |
|
Line 237... | Line 238... | |||
237 | command = llDeleteSubList(command, 0, 0); |
238 | command = llDeleteSubList(command, 0, 0); |
|
Line 238... | Line 239... | |||
238 | |
239 | |
|
239 | // Dump the rest of the message. |
240 | // Dump the rest of the message. |
|
Line 240... | Line 241... | |||
240 | data = llDumpList2String(command, " "); |
241 | data = llDumpList2String(command, " "); |
|
241 | |
- | ||
242 | // Get an URL. |
- | ||
243 | state url; |
- | ||
244 | } |
- | ||
245 | on_rez(integer num) { |
- | ||
246 | llResetScript(); |
- | ||
247 | } |
- | ||
248 | changed(integer change) { |
- | ||
249 | if((change & CHANGED_INVENTORY) || |
- | ||
250 | (change & CHANGED_REGION_START) || |
- | ||
251 | (change & CHANGED_OWNER)) { |
- | ||
252 | llResetScript(); |
- | ||
253 | } |
- | ||
254 | } |
- | ||
255 | } |
- | ||
256 | |
- | ||
257 | state url { |
- | ||
258 | state_entry() { |
- | ||
259 | // DEBUG |
- | ||
260 | llOwnerSay("[Invite] Requesting URL..."); |
- | ||
261 | llRequestURL(); |
- | ||
262 | } |
- | ||
263 | http_request(key id, string method, string body) { |
- | ||
264 | if(method != URL_REQUEST_GRANTED) return; |
- | ||
265 | URL = body; |
- | ||
266 | // DEBUG |
242 | |
|
267 | llOwnerSay("[Invite] Got URL..."); |
243 | // Search for agent. |
|
268 | state search; |
244 | state search; |
|
269 | } |
245 | } |
|
270 | on_rez(integer num) { |
246 | on_rez(integer num) { |
|
Line 311... | Line 287... | |||
311 | "match", |
287 | "match", |
|
312 | wasURLEscape("(?i),?([^,$]*" + data +"[^,$]*),?") |
288 | wasURLEscape("(?i),?([^,$]*" + data +"[^,$]*),?") |
|
313 | ] |
289 | ] |
|
314 | ) |
290 | ) |
|
315 | ),*/ |
291 | ),*/ |
|
316 | "callback", wasURLEscape(URL) |
292 | "callback", wasURLEscape( |
|
- | 293 | wasKeyValueGet( |
||
- | 294 | "URL", |
||
- | 295 | configuration |
||
- | 296 | ) |
||
- | 297 | ) |
||
317 | ] |
298 | ] |
|
318 | ) |
299 | ) |
|
319 | ); |
300 | ); |
|
320 | llSetTimerEvent(60); |
301 | llSetTimerEvent(60); |
|
321 | } |
302 | } |
|
322 | http_request(key id, string method, string body) { |
303 | link_message(integer sender, integer num, string body, key id) { |
|
323 | llHTTPResponse(id, 200, "OK"); |
304 | // Only process callbacks for the database command. |
|
324 | if(wasKeyValueGet("command", body) != "directorysearch" || |
305 | if(id != "callback" || wasKeyValueGet("command", body) != "directorysearch") |
|
- | 306 | return; |
||
- | 307 | |
||
325 | wasKeyValueGet("success", body) != "True") { |
308 | if(wasKeyValueGet("success", body) != "True") { |
|
326 | // DEBUG |
309 | // DEBUG |
|
327 | llOwnerSay("[Invite] Unable to search for agent: " + |
310 | llOwnerSay("[Invite] Unable to search for agent: " + |
|
328 | wasURLUnescape( |
311 | wasURLUnescape( |
|
329 | wasKeyValueGet("error", body) |
312 | wasKeyValueGet("error", body) |
|
330 | ) |
313 | ) |
|
331 | ); |
314 | ); |
|
332 | llReleaseURL(URL); |
- | ||
333 | state listen_group; |
315 | state listen_group; |
|
334 | } |
316 | } |
|
Line 335... | Line 317... | |||
335 | |
317 | |
|
336 | list first_last = llParseString2List(data, [" "], []); |
318 | list first_last = llParseString2List(data, [" "], []); |
|
Line 360... | Line 342... | |||
360 | (list)"LastName" |
342 | (list)"LastName" |
|
361 | ) + 1 |
343 | ) + 1 |
|
362 | ) |
344 | ) |
|
363 | ) != llToUpper(lastname)) { |
345 | ) != llToUpper(lastname)) { |
|
364 | data = "Agent not found."; |
346 | data = "Agent not found."; |
|
365 | llReleaseURL(URL); |
- | ||
366 | state tell; |
347 | state tell; |
|
367 | } |
348 | } |
|
Line 368... | Line 349... | |||
368 | |
349 | |
|
369 | state invite; |
350 | state invite; |
|
370 | } |
351 | } |
|
371 | timer() { |
- | ||
372 | llReleaseURL(URL); |
352 | timer() { |
|
373 | state listen_group; |
353 | state listen_group; |
|
374 | } |
354 | } |
|
375 | on_rez(integer num) { |
355 | on_rez(integer num) { |
|
376 | llResetScript(); |
356 | llResetScript(); |
|
Line 413... | Line 393... | |||
413 | ), |
393 | ), |
|
414 | "firstname", firstname, |
394 | "firstname", firstname, |
|
415 | "lastname", lastname, |
395 | "lastname", lastname, |
|
416 | "soft", "True", |
396 | "soft", "True", |
|
417 | "verify", "False", |
397 | "verify", "False", |
|
418 | "callback", wasURLEscape(URL) |
398 | "callback", wasURLEscape( |
|
- | 399 | wasKeyValueGet( |
||
- | 400 | "URL", |
||
- | 401 | configuration |
||
- | 402 | ) |
||
- | 403 | ) |
||
419 | ] |
404 | ] |
|
420 | ) |
405 | ) |
|
421 | ); |
406 | ); |
|
422 | llSetTimerEvent(60); |
407 | llSetTimerEvent(60); |
|
423 | } |
408 | } |
|
424 | http_request(key id, string method, string body) { |
409 | link_message(integer sender, integer num, string body, key id) { |
|
425 | llHTTPResponse(id, 200, "OK"); |
410 | // Only process callbacks for the database command. |
|
426 | llReleaseURL(URL); |
- | ||
427 | if(wasKeyValueGet("command", body) != "invite" || |
411 | if(id != "callback" || wasKeyValueGet("command", body) != "invite") |
|
- | 412 | return; |
||
- | 413 | |
||
428 | wasKeyValueGet("success", body) != "True") { |
414 | if(wasKeyValueGet("success", body) != "True") { |
|
429 | // DEBUG |
415 | // DEBUG |
|
430 | llOwnerSay("[Eject] Unable to invite agent: " + |
416 | llOwnerSay("[Eject] Unable to invite agent: " + |
|
431 | wasURLUnescape( |
417 | wasURLUnescape( |
|
432 | wasKeyValueGet("error", body) |
418 | wasKeyValueGet("error", body) |
|
433 | ) |
419 | ) |
|
Line 438... | Line 424... | |||
438 | data = "Butters (Jym) was sent to pick them up!"; |
424 | data = "Butters (Jym) was sent to pick them up!"; |
|
Line 439... | Line 425... | |||
439 | |
425 | |
|
440 | state tell; |
426 | state tell; |
|
441 | } |
427 | } |
|
442 | timer() { |
- | ||
443 | llReleaseURL(URL); |
428 | timer() { |
|
444 | state listen_group; |
429 | state listen_group; |
|
445 | } |
430 | } |
|
446 | on_rez(integer num) { |
431 | on_rez(integer num) { |
|
447 | llResetScript(); |
432 | llResetScript(); |