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 MOTD module for Corrade Eggdrop. |
5 | // A MOTD module for Corrade Eggdrop. |
|
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 firstname = ""; |
167 | string firstname = ""; |
|
170 | string lastname = ""; |
168 | string lastname = ""; |
|
171 | string group = ""; |
169 | string group = ""; |
|
172 | string data = ""; |
170 | string data = ""; |
|
- | 171 | string jump_state = ""; |
||
Line 173... | Line 172... | |||
173 | string jump_state = ""; |
172 | integer membershipFee; |
|
174 | |
173 | |
|
175 | default { |
174 | default { |
|
176 | state_entry() { |
175 | state_entry() { |
|
Line 180... | Line 179... | |||
180 | link_message(integer sender, integer num, string message, key id) { |
179 | link_message(integer sender, integer num, string message, key id) { |
|
181 | if(id != "configuration") return; |
180 | if(id != "configuration") return; |
|
182 | llOwnerSay("[MOTD] Got configuration..."); |
181 | llOwnerSay("[MOTD] Got configuration..."); |
|
183 | configuration = message; |
182 | configuration = message; |
|
184 | jump_state = "create_database"; |
183 | jump_state = "create_database"; |
|
185 | state url; |
184 | state trampoline; |
|
186 | } |
185 | } |
|
187 | timer() { |
186 | timer() { |
|
188 | llOwnerSay("[MOTD] Requesting configuration..."); |
187 | llOwnerSay("[MOTD] Requesting configuration..."); |
|
189 | llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY); |
188 | llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY); |
|
190 | } |
189 | } |
|
Line 201... | Line 200... | |||
201 | state_exit() { |
200 | state_exit() { |
|
202 | llSetTimerEvent(0); |
201 | llSetTimerEvent(0); |
|
203 | } |
202 | } |
|
204 | } |
203 | } |
|
Line 205... | Line 204... | |||
205 | |
204 | |
|
206 | state url { |
205 | state trampoline { |
|
207 | state_entry() { |
- | ||
208 | // DEBUG |
- | ||
209 | llOwnerSay("[MOTD] Requesting URL..."); |
- | ||
210 | llRequestURL(); |
- | ||
211 | } |
- | ||
212 | http_request(key id, string method, string body) { |
- | ||
213 | if(method != URL_REQUEST_GRANTED) return; |
- | ||
214 | URL = body; |
- | ||
215 | // DEBUG |
- | ||
216 | llOwnerSay("[MOTD] Got URL..."); |
206 | state_entry() { |
|
217 | if(jump_state == "create_database") |
207 | if(jump_state == "create_database") |
|
218 | state create_database; |
208 | state create_database; |
|
219 | if(jump_state == "greet") |
209 | if(jump_state == "greet") |
|
220 | state greet; |
210 | state greet; |
|
221 | if(jump_state == "get") |
211 | if(jump_state == "get") |
|
222 | state get; |
212 | state get; |
|
223 | if(jump_state == "set") |
213 | if(jump_state == "set") |
|
- | 214 | state set; |
||
- | 215 | if(jump_state == "fee") |
||
- | 216 | state fee; |
||
- | 217 | if(jump_state == "pay") |
||
224 | state set; |
218 | state pay; |
|
225 | if(jump_state == "listen_group") |
219 | if(jump_state == "listen_group") |
|
Line 226... | Line 220... | |||
226 | state listen_group; |
220 | state listen_group; |
|
227 | |
221 | |
|
Line 266... | Line 260... | |||
266 | ) |
260 | ) |
|
267 | ), |
261 | ), |
|
268 | "SQL", wasURLEscape("CREATE TABLE IF NOT EXISTS \"" + |
262 | "SQL", wasURLEscape("CREATE TABLE IF NOT EXISTS \"" + |
|
269 | wasKeyValueGet("motd table", configuration) + |
263 | wasKeyValueGet("motd table", configuration) + |
|
270 | "\" (name text unique collate nocase, data text)"), |
264 | "\" (name text unique collate nocase, data text)"), |
|
271 | "callback", wasURLEscape(URL) |
265 | "callback", wasURLEscape( |
|
- | 266 | wasKeyValueGet( |
||
- | 267 | "URL", |
||
- | 268 | configuration |
||
- | 269 | ) |
||
- | 270 | ) |
||
272 | ] |
271 | ] |
|
273 | ) |
272 | ) |
|
274 | ); |
273 | ); |
|
275 | llSetTimerEvent(60); |
274 | llSetTimerEvent(60); |
|
276 | } |
275 | } |
|
277 | http_request(key id, string method, string body) { |
276 | link_message(integer sender, integer num, string body, key id) { |
|
278 | llHTTPResponse(id, 200, "OK"); |
277 | // Only process callbacks for the database command. |
|
279 | llReleaseURL(URL); |
- | ||
280 | if(wasKeyValueGet("command", body) != "database" || |
278 | if(id != "callback" || wasKeyValueGet("command", body) != "database") |
|
- | 279 | return; |
||
- | 280 | |
||
281 | wasKeyValueGet("success", body) != "True") { |
281 | if(wasKeyValueGet("success", body) != "True") { |
|
282 | // DEBUG |
282 | // DEBUG |
|
283 | llOwnerSay("[MOTD] Unable modify database: " + |
283 | llOwnerSay("[MOTD] Unable modify database: " + |
|
284 | wasURLUnescape( |
284 | wasURLUnescape( |
|
285 | wasKeyValueGet("error", body) |
285 | wasKeyValueGet("error", body) |
|
286 | ) + |
286 | ) + |
|
Line 294... | Line 294... | |||
294 | } |
294 | } |
|
295 | llOwnerSay("[MOTD] Database created!"); |
295 | llOwnerSay("[MOTD] Database created!"); |
|
296 | state listen_group; |
296 | state listen_group; |
|
297 | } |
297 | } |
|
298 | timer() { |
298 | timer() { |
|
299 | llReleaseURL(URL); |
- | ||
300 | state listen_group; |
299 | state listen_group; |
|
301 | } |
300 | } |
|
302 | on_rez(integer num) { |
301 | on_rez(integer num) { |
|
303 | llResetScript(); |
302 | llResetScript(); |
|
304 | } |
303 | } |
|
Line 331... | Line 330... | |||
331 | "group", |
330 | "group", |
|
332 | message |
331 | message |
|
333 | ) |
332 | ) |
|
334 | ); |
333 | ); |
|
Line -... | Line 334... | |||
- | 334 | |
||
- | 335 | // This script only processes group and membership notifications. |
||
- | 336 | // Esnure that the notification is meant for the configured group. |
||
- | 337 | if((wasKeyValueGet("type", message) != "membership" && wasKeyValueGet("type", message) != "group") || |
||
- | 338 | ((wasKeyValueGet("type", message) == "membership" || wasKeyValueGet("type", message) == "group") && |
||
- | 339 | wasURLUnescape(wasKeyValueGet("group", message)) != |
||
- | 340 | wasKeyValueGet("group", configuration))) |
||
- | 341 | return; |
||
335 | |
342 | |
|
336 | // Retrieve the membership notification. |
343 | // Retrieve the membership notification. |
|
337 | if(wasKeyValueGet("type", message) == "membership" && |
344 | if(wasKeyValueGet("type", message) == "membership" && |
|
338 | wasKeyValueGet("action", message) == "joined") { |
345 | wasKeyValueGet("action", message) == "joined") { |
|
339 | firstname = wasURLUnescape( |
346 | firstname = wasURLUnescape( |
|
Line 346... | Line 353... | |||
346 | wasKeyValueGet( |
353 | wasKeyValueGet( |
|
347 | "lastname", |
354 | "lastname", |
|
348 | message |
355 | message |
|
349 | ) |
356 | ) |
|
350 | ); |
357 | ); |
|
- | 358 | |
||
- | 359 | if(wasKeyValueGet("pay back", configuration) != "true") { |
||
351 | jump_state = "greet"; |
360 | jump_state = "greet"; |
|
352 | state url; |
361 | state trampoline; |
|
353 | } |
362 | } |
|
Line 354... | Line 363... | |||
354 | |
363 | |
|
355 | // This script only processes group notifications. |
364 | jump_state = "fee"; |
|
356 | if(wasKeyValueGet("type", message) != "group") |
365 | state trampoline; |
|
Line 357... | Line 366... | |||
357 | return; |
366 | } |
|
358 | |
367 | |
|
359 | // Get the sent message. |
368 | // Get the sent message. |
|
360 | data = wasURLUnescape( |
369 | data = wasURLUnescape( |
|
Line 379... | Line 388... | |||
379 | command = llDeleteSubList(command, 0, 0); |
388 | command = llDeleteSubList(command, 0, 0); |
|
Line 380... | Line 389... | |||
380 | |
389 | |
|
381 | // Dump the rest of the message. |
390 | // Dump the rest of the message. |
|
Line -... | Line 391... | |||
- | 391 | data = llDumpList2String(command, " "); |
||
- | 392 | |
||
- | 393 | // DEBUG |
||
382 | data = llDumpList2String(command, " "); |
394 | //llOwnerSay("Remaining data: " + data); |
|
383 | |
395 | |
|
384 | // Get the sent message. |
396 | // Get the sent message. |
|
385 | if(data == "") { |
397 | if(data == "") { |
|
386 | jump_state = "get"; |
398 | jump_state = "get"; |
|
Line -... | Line 399... | |||
- | 399 | state trampoline; |
||
387 | state url; |
400 | } |
|
388 | } |
401 | |
|
389 | |
402 | data = wasURLEscape(data); |
|
390 | jump_state = "set"; |
403 | jump_state = "set"; |
|
391 | state url; |
404 | state trampoline; |
|
392 | } |
405 | } |
|
393 | on_rez(integer num) { |
406 | on_rez(integer num) { |
|
Line 403... | Line 416... | |||
403 | } |
416 | } |
|
Line 404... | Line 417... | |||
404 | |
417 | |
|
405 | state greet { |
418 | state greet { |
|
406 | state_entry() { |
419 | state_entry() { |
|
407 | // DEBUG |
420 | // DEBUG |
|
408 | llOwnerSay("[MOTD] Member joined, retrieving MOTD..."); |
421 | llOwnerSay("[MOTD] Retrieving MOTD..."); |
|
409 | llInstantMessage( |
422 | llInstantMessage( |
|
410 | wasKeyValueGet( |
423 | wasKeyValueGet( |
|
411 | "corrade", |
424 | "corrade", |
|
412 | configuration |
425 | configuration |
|
Line 435... | Line 448... | |||
435 | "group", |
448 | "group", |
|
436 | wasURLEscape(group) |
449 | wasURLEscape(group) |
|
437 | ] |
450 | ] |
|
438 | ) |
451 | ) |
|
439 | ), |
452 | ), |
|
440 | "callback", wasURLEscape(URL) |
453 | "callback", wasURLEscape( |
|
- | 454 | wasKeyValueGet( |
||
- | 455 | "URL", |
||
- | 456 | configuration |
||
- | 457 | ) |
||
- | 458 | ) |
||
441 | ] |
459 | ] |
|
442 | ) |
460 | ) |
|
443 | ); |
461 | ); |
|
444 | llSetTimerEvent(60); |
462 | llSetTimerEvent(60); |
|
445 | } |
463 | } |
|
446 | http_request(key id, string method, string body) { |
464 | link_message(integer sender, integer num, string body, key id) { |
|
447 | llHTTPResponse(id, 200, "OK"); |
465 | // Only process callbacks for the database command. |
|
448 | llReleaseURL(URL); |
- | ||
449 | if(wasKeyValueGet("command", body) != "database" || |
466 | if(id != "callback" || wasKeyValueGet("command", body) != "database") |
|
- | 467 | return; |
||
- | 468 | |
||
450 | wasKeyValueGet("success", body) != "True") { |
469 | if(wasKeyValueGet("success", body) != "True") { |
|
451 | // DEBUG |
470 | // DEBUG |
|
452 | llOwnerSay("[MOTD] Unable retrieve from database: " + |
471 | llOwnerSay("[MOTD] Unable retrieve from database: " + |
|
453 | wasURLUnescape( |
472 | wasURLUnescape( |
|
454 | wasKeyValueGet("error", body) |
473 | wasKeyValueGet("error", body) |
|
455 | ) |
474 | ) |
|
Line 475... | Line 494... | |||
475 | |
494 | |
|
476 | data = "Hello " + firstname + " " + lastname + "!" + " " + data; |
495 | data = "Hello " + firstname + " " + lastname + "!" + " " + data; |
|
477 | state tell; |
496 | state tell; |
|
478 | } |
497 | } |
|
479 | timer() { |
- | ||
480 | llReleaseURL(URL); |
498 | timer() { |
|
481 | state listen_group; |
499 | state listen_group; |
|
482 | } |
500 | } |
|
483 | on_rez(integer num) { |
501 | on_rez(integer num) { |
|
484 | llResetScript(); |
502 | llResetScript(); |
|
Line 533... | Line 551... | |||
533 | ) |
551 | ) |
|
534 | ) |
552 | ) |
|
535 | ] |
553 | ] |
|
536 | ) |
554 | ) |
|
537 | ), |
555 | ), |
|
538 | "callback", wasURLEscape(URL) |
556 | "callback", wasURLEscape( |
|
- | 557 | wasKeyValueGet( |
||
- | 558 | "URL", |
||
- | 559 | configuration |
||
- | 560 | ) |
||
- | 561 | ) |
||
539 | ] |
562 | ] |
|
540 | ) |
563 | ) |
|
541 | ); |
564 | ); |
|
542 | llSetTimerEvent(60); |
565 | llSetTimerEvent(60); |
|
543 | } |
566 | } |
|
544 | http_request(key id, string method, string body) { |
567 | link_message(integer sender, integer num, string body, key id) { |
|
545 | llHTTPResponse(id, 200, "OK"); |
568 | // Only process callbacks for the database command. |
|
546 | llReleaseURL(URL); |
- | ||
547 | if(wasKeyValueGet("command", body) != "database" || |
569 | if(id != "callback" || wasKeyValueGet("command", body) != "database") |
|
- | 570 | return; |
||
- | 571 | |
||
548 | wasKeyValueGet("success", body) != "True") { |
572 | if(wasKeyValueGet("success", body) != "True") { |
|
549 | // DEBUG |
573 | // DEBUG |
|
550 | llOwnerSay("[MOTD] Unable retrieve from database: " + |
574 | llOwnerSay("[MOTD] Unable retrieve from database: " + |
|
551 | wasURLUnescape( |
575 | wasURLUnescape( |
|
552 | wasKeyValueGet("error", body) |
576 | wasKeyValueGet("error", body) |
|
553 | ) |
577 | ) |
|
Line 574... | Line 598... | |||
574 | } |
598 | } |
|
Line 575... | Line 599... | |||
575 | |
599 | |
|
576 | state tell; |
600 | state tell; |
|
577 | } |
601 | } |
|
- | 602 | timer() { |
||
- | 603 | state listen_group; |
||
- | 604 | } |
||
- | 605 | on_rez(integer num) { |
||
- | 606 | llResetScript(); |
||
- | 607 | } |
||
- | 608 | changed(integer change) { |
||
- | 609 | if((change & CHANGED_INVENTORY) || |
||
- | 610 | (change & CHANGED_REGION_START) || |
||
- | 611 | (change & CHANGED_OWNER)) { |
||
- | 612 | llResetScript(); |
||
- | 613 | } |
||
- | 614 | } |
||
- | 615 | state_exit() { |
||
- | 616 | llSetTimerEvent(0); |
||
- | 617 | } |
||
- | 618 | } |
||
- | 619 | |
||
- | 620 | state fee { |
||
- | 621 | state_entry() { |
||
- | 622 | // DEBUG |
||
- | 623 | llOwnerSay("[MOTD] Member joined, getting group membership fee..."); |
||
- | 624 | llInstantMessage( |
||
- | 625 | wasKeyValueGet( |
||
- | 626 | "corrade", |
||
- | 627 | configuration |
||
- | 628 | ), |
||
- | 629 | wasKeyValueEncode( |
||
- | 630 | [ |
||
- | 631 | "command", "getgroupdata", |
||
- | 632 | "group", wasURLEscape( |
||
- | 633 | wasKeyValueGet( |
||
- | 634 | "group", |
||
- | 635 | configuration |
||
- | 636 | ) |
||
- | 637 | ), |
||
- | 638 | "password", wasURLEscape( |
||
- | 639 | wasKeyValueGet( |
||
- | 640 | "password", |
||
- | 641 | configuration |
||
- | 642 | ) |
||
- | 643 | ), |
||
- | 644 | "data", "MembershipFee", |
||
- | 645 | "callback", wasURLEscape( |
||
- | 646 | wasKeyValueGet( |
||
- | 647 | "URL", |
||
- | 648 | configuration |
||
- | 649 | ) |
||
- | 650 | ) |
||
- | 651 | ] |
||
- | 652 | ) |
||
- | 653 | ); |
||
- | 654 | llSetTimerEvent(60); |
||
- | 655 | } |
||
- | 656 | link_message(integer sender, integer num, string body, key id) { |
||
- | 657 | // Only process callbacks for the database command. |
||
- | 658 | if(id != "callback" || wasKeyValueGet("command", body) != "getgroupdata") |
||
- | 659 | return; |
||
- | 660 | |
||
- | 661 | if(wasKeyValueGet("success", body) != "True") { |
||
- | 662 | // DEBUG |
||
- | 663 | llOwnerSay("[MOTD] Unable to get group data: " + |
||
- | 664 | wasURLUnescape( |
||
- | 665 | wasKeyValueGet("error", body) |
||
- | 666 | ) |
||
- | 667 | ); |
||
- | 668 | state listen_group; |
||
- | 669 | } |
||
- | 670 | |
||
- | 671 | list membership = wasCSVToList( |
||
- | 672 | wasURLUnescape( |
||
- | 673 | wasKeyValueGet( |
||
- | 674 | "data", |
||
- | 675 | body |
||
- | 676 | ) |
||
- | 677 | ) |
||
- | 678 | ); |
||
- | 679 | |
||
- | 680 | membershipFee = llList2Integer( |
||
- | 681 | membership, |
||
- | 682 | llListFindList( |
||
- | 683 | membership, |
||
- | 684 | [ "MembershipFee" ] |
||
- | 685 | ) + 1 |
||
- | 686 | ); |
||
- | 687 | |
||
- | 688 | if(membershipFee <= 0) { |
||
- | 689 | // DEBUG |
||
- | 690 | llOwnerSay("The configured group does not have a membership fee!"); |
||
- | 691 | state listen_group; |
||
- | 692 | } |
||
- | 693 | |
||
- | 694 | jump_state = "pay"; |
||
- | 695 | state trampoline; |
||
- | 696 | } |
||
- | 697 | timer() { |
||
- | 698 | state listen_group; |
||
- | 699 | } |
||
578 | timer() { |
700 | on_rez(integer num) { |
|
- | 701 | llResetScript(); |
||
- | 702 | } |
||
- | 703 | changed(integer change) { |
||
- | 704 | if((change & CHANGED_INVENTORY) || |
||
- | 705 | (change & CHANGED_REGION_START) || |
||
- | 706 | (change & CHANGED_OWNER)) { |
||
- | 707 | llResetScript(); |
||
- | 708 | } |
||
- | 709 | } |
||
- | 710 | state_exit() { |
||
- | 711 | llSetTimerEvent(0); |
||
- | 712 | } |
||
- | 713 | } |
||
- | 714 | |
||
- | 715 | state pay { |
||
- | 716 | state_entry() { |
||
- | 717 | // DEBUG |
||
- | 718 | llOwnerSay("[MOTD] Paying back the entrance fee..."); |
||
- | 719 | llInstantMessage( |
||
- | 720 | wasKeyValueGet( |
||
- | 721 | "corrade", |
||
- | 722 | configuration |
||
- | 723 | ), |
||
- | 724 | wasKeyValueEncode( |
||
- | 725 | [ |
||
- | 726 | "command", "pay", |
||
- | 727 | "group", wasURLEscape( |
||
- | 728 | wasKeyValueGet( |
||
- | 729 | "group", |
||
- | 730 | configuration |
||
- | 731 | ) |
||
- | 732 | ), |
||
- | 733 | "password", wasURLEscape( |
||
- | 734 | wasKeyValueGet( |
||
- | 735 | "password", |
||
- | 736 | configuration |
||
- | 737 | ) |
||
- | 738 | ), |
||
- | 739 | "amount", membershipFee, |
||
- | 740 | "entity", "avatar", |
||
- | 741 | "firstname", wasURLEscape(firstname), |
||
- | 742 | "lastname", wasURLEscape(lastname), |
||
- | 743 | "callback", wasURLEscape( |
||
- | 744 | wasKeyValueGet( |
||
- | 745 | "URL", |
||
- | 746 | configuration |
||
- | 747 | ) |
||
- | 748 | ) |
||
- | 749 | ] |
||
- | 750 | ) |
||
- | 751 | ); |
||
- | 752 | llSetTimerEvent(60); |
||
- | 753 | } |
||
- | 754 | link_message(integer sender, integer num, string body, key id) { |
||
- | 755 | // Only process callbacks for the database command. |
||
- | 756 | if(id != "callback" || wasKeyValueGet("command", body) != "pay") |
||
- | 757 | return; |
||
- | 758 | |
||
- | 759 | if(wasKeyValueGet("success", body) != "True") { |
||
- | 760 | // DEBUG |
||
- | 761 | llOwnerSay("[MOTD] Unable to pay the entrance fee: " + |
||
- | 762 | wasURLUnescape( |
||
- | 763 | wasKeyValueGet("error", body) |
||
- | 764 | ) |
||
- | 765 | ); |
||
- | 766 | state listen_group; |
||
- | 767 | } |
||
- | 768 | |
||
- | 769 | // DEBUG |
||
- | 770 | llOwnerSay("[MOTD] Paid back the entrance fee."); |
||
- | 771 | |
||
- | 772 | jump_state = "greet"; |
||
- | 773 | state trampoline; |
||
- | 774 | } |
||
579 | llReleaseURL(URL); |
775 | timer() { |
|
580 | state listen_group; |
776 | state listen_group; |
|
581 | } |
777 | } |
|
582 | on_rez(integer num) { |
778 | on_rez(integer num) { |
|
583 | llResetScript(); |
779 | llResetScript(); |
|
Line 595... | Line 791... | |||
595 | } |
791 | } |
|
Line 596... | Line 792... | |||
596 | |
792 | |
|
597 | state set { |
793 | state set { |
|
598 | state_entry() { |
794 | state_entry() { |
|
599 | // DEBUG |
795 | // DEBUG |
|
600 | llOwnerSay("[MOTD] Adding to database."); |
796 | llOwnerSay("[MOTD] Adding to database..."); |
|
601 | llInstantMessage( |
797 | llInstantMessage( |
|
602 | wasKeyValueGet( |
798 | wasKeyValueGet( |
|
603 | "corrade", |
799 | "corrade", |
|
604 | configuration |
800 | configuration |
|
Line 618... | Line 814... | |||
618 | configuration |
814 | configuration |
|
619 | ) |
815 | ) |
|
620 | ), |
816 | ), |
|
621 | "SQL", wasURLEscape("REPLACE INTO \"" + |
817 | "SQL", wasURLEscape("REPLACE INTO \"" + |
|
622 | wasKeyValueGet("motd table", configuration) + |
818 | wasKeyValueGet("motd table", configuration) + |
|
623 | "\" (name, data) VALUES (:name, :data)"), |
819 | "\" (name, data) VALUES (:group, :message)"), |
|
624 | "data", wasURLEscape( |
820 | "data", wasURLEscape( |
|
625 | wasListToCSV( |
821 | wasListToCSV( |
|
626 | [ |
822 | [ |
|
627 | "name", |
823 | "group", |
|
628 | wasURLEscape( |
824 | wasURLEscape( |
|
629 | wasKeyValueGet( |
825 | wasKeyValueGet( |
|
630 | "group", |
826 | "group", |
|
631 | configuration |
827 | configuration |
|
632 | ) |
828 | ) |
|
633 | ), |
829 | ), |
|
634 | "data", |
830 | "message", |
|
635 | wasURLEscape(data) |
831 | data |
|
636 | ] |
832 | ] |
|
637 | ) |
833 | ) |
|
638 | ), |
834 | ), |
|
639 | "callback", wasURLEscape(URL) |
835 | "callback", wasURLEscape( |
|
- | 836 | wasKeyValueGet( |
||
- | 837 | "URL", |
||
- | 838 | configuration |
||
- | 839 | ) |
||
- | 840 | ) |
||
640 | ] |
841 | ] |
|
641 | ) |
842 | ) |
|
642 | ); |
843 | ); |
|
643 | llSetTimerEvent(60); |
844 | llSetTimerEvent(60); |
|
644 | } |
845 | } |
|
645 | http_request(key id, string method, string body) { |
846 | link_message(integer sender, integer num, string body, key id) { |
|
646 | llHTTPResponse(id, 200, "OK"); |
847 | // Only process callbacks for the database command. |
|
647 | llReleaseURL(URL); |
- | ||
648 | if(wasKeyValueGet("command", body) != "database" || |
848 | if(id != "callback" || wasKeyValueGet("command", body) != "database") |
|
- | 849 | return; |
||
- | 850 | |
||
649 | wasKeyValueGet("success", body) != "True") { |
851 | if(wasKeyValueGet("success", body) != "True") { |
|
650 | // DEBUG |
852 | // DEBUG |
|
651 | llOwnerSay("[MOTD] Unable modify database: " + |
853 | llOwnerSay("[MOTD] Unable modify database: " + |
|
652 | wasURLUnescape( |
854 | wasURLUnescape( |
|
653 | wasKeyValueGet("error", body) |
855 | wasKeyValueGet("error", body) |
|
654 | ) |
856 | ) |
|
Line 657... | Line 859... | |||
657 | } |
859 | } |
|
658 | data = "Saved"; |
860 | data = "Saved"; |
|
659 | state tell; |
861 | state tell; |
|
660 | } |
862 | } |
|
661 | timer() { |
863 | timer() { |
|
662 | llReleaseURL(URL); |
- | ||
663 | state listen_group; |
864 | state listen_group; |
|
664 | } |
865 | } |
|
665 | on_rez(integer num) { |
866 | on_rez(integer num) { |
|
666 | llResetScript(); |
867 | llResetScript(); |
|
667 | } |
868 | } |