corrade-lsl-templates

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 41  →  ?path2? @ 42
/source/eggdrop/softunban.lsl
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 //
// Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
//
// A module that unbans group members using fuzzy name matching.
@@ -17,9 +17,9 @@
if(i != -1) return llList2String(a, 2*i+1);
return "";
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueEncode(list data) {
list k = llList2ListStrided(data, 0, -1, 2);
@@ -34,7 +34,7 @@
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
// http://was.fm/secondlife/wanderer
vector wasCirclePoint(float radius) {
@@ -46,7 +46,7 @@
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
// escapes a string in conformance with RFC1738
string wasURLEscape(string i) {
@@ -70,7 +70,7 @@
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
list wasCSVToList(string csv) {
list l = [];
@@ -109,7 +109,7 @@
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
string wasListToCSV(list l) {
list v = [];
@@ -117,18 +117,18 @@
string a = llDumpList2String(
llParseStringKeepNulls(
llList2String(
l,
l,
0
),
["\""],
),
["\""],
[]
),
"\"\""
);
if(llParseStringKeepNulls(
a,
a,
[" ", ",", "\n", "\""], []
) !=
) !=
(list) a
) a = "\"" + a + "\"";
v += a;
@@ -138,7 +138,7 @@
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
// unescapes a string in conformance with RFC1738
string wasURLUnescape(string i) {
@@ -147,15 +147,15 @@
llParseString2List(
llDumpList2String(
llParseString2List(
i,
["+"],
i,
["+"],
[]
),
),
" "
),
["%0D%0A"],
),
["%0D%0A"],
[]
),
),
"\n"
)
);
@@ -162,7 +162,7 @@
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Wizardry and Steamworks - License: CC BY 2.0 //
// Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
list wasSetIntersect(list a, list b) {
if(llGetListLength(a) == 0) return [];
@@ -175,8 +175,6 @@
 
// configuration data
string configuration = "";
// callback URL
string URL = "";
// store message over state.
string data = "";
// banee
@@ -202,8 +200,8 @@
llResetScript();
}
changed(integer change) {
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
(change & CHANGED_OWNER)) {
llResetScript();
}
@@ -222,70 +220,48 @@
// We only care about notifications now.
if(id != "notification")
return;
 
// This script only processes group notifications.
if(wasKeyValueGet("type", message) != "group")
if(wasKeyValueGet("type", message) != "group" ||
(wasKeyValueGet("type", message) == "group" &&
wasURLUnescape(wasKeyValueGet("group", message)) !=
wasKeyValueGet("group", configuration)))
return;
 
// Get the sent message.
data = wasURLUnescape(
wasKeyValueGet(
"message",
"message",
message
)
);
 
// Check if this is an eggdrop command.
if(llGetSubString(data, 0, 0) !=
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) !=
if(llList2String(command, 0) !=
wasKeyValueGet("command", configuration) + "softunban")
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("[Softunban] Requesting URL...");
llRequestURL();
}
http_request(key id, string method, string body) {
if(method != URL_REQUEST_GRANTED) return;
URL = body;
// DEBUG
llOwnerSay("[Softunban] Got URL...");
// Get roles of caller.
state get_caller_roles;
}
on_rez(integer num) {
@@ -292,8 +268,8 @@
llResetScript();
}
changed(integer change) {
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
(change & CHANGED_OWNER)) {
llResetScript();
}
@@ -306,46 +282,52 @@
llOwnerSay("[Softunban] Searching for caller...");
llInstantMessage(
wasKeyValueGet(
"corrade",
"corrade",
configuration
),
),
wasKeyValueEncode(
[
"command", "getmemberroles",
"group", wasURLEscape(
wasKeyValueGet(
"group",
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
"password",
configuration
)
),
"firstname", firstname,
"lastname", lastname,
"callback", wasURLEscape(URL)
"callback", wasURLEscape(
wasKeyValueGet(
"URL",
configuration
)
)
]
)
);
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
if(wasKeyValueGet("command", body) != "getmemberroles" ||
wasKeyValueGet("success", body) != "True") {
link_message(integer sender, integer num, string body, key id) {
// Only process callbacks for the database command.
if(id != "callback" || wasKeyValueGet("command", body) != "getmemberroles")
return;
 
if(wasKeyValueGet("success", body) != "True") {
// DEBUG
llOwnerSay("[Softunban] Unable to get member roles: " +
llOwnerSay("[Softunban] Unable to get member roles: " +
wasURLUnescape(
wasKeyValueGet("error", body)
)
);
llReleaseURL(URL);
state listen_group;
}
 
// Dump the roles to a list.
list roles = wasCSVToList(
wasURLUnescape(
@@ -352,9 +334,9 @@
wasKeyValueGet("data", body)
)
);
 
if(llGetListLength(
wasSetIntersect(roles,
wasSetIntersect(roles,
wasCSVToList(
wasKeyValueGet(
"admin roles", configuration
@@ -363,26 +345,24 @@
)
) == 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) {
@@ -389,8 +369,8 @@
llResetScript();
}
changed(integer change) {
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
(change & CHANGED_OWNER)) {
llResetScript();
}
@@ -406,36 +386,43 @@
llOwnerSay("[Softunban] Searching for banee...");
llInstantMessage(
wasKeyValueGet(
"corrade",
"corrade",
configuration
),
),
wasKeyValueEncode(
[
"command", "getmemberroles",
"group", wasURLEscape(
wasKeyValueGet(
"group",
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
"password",
configuration
)
),
"firstname", firstname,
"lastname", lastname,
"callback", wasURLEscape(URL)
"callback", wasURLEscape(
wasKeyValueGet(
"URL",
configuration
)
)
]
)
);
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
if(wasKeyValueGet("command", body) != "getmemberroles" ||
wasKeyValueGet("success", body) != "True") {
link_message(integer sender, integer num, string body, key id) {
// Only process callbacks for the database command.
if(id != "callback" || wasKeyValueGet("command", body) != "getmemberroles")
return;
 
if(wasKeyValueGet("success", body) != "True") {
if(wasKeyValueGet("status", body) == "19862") {
// DEBUG
llOwnerSay("[Softunban] User not in group, but proceeding anyway...");
@@ -442,31 +429,28 @@
jump continue;
}
// DEBUG
llOwnerSay("[Softunban] Unable to get member roles: " +
llOwnerSay("[Softunban] 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;
}
 
@continue;
 
state unban;
}
timer() {
llReleaseURL(URL);
state listen_group;
}
on_rez(integer num) {
@@ -473,8 +457,8 @@
llResetScript();
}
changed(integer change) {
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
(change & CHANGED_OWNER)) {
llResetScript();
}
@@ -490,21 +474,21 @@
llOwnerSay("[Softunban] Unbanning...");
llInstantMessage(
wasKeyValueGet(
"corrade",
"corrade",
configuration
),
),
wasKeyValueEncode(
[
"command", "softban",
"group", wasURLEscape(
wasKeyValueGet(
"group",
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
"password",
configuration
)
),
@@ -516,19 +500,25 @@
]
)
),
"callback", wasURLEscape(URL)
"callback", wasURLEscape(
wasKeyValueGet(
"URL",
configuration
)
)
]
)
);
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
llReleaseURL(URL);
if(wasKeyValueGet("command", body) != "softban" ||
wasKeyValueGet("success", body) != "True") {
link_message(integer sender, integer num, string body, key id) {
// Only process callbacks for the database command.
if(id != "callback" || wasKeyValueGet("command", body) != "softban")
return;
 
if(wasKeyValueGet("success", body) != "True") {
// DEBUG
llOwnerSay("[Softunban] Unable to ban member: " +
llOwnerSay("[Softunban] Unable to ban member: " +
wasURLUnescape(
wasKeyValueGet("error", body)
)
@@ -535,13 +525,12 @@
);
state listen_group;
}
 
data = "They'll be bak!";
 
state tell;
}
timer() {
llReleaseURL(URL);
state listen_group;
}
on_rez(integer num) {
@@ -548,8 +537,8 @@
llResetScript();
}
changed(integer change) {
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
if((change & CHANGED_INVENTORY) ||
(change & CHANGED_REGION_START) ||
(change & CHANGED_OWNER)) {
llResetScript();
}
@@ -565,21 +554,21 @@
llOwnerSay("[Softunban] Sending to group.");
llInstantMessage(
wasKeyValueGet(
"corrade",
"corrade",
configuration
),
),
wasKeyValueEncode(
[
"command", "tell",
"group", wasURLEscape(
wasKeyValueGet(
"group",
"group",
configuration
)
),
"password", wasURLEscape(
wasKeyValueGet(
"password",
"password",
configuration
)
),
@@ -588,7 +577,7 @@
]
)
);
 
state listen_group;
}
}