instantmessager.lslp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Sloodle Instant Messager
  2. // Gets instant messages on the HTTP-in channel from the sloodle_rezzer_object, instant messages the content to the user.
  3. //
  4. // Copyright (c) 2012 contributors (see below)
  5. // Released under the GNU GPL
  6. //
  7. // Contributors:
  8. // Edmund Edgar
  9. // Paul Preibisch
  10. //
  11. integer SLOODLE_CHANNEL_MESSAGER_INSTANT_MESSAGE = 163290001;
  12. // Only one state - all we ever do is relay instant messages.
  13. default
  14. {
  15. link_message( integer sender_num, integer num, string str, key id)
  16. {
  17. // llOwnerSay("got message"+str+" with num "+(string)num);
  18. // Check the channel
  19. if (num == SLOODLE_CHANNEL_MESSAGER_INSTANT_MESSAGE) {
  20. // Split the message into lines
  21. list lines = llParseString2List(str, ["\n"], []);
  22. integer numlines = llGetListLength(lines);
  23. key avuuid = NULL_KEY;
  24. string message = "";
  25. integer i = 0;
  26. for (i=1; i < numlines; i++) { // start at line 1 and ignore the status line.
  27. list bits = llParseString2List(llList2String(lines, i), ["|"], []);
  28. if (llGetListLength(bits) > 1) {
  29. string name = llList2String(bits, 0);
  30. if (name == "avuuid") {
  31. avuuid = llList2Key(bits, 1);
  32. } else if (name == "message") {
  33. message = llList2String(bits, 1);
  34. }
  35. }
  36. }
  37. if ( (avuuid != NULL_KEY) && (message != "") ) {
  38. llInstantMessage(avuuid, message );
  39. }
  40. }
  41. }
  42. }
  43. // Please leave the following line intact to show where the script lives in Git:
  44. // SLOODLE LSL Script Git Location: mod/messager-1.0/objects/instantmessager/assets/instantmessager.lslp