/source/eggdrop/ai.lsl |
@@ -179,8 +179,6 @@ |
string URL = ""; |
// store message over state. |
string data = ""; |
string jump_table = ""; |
string messageHash = ""; |
|
default { |
state_entry() { |
@@ -191,10 +189,7 @@ |
if(id != "configuration") return; |
llOwnerSay("[AI] Got configuration..."); |
configuration = message; |
|
// Subscribe to MQTT messages. |
jump_table = "subscribe"; |
state url; |
state listen_group; |
} |
timer() { |
llOwnerSay("[AI] Requesting configuration..."); |
@@ -215,135 +210,6 @@ |
} |
} |
|
state url { |
state_entry() { |
// DEBUG |
llOwnerSay("[AI] Requesting URL..."); |
llRequestURL(); |
} |
http_request(key id, string method, string body) { |
if(method != URL_REQUEST_GRANTED) return; |
URL = body; |
|
// DEBUG |
llOwnerSay("[AI] Got URL..."); |
|
if(jump_table == "subscribe") |
state subscribe; |
if(jump_table == "publish") |
state publish; |
} |
on_rez(integer num) { |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
} |
} |
|
state subscribe { |
state_entry() { |
// DEBUG |
llOwnerSay("[AI] Subscribing to Corrade AI..."); |
llInstantMessage( |
wasKeyValueGet( |
"corrade", |
configuration |
), |
wasKeyValueEncode( |
[ |
"command", "MQTT", |
"group", wasURLEscape( |
wasKeyValueGet( |
"group", |
configuration |
) |
), |
"password", wasURLEscape( |
wasKeyValueGet( |
"password", |
configuration |
) |
), |
// Subscribe to Corrade AI |
"action", "subscribe", |
"id", wasURLEscape( |
wasKeyValueGet( |
"ai subscription", |
configuration |
) |
), |
// Corrade AI listening host. |
"host", wasURLEscape( |
wasKeyValueGet( |
"ai host", |
configuration |
) |
), |
// Corrade AI listening port. |
"port", wasURLEscape( |
wasKeyValueGet( |
"ai port", |
configuration |
) |
), |
// Corrade AI credentials. |
"username", wasURLEscape( |
wasKeyValueGet( |
"ai username", |
configuration |
) |
), |
"secret", wasURLEscape( |
wasKeyValueGet( |
"ai secret", |
configuration |
) |
), |
// Use the SIML module of Corrade AI. |
"topic", "SIML", |
// Send the result of the MQTT command to this URL. |
"callback", wasURLEscape(URL) |
] |
) |
); |
} |
|
http_request(key id, string method, string body) { |
llHTTPResponse(id, 200, "OK"); |
llReleaseURL(URL); |
if(wasKeyValueGet("command", body) != "MQTT" || |
wasKeyValueGet("success", body) != "True") { |
// DEBUG |
llOwnerSay("[AI] Unable to subscribe to MQTT topic: " + |
wasURLUnescape( |
wasKeyValueGet("error", body) |
) |
); |
llResetScript(); |
} |
|
state listen_group; |
} |
on_rez(integer num) { |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
} |
state_exit() { |
llSetTimerEvent(0); |
} |
} |
|
state listen_group { |
state_entry() { |
// DEBUG |
@@ -354,7 +220,7 @@ |
if(id != "notification") |
return; |
|
// Listen to group message notifications. |
// This script only processes group notifications. |
if(wasKeyValueGet("type", message) != "group") |
return; |
|
@@ -385,7 +251,6 @@ |
data = llDumpList2String(command, " "); |
|
// Get an URL. |
jump_table = "publish"; |
state url; |
} |
on_rez(integer num) { |
@@ -400,13 +265,35 @@ |
} |
} |
|
state publish { |
state url { |
state_entry() { |
// DEBUG |
llOwnerSay("[AI] Requesting URL..."); |
llRequestURL(); |
} |
http_request(key id, string method, string body) { |
if(method != URL_REQUEST_GRANTED) return; |
URL = body; |
// DEBUG |
llOwnerSay("[AI] Got URL..."); |
state version; |
} |
on_rez(integer num) { |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
} |
} |
|
state version { |
state_entry() { |
// DEBUG |
llOwnerSay("[AI] Sending to AI for processing..."); |
|
messageHash = llSHA1String(data); |
|
llInstantMessage( |
wasKeyValueGet( |
"corrade", |
@@ -414,7 +301,7 @@ |
), |
wasKeyValueEncode( |
[ |
"command", "MQTT", |
"command", "ai", |
"group", wasURLEscape( |
wasKeyValueGet( |
"group", |
@@ -427,48 +314,8 @@ |
configuration |
) |
), |
"action", "publish", |
// Corrade AI listening host. |
"host", wasURLEscape( |
wasKeyValueGet( |
"ai host", |
configuration |
) |
), |
// Corrade AI listening port. |
"port", wasURLEscape( |
wasKeyValueGet( |
"ai port", |
configuration |
) |
), |
// Corrade AI credentials. |
"username", wasURLEscape( |
wasKeyValueGet( |
"ai username", |
configuration |
) |
), |
"secret", wasURLEscape( |
wasKeyValueGet( |
"ai secret", |
configuration |
) |
), |
// Use the SIML module of Corrade AI. |
"topic", "SIML", |
"payload", wasURLEscape( |
wasKeyValueEncode( |
[ |
// The hash is an identifier that will allow responses from Corrade AI |
// for various messages to be distinguished. It can be any identifier |
// but a handy way of generating an identifier is to hash the message. |
"Hash", messageHash, |
// Note the double escaping! |
"Message", wasURLEscape(data) |
] |
) |
), |
"action", "process", |
"message", wasURLEscape(data), |
"callback", wasURLEscape(URL) |
] |
) |
@@ -478,63 +325,20 @@ |
http_request(key id, string method, string body) { |
llHTTPResponse(id, 200, "OK"); |
llReleaseURL(URL); |
if(wasKeyValueGet("command", body) != "MQTT" || |
if(wasKeyValueGet("command", body) != "ai" || |
wasKeyValueGet("success", body) != "True") { |
// DEBUG |
llOwnerSay("[AI] Unable to publish message: " + |
llOwnerSay("[AI] Unable to get processed message: " + |
wasURLUnescape( |
wasKeyValueGet("data", body) |
wasKeyValueGet("error", body) |
) |
); |
state listen_group; |
} |
|
// DEBUG |
llOwnerSay("[AI] Message published successfully..."); |
} |
link_message(integer sender, integer num, string message, key id) { |
// We only care about notifications now. |
if(id != "notification") |
return; |
// Get the processed message. |
data = wasKeyValueGet("data", body); |
|
// Listen to MQTT messages. |
if(wasKeyValueGet("type", message) != "MQTT") |
return; |
|
// Get the sent message. |
data = wasURLUnescape( |
wasKeyValueGet( |
"payload", |
message |
) |
); |
|
string hash = wasURLUnescape( |
wasKeyValueGet( |
"Hash", |
data |
) |
); |
|
string serverMessage = wasURLUnescape( |
wasKeyValueGet( |
"ServerMessage", |
data |
) |
); |
|
// Skip generated messages that are not for the published message. |
if(hash != messageHash || |
serverMessage != "True") |
return; |
|
data = wasURLUnescape( |
wasKeyValueGet( |
"Message", |
data |
) |
); |
|
state tell; |
} |
timer() { |
@@ -581,7 +385,7 @@ |
) |
), |
"entity", "group", |
"message", wasURLEscape(data) |
"message", data // message is already encoded |
] |
) |
); |
/source/eggdrop/motd.lsl |
@@ -5,7 +5,7 @@ |
// A MOTD module for Corrade Eggdrop. |
// |
/////////////////////////////////////////////////////////////////////////// |
|
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
@@ -32,7 +32,7 @@ |
} while(llGetListLength(k) != 0); |
return llDumpList2String(data, "&"); |
} |
|
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
@@ -44,7 +44,7 @@ |
return <x, y, 0>; |
return wasCirclePoint(radius); |
} |
|
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
@@ -68,7 +68,7 @@ |
} while(i != ""); |
return o; |
} |
|
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
@@ -107,7 +107,7 @@ |
// postcondition: length(s) = 0 |
return l + m; |
} |
|
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
@@ -136,7 +136,7 @@ |
} while(l != []); |
return llDumpList2String(v, ","); |
} |
|
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
@@ -160,7 +160,7 @@ |
) |
); |
} |
|
|
// configuration data |
string configuration = ""; |
// callback URL |
@@ -171,7 +171,7 @@ |
string group = ""; |
string data = ""; |
string jump_state = ""; |
|
|
default { |
state_entry() { |
llOwnerSay("[MOTD] Starting module..."); |
@@ -202,7 +202,7 @@ |
llSetTimerEvent(0); |
} |
} |
|
|
state url { |
state_entry() { |
// DEBUG |
@@ -224,7 +224,7 @@ |
state set; |
if(jump_state == "listen_group") |
state listen_group; |
|
|
// DEBUG |
llOwnerSay("[MOTD] Jump table corrupted, please contact creator..."); |
llResetScript(); |
@@ -240,11 +240,11 @@ |
} |
} |
} |
|
|
state create_database { |
state_entry() { |
// DEBUG |
llOwnerSay("[MOTD] Creating database: " + wasKeyValueGet("motd table", configuration)); |
llOwnerSay("[MOTD] Creating database."); |
llInstantMessage( |
wasKeyValueGet( |
"corrade", |
@@ -283,12 +283,7 @@ |
llOwnerSay("[MOTD] Unable modify database: " + |
wasURLUnescape( |
wasKeyValueGet("error", body) |
) + |
" " + |
wasURLUnescape( |
wasKeyValueGet("data", body) |
) |
|
); |
llResetScript(); |
} |
@@ -313,8 +308,8 @@ |
llSetTimerEvent(0); |
} |
} |
|
|
|
|
state listen_group { |
state_entry() { |
// DEBUG |
@@ -324,7 +319,7 @@ |
// We only care about notifications now. |
if(id != "notification") |
return; |
|
|
// Get the group. |
group = wasURLUnescape( |
wasKeyValueGet( |
@@ -332,7 +327,7 @@ |
message |
) |
); |
|
|
// Retrieve the membership notification. |
if(wasKeyValueGet("type", message) == "membership" && |
wasKeyValueGet("action", message) == "joined") { |
@@ -351,11 +346,11 @@ |
jump_state = "greet"; |
state url; |
} |
|
|
// This script only processes group notifications. |
if(wasKeyValueGet("type", message) != "group") |
return; |
|
|
// Get the sent message. |
data = wasURLUnescape( |
wasKeyValueGet( |
@@ -363,30 +358,30 @@ |
message |
) |
); |
|
|
// Check if this is an eggdrop command. |
if(llGetSubString(data, 0, 0) != |
wasKeyValueGet("command", configuration)) |
return; |
|
|
// Check if the command matches the current module. |
list command = llParseString2List(data, [" "], []); |
if(llList2String(command, 0) != |
wasKeyValueGet("command", configuration) + "motd") |
return; |
|
|
// Remove command. |
command = llDeleteSubList(command, 0, 0); |
|
|
// Dump the rest of the message. |
data = llDumpList2String(command, " "); |
|
|
// Get the sent message. |
if(data == "") { |
jump_state = "get"; |
state url; |
} |
|
|
jump_state = "set"; |
state url; |
} |
@@ -401,7 +396,7 @@ |
} |
} |
} |
|
|
state greet { |
state_entry() { |
// DEBUG |
@@ -456,7 +451,7 @@ |
); |
state listen_group; |
} |
|
|
data = llDumpList2String( |
llDeleteSubList( |
wasCSVToList( |
@@ -469,10 +464,10 @@ |
), |
"" |
); |
|
|
if(data == "") |
state listen_group; |
|
|
data = "Hello " + firstname + " " + lastname + "!" + " " + data; |
state tell; |
} |
@@ -494,7 +489,7 @@ |
llSetTimerEvent(0); |
} |
} |
|
|
state get { |
state_entry() { |
// DEBUG |
@@ -526,12 +521,7 @@ |
wasListToCSV( |
[ |
"group", |
wasURLEscape( |
wasKeyValueGet( |
"group", |
configuration |
) |
) |
wasURLEscape(group) |
] |
) |
), |
@@ -554,7 +544,7 @@ |
); |
state listen_group; |
} |
|
|
data = llDumpList2String( |
llDeleteSubList( |
wasCSVToList( |
@@ -567,12 +557,12 @@ |
), |
"" |
); |
|
|
if(data == "") { |
data = "Sorry, no MOTD is currently set."; |
state tell; |
} |
|
|
state tell; |
} |
timer() { |
@@ -593,7 +583,7 @@ |
llSetTimerEvent(0); |
} |
} |
|
|
state set { |
state_entry() { |
// DEBUG |
@@ -625,12 +615,7 @@ |
wasListToCSV( |
[ |
"name", |
wasURLEscape( |
wasKeyValueGet( |
"group", |
configuration |
) |
), |
wasURLEscape(group), |
"data", |
wasURLEscape(data) |
] |
@@ -676,7 +661,7 @@ |
llSetTimerEvent(0); |
} |
} |
|
|
state tell { |
state_entry() { |
// DEBUG |
/source/eggdrop/stitch.lsl |
@@ -0,0 +1,528 @@ |
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// |
// A module that upgrades or downgrades Corrade via Stitch. |
// |
/////////////////////////////////////////////////////////////////////////// |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
string wasKeyValueGet(string k, string data) { |
if(llStringLength(data) == 0) return ""; |
if(llStringLength(k) == 0) return ""; |
list a = llParseString2List(data, ["&", "="], []); |
integer i = llListFindList(a, [ k ]); |
if(i != -1) return llList2String(a, i+1); |
return ""; |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
string wasKeyValueEncode(list data) { |
list k = llList2ListStrided(data, 0, -1, 2); |
list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); |
data = []; |
do { |
data += llList2String(k, 0) + "=" + llList2String(v, 0); |
k = llDeleteSubList(k, 0, 0); |
v = llDeleteSubList(v, 0, 0); |
} while(llGetListLength(k) != 0); |
return llDumpList2String(data, "&"); |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// http://was.fm/secondlife/wanderer |
vector wasCirclePoint(float radius) { |
float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) |
return <x, y, 0>; |
return wasCirclePoint(radius); |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// escapes a string in conformance with RFC1738 |
string wasURLEscape(string i) { |
string o = ""; |
do { |
string c = llGetSubString(i, 0, 0); |
i = llDeleteSubString(i, 0, 0); |
if(c == "") jump continue; |
if(c == " ") { |
o += "+"; |
jump continue; |
} |
if(c == "\n") { |
o += "%0D" + llEscapeURL(c); |
jump continue; |
} |
o += llEscapeURL(c); |
@continue; |
} while(i != ""); |
return o; |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
list wasCSVToList(string csv) { |
list l = []; |
list s = []; |
string m = ""; |
do { |
string a = llGetSubString(csv, 0, 0); |
csv = llDeleteSubString(csv, 0, 0); |
if(a == ",") { |
if(llList2String(s, -1) != "\"") { |
l += m; |
m = ""; |
jump continue; |
} |
m += a; |
jump continue; |
} |
if(a == "\"" && llGetSubString(csv, 0, 0) == a) { |
m += a; |
csv = llDeleteSubString(csv, 0, 0); |
jump continue; |
} |
if(a == "\"") { |
if(llList2String(s, -1) != a) { |
s += a; |
jump continue; |
} |
s = llDeleteSubList(s, -1, -1); |
jump continue; |
} |
m += a; |
@continue; |
} while(csv != ""); |
// postcondition: length(s) = 0 |
return l + m; |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
string wasListToCSV(list l) { |
list v = []; |
do { |
string a = llDumpList2String( |
llParseStringKeepNulls( |
llList2String( |
l, |
0 |
), |
["\""], |
[] |
), |
"\"\"" |
); |
if(llParseStringKeepNulls( |
a, |
[" ", ",", "\n", "\""], [] |
) != |
(list) a |
) a = "\"" + a + "\""; |
v += a; |
l = llDeleteSubList(l, 0, 0); |
} while(l != []); |
return llDumpList2String(v, ","); |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// unescapes a string in conformance with RFC1738 |
string wasURLUnescape(string i) { |
return llUnescapeURL( |
llDumpList2String( |
llParseString2List( |
llDumpList2String( |
llParseString2List( |
i, |
["+"], |
[] |
), |
" " |
), |
["%0D%0A"], |
[] |
), |
"\n" |
) |
); |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
list wasSetIntersect(list a, list b) { |
if(llGetListLength(a) == 0) return []; |
string i = llList2String(a, 0); |
a = llDeleteSubList(a, 0, 0); |
if(llListFindList(b, (list)i) == -1) |
return wasSetIntersect(a, b); |
return i + wasSetIntersect(a, b); |
} |
|
// configuration data |
string configuration = ""; |
// callback URL |
string URL = ""; |
// store message over state. |
string data = ""; |
string version = ""; |
string firstname = ""; |
string lastname = ""; |
string jump_state = ""; |
|
default { |
state_entry() { |
llOwnerSay("[Stitch] Starting..."); |
llSetTimerEvent(10); |
} |
link_message(integer sender, integer num, string message, key id) { |
if(id != "configuration") return; |
llOwnerSay("[Stitch] Got configuration..."); |
configuration = message; |
state listen_group; |
} |
timer() { |
llOwnerSay("[Stitch] Requesting configuration..."); |
llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY); |
} |
on_rez(integer num) { |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
} |
state_exit() { |
llSetTimerEvent(0); |
} |
} |
|
state listen_group { |
state_entry() { |
// DEBUG |
llOwnerSay("[Stitch] Waiting for group messages..."); |
} |
link_message(integer sender, integer num, string message, key id) { |
// We only care about notifications now. |
if(id != "notification") |
return; |
|
// This script only processes group notifications. |
if(wasKeyValueGet("type", message) != "group" && |
wasKeyValueGet("type", message) != "login") |
return; |
|
// Process login notification. |
if(wasKeyValueGet("type", message) == "login") { |
string action = wasKeyValueGet("action", message); |
string loginVersion = wasKeyValueGet("version", message); |
if(action == "logout") { |
version = loginVersion; |
return; |
} |
if(action == "login" && loginVersion != version) { |
data = "I have been stitched to version v" + loginVersion; |
version = loginVersion; |
state tell; |
} |
// Unknown login action. |
return; |
} |
|
// Get the sent message. |
data = wasURLUnescape( |
wasKeyValueGet( |
"message", |
message |
) |
); |
|
// Check if this is an eggdrop command. |
if(llGetSubString(data, 0, 0) != |
wasKeyValueGet("command", configuration)) |
return; |
|
// Check if the command matches the current module. |
list command = llParseString2List(data, [" "], []); |
if(llList2String(command, 0) != |
wasKeyValueGet("command", configuration) + "stitch") |
return; |
|
// Remove command. |
command = llDeleteSubList(command, 0, 0); |
|
firstname = wasKeyValueGet("firstname", message); |
lastname = wasKeyValueGet("lastname", message); |
|
if(firstname == "" || lastname == "") { |
data = "And who would yarr be?"; |
state tell; |
} |
|
// Dump the rest of the message. |
data = llDumpList2String(command, " "); |
|
// Get an URL. |
state url; |
} |
on_rez(integer num) { |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
} |
} |
|
state url { |
state_entry() { |
// DEBUG |
llOwnerSay("[Stitch] Requesting URL..."); |
llRequestURL(); |
} |
http_request(key id, string method, string body) { |
if(method != URL_REQUEST_GRANTED) return; |
URL = body; |
// DEBUG |
llOwnerSay("[Stitch] Got URL..."); |
state get_caller_roles; |
} |
on_rez(integer num) { |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
} |
} |
|
state get_caller_roles { |
state_entry() { |
// DEBUG |
llOwnerSay("[Stitch] Searching for caller..."); |
llInstantMessage( |
wasKeyValueGet( |
"corrade", |
configuration |
), |
wasKeyValueEncode( |
[ |
"command", "getmemberroles", |
"group", wasURLEscape( |
wasKeyValueGet( |
"group", |
configuration |
) |
), |
"password", wasURLEscape( |
wasKeyValueGet( |
"password", |
configuration |
) |
), |
"firstname", firstname, |
"lastname", lastname, |
"callback", wasURLEscape(URL) |
] |
) |
); |
llSetTimerEvent(60); |
} |
http_request(key id, string method, string body) { |
llHTTPResponse(id, 200, "OK"); |
if(wasKeyValueGet("command", body) != "getmemberroles" || |
wasKeyValueGet("success", body) != "True") { |
// DEBUG |
llOwnerSay("[Stitch] Unable to get member roles: " + |
wasURLUnescape( |
wasKeyValueGet("error", body) |
) |
); |
llReleaseURL(URL); |
state listen_group; |
} |
|
// Dump the roles to a list. |
list roles = wasCSVToList( |
wasURLUnescape( |
wasKeyValueGet("data", body) |
) |
); |
|
if(llGetListLength( |
wasSetIntersect(roles, |
wasCSVToList( |
wasKeyValueGet( |
"admin roles", configuration |
) |
) |
) |
) == 0) { |
data = "You ain't got the cojones!"; |
llReleaseURL(URL); |
state tell; |
} |
|
list command = llParseString2List(data, [" "], []); |
|
version = llList2String(command, 0); |
|
// GC |
command = []; |
|
if(version == "") |
version = "\"latest\""; |
|
// Announce stitching process. |
data = "Stitching to: " + version; |
jump_state = "stitch"; |
state tell; |
} |
timer() { |
llReleaseURL(URL); |
state listen_group; |
} |
on_rez(integer num) { |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
} |
state_exit() { |
llSetTimerEvent(0); |
} |
} |
|
state stitch { |
state_entry() { |
// DEBUG |
llOwnerSay("[Stitch] Stitching..."); |
llInstantMessage( |
wasKeyValueGet( |
"corrade", |
configuration |
), |
wasKeyValueEncode( |
[ |
"command", "stitch", |
"group", wasURLEscape( |
wasKeyValueGet( |
"group", |
configuration |
) |
), |
"password", wasURLEscape( |
wasKeyValueGet( |
"password", |
configuration |
) |
), |
"action", "stitch", |
"version", version, |
"callback", wasURLEscape(URL) |
] |
) |
); |
llSetTimerEvent(60); |
} |
http_request(key id, string method, string body) { |
llHTTPResponse(id, 200, "OK"); |
llReleaseURL(URL); |
if(wasKeyValueGet("command", body) != "stitch" || |
wasKeyValueGet("success", body) != "True") { |
// DEBUG |
llOwnerSay("[Stitch] Unable to stitch: " + |
wasURLUnescape( |
wasKeyValueGet("error", body) |
) |
); |
state listen_group; |
} |
|
// Corrade proceeds with termination - cannot (should not) announce via "tell". |
state listen_group; |
} |
timer() { |
llReleaseURL(URL); |
state listen_group; |
} |
on_rez(integer num) { |
llResetScript(); |
} |
changed(integer change) { |
if((change & CHANGED_INVENTORY) || |
(change & CHANGED_REGION_START) || |
(change & CHANGED_OWNER)) { |
llResetScript(); |
} |
} |
state_exit() { |
llSetTimerEvent(0); |
} |
} |
|
state tell { |
state_entry() { |
// DEBUG |
llOwnerSay("[Stitch] Sending to group."); |
llInstantMessage( |
wasKeyValueGet( |
"corrade", |
configuration |
), |
wasKeyValueEncode( |
[ |
"command", "tell", |
"group", wasURLEscape( |
wasKeyValueGet( |
"group", |
configuration |
) |
), |
"password", wasURLEscape( |
wasKeyValueGet( |
"password", |
configuration |
) |
), |
"entity", "group", |
"message", wasURLEscape(data) |
] |
) |
); |
|
// jump table |
string nextState = jump_state; |
jump_state = ""; |
if(nextState == "stitch") |
state stitch; |
state listen_group; |
} |
} |