Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- key notecardQueryId;
- string notecardName = "Bot List";
- integer notecardLine;
- list namesKeySet;
- string botName;
- integer totalNotcardLines;
- key totalNotecardQyID;
- key name_key_query;
- integer dListen_handle;
- integer dListen_channel;
- //list dataSetKeys;
- key botStatusQy;
- integer botOnline;
- integer botOffline;
- integer i;
- key user;
- // Convert Unix Time to SLT, identifying whether it is currently PST or PDT (i.e. Daylight Saving aware)
- // Omei Qunhua December 2013
- list weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
- string Unix2PST_PDT(integer insecs)
- {
- string str = Convert(insecs - (3600 * 8) ); // PST is 8 hours behind GMT
- if (llGetSubString(str, -3, -1) == "PDT") // if the result indicates Daylight Saving Time ...
- str = Convert(insecs - (3600 * 7) ); // ... Recompute at 1 hour later
- return str;
- }
- // This leap year test is correct for all years from 1901 to 2099 and hence is quite adequate for Unix Time computations
- integer LeapYear(integer year)
- {
- return !(year & 3);
- }
- integer DaysPerMonth(integer year, integer month)
- {
- if (month == 2) return 28 + LeapYear(year);
- return 30 + ( (month + (month > 7) ) & 1); // Odd months up to July, and even months after July, have 31 days
- }
- string Convert(integer insecs)
- {
- integer w; integer month; integer daysinyear;
- integer mins = insecs / 60;
- integer secs = insecs % 60;
- integer hours = mins / 60;
- mins = mins % 60;
- integer days = hours / 24;
- hours = hours % 24;
- integer DayOfWeek = (days + 4) % 7; // 0=Sun thru 6=Sat
- integer years = 1970 + 4 * (days / 1461);
- days = days % 1461; // number of days into a 4-year cycle
- @loop;
- daysinyear = 365 + LeapYear(years);
- if (days >= daysinyear)
- {
- days -= daysinyear;
- ++years;
- jump loop;
- }
- ++days;
- for (w = month = 0; days > w; )
- {
- days -= w;
- w = DaysPerMonth(years, ++month);
- }
- string str = ((string) years + "-" + llGetSubString ("0" + (string) month, -2, -1) + "-" + llGetSubString ("0" + (string) days, -2, -1) + " " +
- llGetSubString ("0" + (string) hours, -2, -1) + ":" + llGetSubString ("0" + (string) mins, -2, -1) );
- integer LastSunday = days - DayOfWeek;
- string PST_PDT = " PST"; // start by assuming Pacific Standard Time
- // Up to 2006, PDT is from the first Sunday in April to the last Sunday in October
- // After 2006, PDT is from the 2nd Sunday in March to the first Sunday in November
- if (years > 2006 && month == 3 && LastSunday > 7) PST_PDT = " PDT";
- if (month > 3) PST_PDT = " PDT";
- if (month > 10) PST_PDT = " PST";
- if (years < 2007 && month == 10 && LastSunday > 24) PST_PDT = " PST";
- return (llList2String(weekdays, DayOfWeek) + " " + str + PST_PDT);
- }
- listLinksetData()
- {
- integer x;
- list keyEntry;
- string botStatus;
- for(x = 0; x < llLinksetDataCountKeys(); x++)
- {
- keyEntry = llCSV2List((string) llLinksetDataRead((string) llLinksetDataListKeys(x, 1)));
- if(llList2Integer(keyEntry, 1) == 0)
- botStatus = " is Offline.";
- else
- {
- botStatus = " was banned on " + Unix2PST_PDT(llList2Integer(keyEntry, 1));
- }
- llRegionSayTo(user, 0, llList2String(keyEntry, 0) + botStatus);
- }
- }
- listLinksetBanned()
- {
- integer x;
- list keyEntry;
- string botStatus;
- for(x = 0; x < llLinksetDataCountKeys(); x++)
- {
- keyEntry = llCSV2List((string) llLinksetDataRead((string) llLinksetDataListKeys(x, 1)));
- if(llList2Integer(keyEntry, 1) > 0)
- {
- botStatus = " was banned on " + Unix2PST_PDT(llList2Integer(keyEntry, 1));
- llRegionSayTo(user, 0, llList2String(keyEntry, 0) + botStatus);
- }
- }
- }
- list linkSetSearch(string rexgep, string needle)
- {
- list results;
- list search;
- integer x;
- if(rexgep == "")
- rexgep = ".*";
- search = llLinksetDataFindKeys(rexgep, 0, -1);
- for(x = -llGetListLength(search); x < 0; ++x)
- {
- if(!llSubStringIndex(llLinksetDataRead(llList2Key(search, x)), needle))
- results += llList2String(search, x);
- }
- return results;
- }
- default
- {
- state_entry()
- {
- llSetText("", <0,0,0>, 0);
- state bot_status;
- //llLinksetDataWrite("testmode", "1");
- //llLinksetDataDelete("testmode");
- if(llGetLandOwnerAt(llGetPos()) != llGetOwner() && llLinksetDataRead("testmode") == "")
- {
- llOwnerSay("Device neends to be Deeded to group to operate correctly.");
- llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES);
- return;
- }
- if(llLinksetDataRead("testmode"))
- {
- llSay(999, "STOP");
- llSetColor(<0.000, 0.455, 0.851>, ALL_SIDES);
- }
- else
- {
- llSay(888, "STOP");
- llSetColor(<0.694, 0.051, 0.788>, ALL_SIDES);
- }
- dListen_channel = 0x80000000 | (integer)llFrand(65536) | ((integer)llFrand(65536) << 16);
- totalNotecardQyID = llGetNumberOfNotecardLines(notecardName);
- }
- touch_start(integer start)
- {
- llResetTime();
- }
- touch_end(integer end)
- {
- if(llGetTime() > 2)
- {
- if(llLinksetDataRead("testmode"))
- llLinksetDataDelete("testmode");
- else
- llLinksetDataWrite("testmode", "true");
- llResetScript();
- }
- }
- dataserver(key requested, string data)
- {
- if(requested == totalNotecardQyID)
- {
- totalNotcardLines = (integer) data;
- notecardQueryId = llGetNotecardLine(notecardName, notecardLine);
- }
- if(requested == name_key_query)
- {
- if(llLinksetDataRead(data) == "")
- {
- llLinksetDataWrite(data, botName + ",0");
- llOwnerSay("Adding "+ botName +" ("+ (string) data + ")");
- }
- else
- {
- llSay(0, "Skipping " + botName + " ("+(string) data + ")");
- }
- llSleep(0.3);
- notecardQueryId = llGetNotecardLine(notecardName, ++notecardLine);
- }
- if(notecardQueryId == requested)
- {
- if(data == EOF)
- {
- llSay(0, "Cardlines Read: " + (string) notecardLine);
- llSay(0, "Keys in LinksetData: " + (string) llLinksetDataCountKeys());
- state bot_status;
- }
- else
- {
- botName = llStringTrim(data, STRING_TRIM);
- name_key_query = llRequestUserKey(botName);
- }
- }
- llSetText((string) notecardLine +"/"+ (string) totalNotcardLines+ "\n" +
- (string) llLinksetDataAvailable() + "\n",
- <1,0,1>, 1.0);
- }
- listen(integer chan, string name, key id, string msg)
- {
- if(chan == dListen_channel)
- {
- llSetTimerEvent(0);
- llListenRemove(dListen_handle);
- if(msg == "Reload")
- {
- llLinksetDataReset();
- totalNotecardQyID = llGetNumberOfNotecardLines(notecardName);
- notecardLine = 0;
- }
- if(msg == "Diff")
- {
- state diff;
- }
- }
- }
- timer()
- {
- llListenRemove(dListen_handle);
- llSetTimerEvent(0);
- }
- changed(integer change)
- {
- if(change & CHANGED_INVENTORY)
- {
- llSay(0, "Inventory Changed, resetting.");
- llResetScript();
- } else if(change & CHANGED_OWNER)
- {
- llResetScript();
- }
- }
- }
- state diff
- {
- state_entry()
- {
- llSay(0, "state entry");
- }
- }
- state bot_status
- {
- state_entry()
- {
- llSay(0, (string) llGetFreeMemory());
- i = 0;
- if(llLinksetDataRead("testmode"))
- {
- llSay(999, "STOP");
- llSetColor(<0.000, 0.455, 0.851>, ALL_SIDES);
- }
- else
- {
- llSay(888, "STOP");
- llSetColor(<1.000, 0.255, 0.212>, ALL_SIDES);
- }
- //dataSetKeys = llLinksetDataListKeys(0, -1);
- dListen_channel = 0x80000000 | (integer)llFrand(65536) | ((integer)llFrand(65536) << 16);
- llListen(dListen_channel, "", "", "");
- botStatusQy = llRequestAgentData(llList2Key(llLinksetDataListKeys(i, 1),0), DATA_ONLINE);
- }
- touch_end(integer num)
- {
- user = llDetectedKey(0);
- llDialog(user, "Main Menu", ["LinkSet"], dListen_channel);
- }
- listen(integer chan, string name, key id, string msg)
- {
- if(chan == dListen_channel)
- {
- if(msg == "Reload")
- {
- state default;
- }
- if(msg == "Diff")
- {
- state diff;
- }
- if(msg == "LinkSet")
- llDialog(user, "Linkset Data", ["List All", "List Banned", "Clear"], dListen_channel);
- if(msg == "List All")
- listLinksetData();
- if(msg == "List Banned")
- listLinksetBanned();
- if(msg == "Clear")
- state listLinksetClear;
- }
- }
- changed(integer change)
- {
- if(change & CHANGED_INVENTORY)
- {
- llSay(0, "Inventory Changed, resetting.");
- llResetScript();
- } else if(change & CHANGED_OWNER)
- {
- llResetScript();
- }
- }
- timer()
- {
- botOnline = 0;
- botOffline = 0;
- i = 0;
- if(llLinksetDataRead("testmode"))
- {
- llSay(999, "STOP");
- llSetColor(<0.000, 0.455, 0.851>, ALL_SIDES);
- }
- else
- {
- llSay(888, "STOP");
- llSetColor(<1.000, 0.255, 0.212>, ALL_SIDES);
- }
- //dataSetKeys = llLinksetDataListKeys(0, -1);
- botStatusQy = llRequestAgentData(llList2Key(llLinksetDataListKeys(i, 1), 0), DATA_ONLINE);
- }
- dataserver(key queryid, string data)
- {
- list keyBotStat;
- if(queryid == botStatusQy)
- {
- llSetTimerEvent(0);
- keyBotStat = llCSV2List(llLinksetDataRead(llList2Key(llLinksetDataListKeys(i, 1), 0)));
- if(data == (string) TRUE)
- {
- if(llList2Integer(keyBotStat, 1) == 0)
- {
- llLinksetDataWrite(llList2Key(llLinksetDataListKeys(i, 1), 0), llList2String(keyBotStat, 0) +
- "," + (string) llGetUnixTime());
- llOwnerSay((string) llLinksetDataListKeys(i, 1) +
- " Banning :" + llList2String(keyBotStat, 0));
- llAddToLandBanList(llList2Key(llLinksetDataListKeys(i, 1), 0), 24);
- }else if(llList2Integer(keyBotStat, 1) > 0)
- {
- llLinksetDataWrite(llList2Key(llLinksetDataListKeys(i, 1), 0), llList2String(keyBotStat, 0) +
- "," + (string) llGetUnixTime());
- llRemoveFromLandBanList(llList2Key(llLinksetDataListKeys(i, 1), 0));
- llSleep(2.0);
- llAddToLandBanList(llList2Key(llLinksetDataListKeys(i, 1), 0), 24);
- }
- ++botOnline;
- } else if(data == (string) FALSE)
- {
- if(llList2Integer(keyBotStat,1) > 0)
- {
- llLinksetDataWrite(llList2Key(llLinksetDataListKeys(i, 1), 0),
- llList2String(keyBotStat, 0) + ",0");
- llRemoveFromLandBanList(llList2Key(llLinksetDataListKeys(i, 1), 0));
- }
- ++botOffline;
- }
- }
- //llSay(0, llLinksetDataRead(llList2Key(dataSetKeys, i)));
- if(i < llLinksetDataCountKeys())
- {
- botStatusQy = llRequestAgentData(llList2Key(llLinksetDataListKeys(++i, 1), 0), DATA_ONLINE);
- } else
- {
- if(llLinksetDataRead("testmode"))
- {
- llSetColor(<0.000, 0.455, 0.851>, ALL_SIDES);
- llSay(999, "START");
- }
- else
- {
- llSay(888, "START");
- llSetColor(<0.004, 1.000, 0.439>, ALL_SIDES);
- }
- llSetTimerEvent(600);
- }
- llSetText("Known Bots: " + (string) llLinksetDataCountKeys() + "\n" +
- "Bots Online : " + (string) botOnline + "\n" +
- "Bots Offline : " + (string) botOffline + "\n" +
- (string) llLinksetDataAvailable() + "\n" +
- (string) llGetFreeMemory(),
- <0,1,1>, 1);
- }
- }
- state listLinksetClear
- {
- state_entry()
- {
- notecardLine = 0;
- dListen_channel = 0x80000000 | (integer)llFrand(65536) | ((integer)llFrand(65536) << 16);
- llListen(dListen_channel, "", "", "");
- llSay(0, "Clear");
- llResetTime();
- notecardQueryId = llGetNotecardLine(notecardName, notecardLine);
- //llSay(0, llDumpList2String(linkSetSearch("", "bonniebelle85"), "\n"));
- }
- dataserver(key requested, string data)
- {
- if(notecardQueryId == requested)
- {
- if(data == EOF)
- {
- llSay(0, "run time " + (string) llGetTime() + " Cardlines Read: " + (string) notecardLine);
- }
- else
- {
- ;
- botName = llStringTrim(data, STRING_TRIM);
- llSay(0, (string) notecardLine +") " + llList2String(linkSetSearch("", botName), 0));
- notecardQueryId = llGetNotecardLine(notecardName, ++notecardLine);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement