dd838603-c083-3074-23cc-195cd2856a91_script.lsl 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. // How many seconds between each email check
  4. float EMAIL_CHECK_PERIOD = 30.0;
  5. // Subject of emails to check for
  6. string EMAIL_SUBJECT_LOGIN = "SLOODLE_LOGIN";
  7. ///// TRANSLATION /////
  8. integer SLOODLE_CHANNEL_TRANSLATION_REQUEST = -1928374651;
  9. string SLOODLE_TRANSLATE_IM = "instantmessage"; // Recipient avatar should be identified in link message keyval. No output parameters.
  10. // Send a translation request link message
  11. sloodle_translation_request(string output_method, list output_params, string string_name, list string_params, key keyval, string batch)
  12. {
  13. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_TRANSLATION_REQUEST, output_method + "|" + llList2CSV(output_params) + "|" + string_name + "|" + llList2CSV(string_params) + "|" + batch, keyval);
  14. }
  15. ///// ----------- /////
  16. default
  17. {
  18. state_entry()
  19. {
  20. // Start the timer for email checking
  21. llSetTimerEvent(EMAIL_CHECK_PERIOD);
  22. }
  23. timer()
  24. {
  25. // Check for new emails
  26. llGetNextEmail("", EMAIL_SUBJECT_LOGIN);
  27. }
  28. email(string time, string address, string subject, string msg, integer num_left)
  29. {
  30. //llOwnerSay("Received email from \"" + address + "\".\nSubject: \"" + subject + "\"\nMessage: \"" + msg + "\"");
  31. // Reset the timer (in case this was triggered by this event, not by the timer)
  32. llSetTimerEvent(EMAIL_CHECK_PERIOD);
  33. // Check the subject line of the email
  34. if (subject == EMAIL_SUBJECT_LOGIN) {
  35. // Split off the headers
  36. list parts = llParseStringKeepNulls(msg, ["\n\n"], []);
  37. string body = "";
  38. if (llGetListLength(parts) >= 2) {
  39. body = llList2String(parts, 1);
  40. } else {
  41. body = msg;
  42. }
  43. // Parse the data fields
  44. list fields = llParseStringKeepNulls(body, ["|"], []);
  45. // Make sure we have enough
  46. if (llGetListLength(fields) >= 3) {
  47. // Extract the individual fields
  48. key useruuid = (key)llList2String(fields, 0);
  49. string website = llList2String(fields, 1);
  50. string username = llList2String(fields, 2);
  51. string password = llList2String(fields, 3);
  52. // Send the information to the user
  53. if (useruuid != NULL_KEY) {
  54. sloodle_translation_request(SLOODLE_TRANSLATE_IM, [], "autoreg:newaccount", [website, username, password], useruuid, "");
  55. }
  56. }
  57. }
  58. // Are there more emails to check for?
  59. if (num_left > 0) {
  60. // Yes - get the next one
  61. llGetNextEmail("", EMAIL_SUBJECT_LOGIN);
  62. }
  63. }
  64. }
  65. // Please leave the following line intact to show where the script lives in Git:
  66. // SLOODLE LSL Script Git Location: assets/sloodle_email_login_details.lslp