Add 1.21 code, with new update checker: 1.22
This commit is contained in:
parent
0c06df5f9c
commit
5d6d24497f
2 changed files with 428 additions and 0 deletions
66
Configuration.txt
Normal file
66
Configuration.txt
Normal file
|
@ -0,0 +1,66 @@
|
|||
# Each admin must be on their own line
|
||||
# To add comments, use the hash sign
|
||||
ADMIN = tashia redrose
|
||||
ADMIN = allerbmu
|
||||
#
|
||||
#
|
||||
# You specify the default mode with this parameter
|
||||
DEFAULTMODE = IC
|
||||
#
|
||||
#
|
||||
# You define modes using the MODE command
|
||||
MODE = IC
|
||||
MODE = OOC
|
||||
MODE = KAJURALIA
|
||||
MODE = RAID
|
||||
MODE = TEST
|
||||
#
|
||||
#
|
||||
# The modes all must have 3 options, the notification type, the actual message, and which mode this is being sent for. Examples are listed below
|
||||
#
|
||||
# none = no notifications
|
||||
# im = InstantMessage notifications
|
||||
# dialog = Dialog notifications
|
||||
# both = IM & Dialog
|
||||
#
|
||||
#
|
||||
# Format: <Mode> = <notification type> = <Message>
|
||||
#
|
||||
IC = none = IC, not being raided
|
||||
OOC = both = Sim is currently OOC
|
||||
KAJURALIA = dialog = Event : Kajuralia is in progress!
|
||||
RAID = im = A raid is in progress
|
||||
TEST = both = This is a test notification
|
||||
#
|
||||
#
|
||||
#
|
||||
# DEVELOPER MODE TOGGLE - THIS WILL SEND NOTIFICATIONS ONLY TO THOSE ON THE ADMIN LIST
|
||||
DEVELOPER
|
||||
#
|
||||
#
|
||||
# What should happen for those already on sim?
|
||||
# zcs = Send a notification over the zCS Message Channel
|
||||
# normal = Send the message the same way they would get it per the mode rules
|
||||
# none = Don't send a change notification to those already on sim
|
||||
CHANGE = zcs
|
||||
#
|
||||
#
|
||||
#
|
||||
# EXEMPT AVATARS
|
||||
EXEMPT = allerbmu resident
|
||||
#
|
||||
#
|
||||
#
|
||||
# Want to only scan the parcel? (For non-sim owners)
|
||||
# Put PARCEL on its own line, or uncomment the line below.
|
||||
# Do NOT use region wide on a sim you do not own all parcels on as you could then be subject to abuse reports and ZNI Creations will not be held responsible, you have been warned.
|
||||
#
|
||||
#PARCEL
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Want to be able to hook another object up to the status?
|
||||
# Then use the below method to set an API Channel. (Please do not use the default...)
|
||||
#API = 1
|
362
Notifier.lsl
Normal file
362
Notifier.lsl
Normal file
|
@ -0,0 +1,362 @@
|
|||
#include "ZNICommon.lsl"
|
||||
|
||||
|
||||
list g_lAdmins;
|
||||
string g_sDefault;
|
||||
list g_lModes;
|
||||
list g_lNotifModes;
|
||||
string g_sCurrentMode;
|
||||
integer g_iLstn=-1;
|
||||
integer g_iChn;
|
||||
integer g_iDEV=FALSE;
|
||||
list g_lNew;
|
||||
list g_lOld;
|
||||
integer updater_channel = 15418070;
|
||||
string g_sProduct;
|
||||
key g_kUpdater;
|
||||
integer g_iScanType = AGENT_LIST_REGION;
|
||||
|
||||
integer g_iChangeNotification = 0;
|
||||
list g_lExempt;
|
||||
|
||||
integer ZCS_MESSAGE = -291451;
|
||||
SendZCS(string m){
|
||||
string obj = llGetObjectName();
|
||||
llSetObjectName("zCS");
|
||||
llRegionSay(ZCS_MESSAGE, "mod;;"+m+";;312eb154-0759-4c1e-8013-fef05c7a8e55");
|
||||
llSetObjectName(obj);
|
||||
}
|
||||
|
||||
integer g_iAPI = 0;
|
||||
integer g_iAPIChan = 0x9; // cant be 0
|
||||
|
||||
|
||||
SetMode(string mode)
|
||||
{
|
||||
// Set the mode from g_lModes, perform any notification action!
|
||||
string oldMode = g_sCurrentMode;
|
||||
g_sCurrentMode=mode;
|
||||
llSetObjectDesc(mode);
|
||||
if(g_iAPI)
|
||||
{
|
||||
llRegionSay(g_iAPIChan, llList2Json(JSON_OBJECT, ["op", "mode", "newmode", mode]));
|
||||
}
|
||||
|
||||
if(!g_iDEV)
|
||||
llSetText("Current mode: "+mode,<1,1,1>,1);
|
||||
else
|
||||
llSetText("Current mode: "+mode+"\nFree Memory: "+(string)llGetFreeMemory()+"\n \n* Debug Mode *", <1,0,0>,1);
|
||||
integer index = llListFindList(g_lNotifModes,[mode]);
|
||||
if(index==-1)
|
||||
{
|
||||
llRegionSayTo(llGetOwner(),0,"ERROR: Mode '"+mode+"' not found in the notification config");
|
||||
g_sCurrentMode=g_sDefault;
|
||||
llSetObjectDesc(g_sCurrentMode);
|
||||
}else{
|
||||
if(g_iDEV){
|
||||
integer iMode = llList2Integer(g_lNotifModes,index+1);
|
||||
string msg = llList2String(g_lNotifModes,index+2);
|
||||
|
||||
if(iMode&1)llRegionSayTo(llGetOwner(), 0,msg);
|
||||
if(iMode&2)llDialog(llGetOwner(), msg, ["-dismiss-"], -999999);
|
||||
}else {
|
||||
NotifyAdmins("[MODE CHANGE] New Status: "+mode);
|
||||
if(g_iChangeNotification == 1){
|
||||
// OK //
|
||||
string Msg = "";
|
||||
integer iM = llList2Integer(g_lNotifModes,index+1);
|
||||
if(iM)Msg=llList2String(g_lNotifModes,index+2);
|
||||
|
||||
SendZCS("/me # [Sim Status] ["+oldMode+"]->["+mode+"] "+Msg);
|
||||
} else if(g_iChangeNotification ==2){
|
||||
g_lOld=[1];
|
||||
}
|
||||
}
|
||||
|
||||
if(llGetInventoryType(mode)==INVENTORY_TEXTURE)
|
||||
{
|
||||
llSetTexture(mode, ALL_SIDES);
|
||||
}
|
||||
}
|
||||
}
|
||||
NotifyAdmins(string m)
|
||||
{
|
||||
integer i=0;
|
||||
integer end = llGetListLength(g_lAdmins);
|
||||
for(i=0;i<end;i++)
|
||||
{
|
||||
llRegionSayTo(llList2Key(g_lAdmins,i),0,m);
|
||||
}
|
||||
}
|
||||
NotifyAdminsWithMask(integer mask,string m)
|
||||
{
|
||||
integer i=0;
|
||||
integer end = llGetListLength(g_lAdmins);
|
||||
for(i=0;i<end;i++)
|
||||
{
|
||||
if(mask&1)
|
||||
llRegionSayTo(llList2Key(g_lAdmins,i),0,m);
|
||||
if(mask&2)
|
||||
llDialog(llList2Key(g_lAdmins,i), m, ["-dismiss-"],-999999);
|
||||
}
|
||||
}
|
||||
|
||||
ProcessNewAvatars()
|
||||
{
|
||||
integer modeIndex = llListFindList(g_lNotifModes,[g_sCurrentMode]);
|
||||
if(modeIndex==-1)return;
|
||||
else{
|
||||
integer notifier = llList2Integer(g_lNotifModes,modeIndex+1);
|
||||
// Notifier is the bitmask
|
||||
string message = llList2String(g_lNotifModes, modeIndex+2);
|
||||
|
||||
integer i=0;
|
||||
integer end = llGetListLength(g_lNew);
|
||||
for(i=0;i<end;i++)
|
||||
{
|
||||
// We do not care about old avatars leaving the region
|
||||
if(llListFindList(g_lOld, [llList2Key(g_lNew,i)])==-1)
|
||||
{
|
||||
// This is a new avatar, perform the notifier
|
||||
if(g_iDEV){
|
||||
NotifyAdminsWithMask(notifier,"Sim Status ("+g_sCurrentMode+")\n \n"+message);
|
||||
}else{
|
||||
if(llListFindList(g_lExempt, [llList2Key(g_lNew,i)]) == -1){
|
||||
if(notifier&1)llRegionSayTo(llList2Key(g_lNew,i),0,"Sim Status ("+g_sCurrentMode+")\n \n"+message);
|
||||
if(notifier&2)llDialog(llList2Key(g_lNew,i),"Sim Status ("+g_sCurrentMode+")\n \n"+message,["-dismiss-"],-999999);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_lOld=g_lNew;
|
||||
}
|
||||
}
|
||||
// ---------------
|
||||
// NEW CODE FOR UPDATE DELIVERY BEGINS HERE
|
||||
// ---------------
|
||||
|
||||
Send(string Req){
|
||||
g_lReqs += [Req];
|
||||
Sends();
|
||||
}
|
||||
Sends(){
|
||||
if(g_kCurrentReq == NULL_KEY){
|
||||
DoNextRequest();
|
||||
}
|
||||
//g_lReqs += [llHTTPRequest(URL + llList2String(lTmp,0), [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], llDumpList2String(llList2List(lTmp,1,-1), "?"))];
|
||||
}
|
||||
key g_kCurrentReq = NULL_KEY;
|
||||
DoNextRequest(){
|
||||
if(llGetListLength(g_lReqs)==0)return;
|
||||
list lTmp = llParseString2List(llList2String(g_lReqs,0),["?"],[]);
|
||||
if(g_iDEV)llSay(0, "SENDING REQUEST: "+API_SERVER+llList2String(g_lReqs,0));
|
||||
g_kCurrentReq = llHTTPRequest(API_SERVER + llList2String(lTmp,0), [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], llDumpList2String(llList2List(lTmp,1,-1),"?"));
|
||||
}
|
||||
|
||||
list g_lReqs;
|
||||
integer initial_start=1;
|
||||
|
||||
|
||||
checkUpdate()
|
||||
{
|
||||
llSay(0, "Checking for updates is not possible in the open sourced build. Purchase from Aria's Creations to get this functionality");
|
||||
}
|
||||
requestProductServer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
default
|
||||
{
|
||||
state_entry()
|
||||
{
|
||||
VERSION = "1.22";
|
||||
UpdateDSRequest(NULL, llGetNumberOfNotecardLines("Configuration"), "nread");
|
||||
llSetTimerEvent(10);
|
||||
llListen(updater_channel, "", "", "");
|
||||
g_sCurrentMode = llGetObjectDesc();
|
||||
}
|
||||
on_rez(integer t)
|
||||
{
|
||||
llResetScript();
|
||||
}
|
||||
timer()
|
||||
{
|
||||
g_lNew = llGetAgentList(g_iScanType, []);
|
||||
if(g_lOld==[])g_lOld=g_lNew;
|
||||
ProcessNewAvatars();
|
||||
}
|
||||
dataserver(key k, string d)
|
||||
{
|
||||
if(HasDSRequest(k)!=-1)
|
||||
{
|
||||
string meta = GetDSMeta(k);
|
||||
list lTmp = llParseString2List(meta,[":"],[]);
|
||||
if(llList2String(lTmp,0)=="nread")
|
||||
{
|
||||
UpdateDSRequest(k, llGetNotecardLine("Configuration",0), "read:0:"+d);
|
||||
}else if(llList2String(lTmp,0) == "read")
|
||||
{
|
||||
if(d==EOF){
|
||||
DeleteDSReq(k);
|
||||
llSetText("Config read: 100%", <1,1,1>,1);
|
||||
llSleep(5);
|
||||
SetMode(g_sCurrentMode);
|
||||
} else {
|
||||
integer line = llList2Integer(lTmp,1);
|
||||
line++;
|
||||
integer total = llList2Integer(lTmp,2);
|
||||
|
||||
integer percent = line*100/total;
|
||||
|
||||
list lTmp2 = llParseString2List(d,[" = ", "="],[]);
|
||||
if(llGetSubString(d,0,0)=="#")jump over;
|
||||
if(llList2String(lTmp2,0) == "ADMIN")
|
||||
{
|
||||
UpdateDSRequest(NULL, llRequestUserKey(llList2String(lTmp2,1)), "get_admin");
|
||||
} else if(llList2String(lTmp2,0) == "DEFAULTMODE")
|
||||
{
|
||||
g_sDefault = llList2String(lTmp2,1);
|
||||
} else if(llList2String(lTmp2,0) == "MODE")
|
||||
{
|
||||
g_lModes += [llList2String(lTmp2,1)];
|
||||
} else if(llList2String(lTmp2,0)=="DEVELOPER")
|
||||
{
|
||||
g_iDEV=1;
|
||||
} else if(llListFindList(g_lModes, [llList2String(lTmp2,0)])!=-1)
|
||||
{
|
||||
integer iFinal;
|
||||
string sLowerMode = llList2String(lTmp2,1);
|
||||
sLowerMode = llToLower(sLowerMode);
|
||||
if(sLowerMode == "im")iFinal = 1;
|
||||
if(sLowerMode=="dialog")iFinal=2;
|
||||
if(sLowerMode == "both")iFinal=1|2;
|
||||
g_lNotifModes += [llList2String(lTmp2,0), iFinal, llList2String(lTmp2,2)];
|
||||
}else if(llList2String(lTmp2,0) == "CHANGE")
|
||||
{
|
||||
switch(llToLower(llList2String(lTmp2,1))){
|
||||
case "zcs":{
|
||||
g_iChangeNotification=1;
|
||||
break;
|
||||
}
|
||||
case "normal":{
|
||||
g_iChangeNotification=2;
|
||||
break;
|
||||
}
|
||||
case "none":{
|
||||
g_iChangeNotification=0;
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
g_iChangeNotification=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if(llList2String(lTmp2,0) == "EXEMPT")
|
||||
{
|
||||
UpdateDSRequest(NULL, llRequestUserKey(llList2String(lTmp2,1)), "get_exempt");
|
||||
} else if(llList2String(lTmp2,0) == "PARCEL"){
|
||||
g_iScanType = AGENT_LIST_PARCEL;
|
||||
} else if(llList2String(lTmp2,0) == "API")
|
||||
{
|
||||
g_iAPI=TRUE;
|
||||
g_iAPIChan = (integer)llList2String(lTmp2,1);
|
||||
}
|
||||
|
||||
@over;
|
||||
llSetText("Read Config: "+(string)percent+"%", <1,1,1>,1);
|
||||
UpdateDSRequest(k, llGetNotecardLine("Configuration",line),"read:"+(string)line+":"+(string)total);
|
||||
}
|
||||
} else if(llList2String(lTmp,0) == "get_admin")
|
||||
{
|
||||
DeleteDSReq(k);
|
||||
g_lAdmins += [(key)d];
|
||||
}else if(llList2String(lTmp,0) == "get_exempt"){
|
||||
DeleteDSReq(k);
|
||||
g_lExempt += [(key)d];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
touch_start(integer t)
|
||||
{
|
||||
if(llListFindList(g_lAdmins,[llDetectedKey(0)])==-1)return;
|
||||
if(g_iLstn !=-1)
|
||||
{
|
||||
llListenRemove(g_iLstn);
|
||||
}
|
||||
g_iChn = llRound(llFrand(8574833));
|
||||
g_iLstn = llListen(g_iChn, "", llDetectedKey(0), "");
|
||||
llDialog(llDetectedKey(0), "What mode do you want to set?\n\nCurrent mode: "+g_sCurrentMode, g_lModes+["-exit-"], g_iChn);
|
||||
}
|
||||
|
||||
changed(integer c)
|
||||
{
|
||||
if(c&CHANGED_REGION_START|CHANGED_INVENTORY|CHANGED_ALLOWED_DROP)
|
||||
{
|
||||
llResetScript();
|
||||
}
|
||||
}
|
||||
|
||||
http_response(key r, integer s,list m,string b)
|
||||
{
|
||||
if(HasDSRequest(r)!=-1)
|
||||
{
|
||||
DeleteDSReq(r);
|
||||
|
||||
list tmp = llParseString2List(b,[";;",";"],[]);
|
||||
if(llList2String(tmp,0)=="Modify_Product")
|
||||
{
|
||||
g_sProduct = llList2String(tmp,1);
|
||||
string ver = llList2String(tmp,2);
|
||||
if(ver==VERSION)
|
||||
{
|
||||
llWhisper(0, "No update available");
|
||||
llRegionSayTo(g_kUpdater,updater_channel,"no_update");
|
||||
}else{
|
||||
llWhisper(0, "Requesting delivery of update");
|
||||
llRegionSayTo(g_kUpdater,updater_channel,(string)g_kUpdater);
|
||||
requestProductServer();
|
||||
}
|
||||
} else if(llList2String(tmp,0)=="Get_Server_URL"){
|
||||
llHTTPRequest(llList2String(tmp,2), [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], llList2Json(JSON_OBJECT, ["product", g_sProduct, "owner", llGetOwner()]));
|
||||
llSleep(5);
|
||||
llInstantMessage(llGetOwner(), "Alert: Old status notifier script removed. Insert the new one upon delivery");
|
||||
llSetText("DEACTIVATED\nSim Status Notifier\n \nInsert updated script", <1,0,0>,1);
|
||||
llRemoveInventory(llGetScriptName());
|
||||
}
|
||||
|
||||
DoNextRequest();
|
||||
}
|
||||
}
|
||||
|
||||
listen(integer c,string n,key i,string m)
|
||||
{
|
||||
if(m=="-exit-")
|
||||
{
|
||||
llListenRemove(g_iLstn);
|
||||
g_iLstn=-1;
|
||||
return;
|
||||
} else if(m == "chk.update")
|
||||
{
|
||||
checkUpdate();
|
||||
}
|
||||
llDialog(i, "What mode do you want to set?\n\nCurrent mode: "+m, g_lModes+["-exit-"], c);
|
||||
SetMode(m);
|
||||
}
|
||||
|
||||
link_message(integer s,integer n,string m,key i)
|
||||
{
|
||||
if(n == 0x004f)
|
||||
{
|
||||
API_SERVER = DecipherService(m,"api") + "/zni";
|
||||
if(!initial_start)
|
||||
{
|
||||
return;
|
||||
}
|
||||
initial_start=0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue