corrade-lsl-templates

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 10  →  ?path2? @ 11
/source/eggdrop/ban.lsl
@@ -235,12 +235,14 @@
)
);
// 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,
[wasKeyValueGet("command", configuration), " "], []);
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "ban")
return;
/source/eggdrop/configuration.txt
@@ -12,8 +12,8 @@
# settings in Corrade.ini otherwise the script will not work at all.
 
# Set this to the UUID of the Corrade bot.
# Corrade Resident
corrade = "2783a9d0-7e5d-4598-b127-d88ebdf1091d"
# Ecto Resident
corrade = "2ac12631-b9e8-4ec2-822e-946591a41469"
 
# The name of the group - it can also be the UUID of the group.
group = "My Group"
@@ -21,9 +21,12 @@
# The password for the group.
password = "mypassword"
 
# The version that this template is compatible with.
version = 9.163
# The notification tag - any string you can come up with except the empty string.
notification tag = "5dfea3c3-1d70-4477-89a8-835072fbb6fa"
 
# The version that this template is compatible with (no need to change).
version = 9.164
 
# The character to use for commands.
command = @
 
@@ -30,10 +33,19 @@
# The range for the dice rolling command (inclusive).
roll range = 3,64
 
# The roles that are eligible for administrative group functions.
# The roles that are eligible for administrative group functions such as "eject".
admin roles = Owners,Officers,Ecto
 
# Restrict wiki operations to admin roles.
restricted wiki = True
 
# Wiki database table.
wiki table = "corrade-eggdrop-wiki"
 
# MOTD database table.
motd table = "corrade-eggdrop-motd"
 
# The name of the help notecard in this primitive's inventory.
help card = "[WaS] Corrade: Eggdrop - Help Card"
 
########################### END CONFIGURATION #############################
/source/eggdrop/control.lsl
@@ -122,9 +122,7 @@
string URL = "";
 
// The notifications to bind to.
list notifications = [ "group", "notice" ];
// The tag that this script uses for notifications.
string EGG_TAG = "147d8bf1-4fbc-4c31-b0ea-1d2a72a41041";
list notifications = [ "group", "membership" ];
 
default {
state_entry() {
@@ -296,7 +294,12 @@
)
),
"action", "remove",
"tag", wasURLEscape(EGG_TAG),
"tag", wasURLEscape(
wasKeyValueGet(
"notification tag",
configuration
)
),
"callback", wasURLEscape(URL)
]
)
@@ -367,7 +370,12 @@
)
),
"URL", wasURLEscape(URL),
"tag", wasURLEscape(EGG_TAG),
"tag", wasURLEscape(
wasKeyValueGet(
"notification tag",
configuration
)
),
"callback", wasURLEscape(URL)
]
)
@@ -474,7 +482,7 @@
"version",
configuration
) +
" for this HUD."
" for this template."
);
compatible = FALSE;
//llReleaseURL(URL);
/source/eggdrop/dice.lsl
@@ -220,12 +220,14 @@
)
);
// 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,
[wasKeyValueGet("command", configuration), " "], []);
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "roll")
return;
/source/eggdrop/eval.lsl
@@ -388,12 +388,14 @@
)
);
// 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,
[wasKeyValueGet("command", configuration), " "], []);
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "eval")
return;
/source/eggdrop/fortune.lsl
@@ -259,12 +259,14 @@
)
);
// 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,
[wasKeyValueGet("command", configuration), " "], []);
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "fortune")
return;
/source/eggdrop/help.lsl
@@ -212,6 +212,20 @@
if(wasKeyValueGet("type", message) != "group")
return;
string firstname = wasURLUnescape(
wasKeyValueGet(
"firstname",
message
)
);
string agent = (key)wasURLUnescape(
wasKeyValueGet(
"agent",
message
)
);
// Get the sent message.
data = wasURLUnescape(
wasKeyValueGet(
@@ -228,24 +242,20 @@
[wasKeyValueGet("command", configuration), " "], []);
if(llList2String(command, 0) != "help")
return;
if(llGetInventoryType(wasKeyValueGet("help card", configuration))
!= INVENTORY_NOTECARD) {
data = "Hmm. I have not notecard to hand out - contact my owner please?";
return;
}
// Hand out the notecard.
llGiveInventory(agent,
wasKeyValueGet("help card", configuration)
);
data = "Sent you a help notecard " + firstname + ". Please check your inventory.";
 
data ="
 
~~~~~~~~~ Corrade Eggdrop ~~~~~~~~~
Syntax: @<command> [OPTIONS]
\t@roll <number>\t- Roll a dice with <number> sides.
\t@spank <name>\t- Spank a group member.
\t@wiki <get|set|dir>\t- Wiki commands.
\t@fortune\t\t- Get a random fortune cookie.
\t@joke\t\t- Get a random joke.
\t@eval <expression>\t- Evaluate a mathematical expression.
\t@ban <first> <last>\t- Ban a group member by name.
\t@invite <first> <last>\t- Invite agent to group by name.
 
\t@help\t- This help message.
~~~~~~~~~ Corrade Eggdrop ~~~~~~~~~
";
 
state tell;
}
on_rez(integer num) {
/source/eggdrop/invite.lsl
@@ -222,12 +222,14 @@
)
);
// 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,
[wasKeyValueGet("command", configuration), " "], []);
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "invite")
return;
/source/eggdrop/joke.lsl
@@ -259,12 +259,14 @@
)
);
// 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,
[wasKeyValueGet("command", configuration), " "], []);
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "joke")
return;
/source/eggdrop/motd.lsl
@@ -0,0 +1,696 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
//
// A MOTD module for Corrade Eggdrop.
//
///////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
// 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"
)
);
}
 
// configuration data
string configuration = "";
// callback URL
string URL = "";
// store message over state.
string firstname = "";
string lastname = "";
string group = "";
string data = "";
string jump_state = "";
 
default {
state_entry() {
llOwnerSay("[MOTD] Starting module...");
llSetTimerEvent(10);
}
link_message(integer sender, integer num, string message, key id) {
if(id != "configuration") return;
llOwnerSay("[MOTD] Got configuration...");
configuration = message;
jump_state = "create_database";
state url;
}
timer() {
llOwnerSay("[MOTD] 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 url {
state_entry() {
// DEBUG
llOwnerSay("[MOTD] Requesting URL...");
llRequestURL();
}
http_request(key id, string method, string body) {
if(method != URL_REQUEST_GRANTED) return;
URL = body;
// DEBUG
llOwnerSay("[MOTD] Got URL...");
if(jump_state == "create_database")
state create_database;
if(jump_state == "greet")
state greet;
if(jump_state == "get")
state get;
if(jump_state == "set")
state set;
if(jump_state == "listen_group")
state listen_group;
// DEBUG
llOwnerSay("[MOTD] Jump table corrupted, please contact creator...");
llResetScript();
}
on_rez(integer num) {
llResetScript();
}
changed(integer change) {
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
(change & CHANGED_OWNER)) {
llResetScript();
}
}
}
 
state create_database {
state_entry() {
// DEBUG
llOwnerSay("[MOTD] Creating database.");
llInstantMessage(
wasKeyValueGet(
"corrade",
configuration
),
wasKeyValueEncode(
[
"command", "database",
"group", wasURLEscape(
wasKeyValueGet(
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
configuration
)
),
"SQL", wasURLEscape("CREATE TABLE IF NOT EXISTS \"" +
wasKeyValueGet("motd table", configuration) +
"\" (name text unique collate nocase, data text)"),
"callback", wasURLEscape(URL)
]
)
);
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
llReleaseURL(URL);
if(wasKeyValueGet("command", body) != "database" ||
wasKeyValueGet("success", body) != "True") {
// DEBUG
llOwnerSay("[MOTD] Unable modify database: " +
wasURLUnescape(
wasKeyValueGet("error", body)
)
);
llResetScript();
}
llOwnerSay("[MOTD] Database created!");
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 listen_group {
state_entry() {
// DEBUG
llOwnerSay("[MOTD] Waiting for group messages and new group members.");
}
link_message(integer sender, integer num, string message, key id) {
// We only care about notifications now.
if(id != "notification")
return;
// Get the group.
group = wasURLUnescape(
wasKeyValueGet(
"group",
message
)
);
// Retrieve the membership notification.
if(wasKeyValueGet("type", message) == "membership" &&
wasKeyValueGet("action", message) == "joined") {
firstname = wasURLUnescape(
wasKeyValueGet(
"firstname",
message
)
);
lastname = wasURLUnescape(
wasKeyValueGet(
"lastname",
message
)
);
jump_state = "greet";
state url;
}
// This script only processes group notifications.
if(wasKeyValueGet("type", message) != "group")
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,
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "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;
}
on_rez(integer num) {
llResetScript();
}
changed(integer change) {
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
(change & CHANGED_OWNER)) {
llResetScript();
}
}
}
 
state greet {
state_entry() {
// DEBUG
llOwnerSay("[MOTD] Member joined, retrieving MOTD...");
llInstantMessage(
wasKeyValueGet(
"corrade",
configuration
),
wasKeyValueEncode(
[
"command", "database",
"group", wasURLEscape(
wasKeyValueGet(
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
configuration
)
),
"SQL", wasURLEscape("SELECT data FROM \"" +
wasKeyValueGet("motd table", configuration) +
"\" WHERE name=:group"),
"data", wasURLEscape(
wasListToCSV(
[
"group",
wasURLEscape(group)
]
)
),
"callback", wasURLEscape(URL)
]
)
);
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
llReleaseURL(URL);
if(wasKeyValueGet("command", body) != "database" ||
wasKeyValueGet("success", body) != "True") {
// DEBUG
llOwnerSay("[MOTD] Unable retrieve from database: " +
wasURLUnescape(
wasKeyValueGet("error", body)
)
);
state listen_group;
}
data = llDumpList2String(
llDeleteSubList(
wasCSVToList(
wasURLUnescape(
wasKeyValueGet("data", body)
)
),
0,
0
),
""
);
if(data == "")
state listen_group;
data = "Hello " + firstname + " " + lastname + "!" + " " + data;
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 get {
state_entry() {
// DEBUG
llOwnerSay("[MOTD] Retrieving from database.");
llInstantMessage(
wasKeyValueGet(
"corrade",
configuration
),
wasKeyValueEncode(
[
"command", "database",
"group", wasURLEscape(
wasKeyValueGet(
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
configuration
)
),
"SQL", wasURLEscape("SELECT data FROM \"" +
wasKeyValueGet("motd table", configuration) +
"\" WHERE name=:group"),
"data", wasURLEscape(
wasListToCSV(
[
"group",
wasURLEscape(group)
]
)
),
"callback", wasURLEscape(URL)
]
)
);
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
llReleaseURL(URL);
if(wasKeyValueGet("command", body) != "database" ||
wasKeyValueGet("success", body) != "True") {
// DEBUG
llOwnerSay("[MOTD] Unable retrieve from database: " +
wasURLUnescape(
wasKeyValueGet("error", body)
)
);
state listen_group;
}
data = llDumpList2String(
llDeleteSubList(
wasCSVToList(
wasURLUnescape(
wasKeyValueGet("data", body)
)
),
0,
0
),
""
);
if(data == "") {
data = "Sorry, no MOTD is currently set.";
state tell;
}
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 set {
state_entry() {
// DEBUG
llOwnerSay("[MOTD] Adding to database.");
llInstantMessage(
wasKeyValueGet(
"corrade",
configuration
),
wasKeyValueEncode(
[
"command", "database",
"group", wasURLEscape(
wasKeyValueGet(
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
configuration
)
),
"SQL", wasURLEscape("REPLACE INTO \"" +
wasKeyValueGet("motd table", configuration) +
"\" (name, data) VALUES (:name, :data)"),
"data", wasURLEscape(
wasListToCSV(
[
"name",
wasURLEscape(group),
"data",
wasURLEscape(data)
]
)
),
"callback", wasURLEscape(URL)
]
)
);
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
llReleaseURL(URL);
if(wasKeyValueGet("command", body) != "database" ||
wasKeyValueGet("success", body) != "True") {
// DEBUG
llOwnerSay("[MOTD] Unable modify database: " +
wasURLUnescape(
wasKeyValueGet("error", body)
)
);
state listen_group;
}
data = "Saved";
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 tell {
state_entry() {
// DEBUG
llOwnerSay("[MOTD] 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)
]
)
);
state listen_group;
}
}
/source/eggdrop/spank.lsl
@@ -220,12 +220,14 @@
)
);
// 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,
[wasKeyValueGet("command", configuration), " "], []);
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "spank")
return;
@@ -303,7 +305,7 @@
wasListToCSV(
[
"match",
wasURLEscape("(?i),?([^,$]*" + data +"[^,$]*),?")
wasURLEscape("(?i),?\"([^\",$]*" + data + "[^\",$]*)\",?")
]
)
),
@@ -328,21 +330,25 @@
}
// Dump the members to a list.
data = llList2CSV(
wasCSVToList(
wasURLUnescape(
wasKeyValueGet("data", body)
)
list spankees = wasCSVToList(
wasURLUnescape(
wasKeyValueGet("data", body)
)
);
// Limit to two people to spank.
if(llGetListLength(spankees) > 2) {
data = "So many people, so few hands!";
return;
}
data = llList2CSV(spankees);
if(data == "") {
data = "I could not find anyone to spank (story of my life).";
state tell;
}
llOwnerSay("Spanking: " + data);
data = "/me spanks " + data;
state tell;
/source/eggdrop/unban.lsl
@@ -0,0 +1,586 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
//
// A module that unbans group members using fuzzy name matching.
//
///////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
// 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 = "";
// banee
string firstname = "";
string lastname = "";
 
default {
state_entry() {
llOwnerSay("[Unban] Starting...");
llSetTimerEvent(10);
}
link_message(integer sender, integer num, string message, key id) {
if(id != "configuration") return;
llOwnerSay("[Unban] Got configuration...");
configuration = message;
state listen_group;
}
timer() {
llOwnerSay("[Unban] 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("[Unban] 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")
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,
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "unban")
return;
firstname = wasKeyValueGet("firstname", message);
lastname = wasKeyValueGet("lastname", message);
if(firstname == "" || lastname == "") {
data = "And who would yarr be?";
state tell;
}
// Remove command.
command = llDeleteSubList(command, 0, 0);
// 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("[Unban] Requesting URL...");
llRequestURL();
}
http_request(key id, string method, string body) {
if(method != URL_REQUEST_GRANTED) return;
URL = body;
// DEBUG
llOwnerSay("[Unban] 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("[Unban] 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("[Unban] 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 banee = llParseString2List(data, [" "], []);
firstname = llList2String(banee, 0);
lastname = llList2String(banee, 1);
if(firstname == "" || lastname == "") {
data = "Full name required.";
state tell;
}
// GC
banee = [];
state get_banee_roles;
}
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 get_banee_roles {
state_entry() {
// DEBUG
llOwnerSay("[Unban] Searching for banee...");
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("[Unban] Unable to get member roles: " +
wasURLUnescape(
wasKeyValueGet("error", body)
)
);
llReleaseURL(URL);
state listen_group;
}
string result = wasURLUnescape(
wasKeyValueGet("data", body)
);
if(result != "" && llListFindList(wasCSVToList(result), (list)"Owners") != -1) {
data = "Ejectee is an owner. I'm not gonna open the pod bay doors.";
llReleaseURL(URL);
state tell;
}
state ban;
}
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 ban {
state_entry() {
// DEBUG
llOwnerSay("[Unban] Unbanning...");
llInstantMessage(
wasKeyValueGet(
"corrade",
configuration
),
wasKeyValueEncode(
[
"command", "unban",
"group", wasURLEscape(
wasKeyValueGet(
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
configuration
)
),
"action", "unban",
"avatars", wasURLEscape(
wasListToCSV(
[
firstname + " " + lastname
]
)
),
"callback", wasURLEscape(URL)
]
)
);
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
llReleaseURL(URL);
if(wasKeyValueGet("command", body) != "ban" ||
wasKeyValueGet("success", body) != "True") {
// DEBUG
llOwnerSay("[Unban] Unable to ban member: " +
wasURLUnescape(
wasKeyValueGet("error", body)
)
);
state listen_group;
}
data = "Hasta la vista, baby!";
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 tell {
state_entry() {
// DEBUG
llOwnerSay("[Unban] 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)
]
)
);
state listen_group;
}
}
/source/eggdrop/wiki.lsl
@@ -273,7 +273,9 @@
configuration
)
),
"SQL", wasURLEscape("CREATE TABLE IF NOT EXISTS corradeeggdrop (path text unique collate nocase, data text)"),
"SQL", wasURLEscape("CREATE TABLE IF NOT EXISTS \"" +
wasKeyValueGet("wiki table", configuration) +
"\" (path text unique collate nocase, data text)"),
"callback", wasURLEscape(URL)
]
)
@@ -337,12 +339,14 @@
)
);
// 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,
[wasKeyValueGet("command", configuration), " "], []);
[wasKeyValueGet("command", configuration), " "], ["@"]);
if(llList2String(command, 0) != "wiki")
return;
@@ -436,12 +440,16 @@
configuration
)
),
"SQL", wasURLEscape("DELETE FROM corradeeggdrop WHERE path=:path"),
"data", wasListToCSV(
[
"path",
wasURLEscape("path")
]
"SQL", wasURLEscape("DELETE FROM \"" +
wasKeyValueGet("wiki table", configuration) +
"\" WHERE path=:path"),
"data", wasURLEscape(
wasListToCSV(
[
"path",
wasURLEscape("path")
]
)
),
"callback", wasURLEscape(URL)
]
@@ -472,14 +480,18 @@
configuration
)
),
"SQL", wasURLEscape("REPLACE INTO corradeeggdrop (path, data) VALUES (:path, :data)"),
"data", wasListToCSV(
[
"path",
wasURLEscape("path"),
"data",
wasURLEscape("data")
]
"SQL", wasURLEscape("REPLACE INTO \"" +
wasKeyValueGet("wiki table", configuration) +
"\" (path, data) VALUES (:path, :data)"),
"data", wasURLEscape(
wasListToCSV(
[
"path",
wasURLEscape(path),
"data",
wasURLEscape(data)
]
)
),
"callback", wasURLEscape(URL)
]
@@ -550,12 +562,16 @@
configuration
)
),
"SQL", wasURLEscape("SELECT data FROM corradeeggdrop WHERE path=:path"),
"data", wasListToCSV(
[
"path",
wasURLEscape(path)
]
"SQL", wasURLEscape("SELECT data FROM \"" +
wasKeyValueGet("wiki table", configuration) +
"\" WHERE path=:path"),
"data", wasURLEscape(
wasListToCSV(
[
"path",
wasURLEscape(path)
]
)
),
"callback", wasURLEscape(URL)
]
@@ -641,12 +657,16 @@
configuration
)
),
"SQL", wasURLEscape("SELECT path FROM corradeeggdrop WHERE path like :path"),
"data", wasListToCSV(
[
"path",
wasURLEscape(path + "%")
]
"SQL", wasURLEscape("SELECT path FROM \"" +
wasKeyValueGet("wiki table", configuration) +
"\" WHERE path like :path"),
"data", wasURLEscape(
wasListToCSV(
[
"path",
wasURLEscape(path + "%")
]
)
),
"callback", wasURLEscape(URL)
]