corrade-lsl-templates

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 41  →  ?path2? @ 42
/source/eggdrop/softban.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 bans group members using fuzzy name matching.
@@ -12,7 +12,7 @@
string wasKeyValueGet(string k, string data) {
if(llStringLength(data) == 0) return "";
if(llStringLength(k) == 0) return "";
list a = llParseStringKeepNulls(data, ["&", "="], []);
list a = llParseString2List(data, ["&", "="], []);
integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]);
if(i != -1) return llList2String(a, 2*i+1);
return "";
@@ -19,7 +19,7 @@
}
///////////////////////////////////////////////////////////////////////////
// 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 = [];
@@ -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) {
@@ -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
@@ -225,7 +223,10 @@
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.
@@ -261,32 +262,7 @@
// 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("[Softban] Requesting URL...");
llRequestURL();
}
http_request(key id, string method, string body) {
if(method != URL_REQUEST_GRANTED) return;
URL = body;
// DEBUG
llOwnerSay("[Softban] Got URL...");
// Get roles of callers.
state get_caller_roles;
}
on_rez(integer num) {
@@ -327,16 +303,23 @@
),
"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("[Softban] Unable to get member roles: " +
wasURLUnescape(
@@ -343,7 +326,6 @@
wasKeyValueGet("error", body)
)
);
llReleaseURL(URL);
state listen_group;
}
@@ -364,7 +346,6 @@
)
) == 0) {
data = "You ain't got the cojones!";
llReleaseURL(URL);
state tell;
}
@@ -390,7 +371,6 @@
state get_banee_roles;
}
timer() {
llReleaseURL(URL);
state listen_group;
}
on_rez(integer num) {
@@ -434,16 +414,23 @@
),
"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("[Softban] User not in group, but proceeding anyway...");
@@ -455,7 +442,6 @@
wasKeyValueGet("error", body)
)
);
llReleaseURL(URL);
state listen_group;
}
@@ -466,7 +452,6 @@
if(result != "" && llListFindList(wasCSVToList(result), (list)"Owners") != -1) {
data = "Ejectee is an owner. I'm not gunna open the pod bay doors.";
llReleaseURL(URL);
state tell;
}
@@ -473,7 +458,6 @@
state ban;
}
timer() {
llReleaseURL(URL);
state listen_group;
}
on_rez(integer num) {
@@ -530,15 +514,22 @@
]
)
),
"callback", wasURLEscape(URL)
"callback", wasURLEscape(
wasKeyValueGet(
"URL",
configuration
)
)
]
)
);
llSetTimerEvent(60);
}
http_request(key id, string method, string body) {
llHTTPResponse(id, 200, "OK");
llReleaseURL(URL);
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("command", body) != "softban" ||
wasKeyValueGet("success", body) != "True") {
// DEBUG
@@ -555,7 +546,6 @@
state tell;
}
timer() {
llReleaseURL(URL);
state listen_group;
}
on_rez(integer num) {