Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: inworld Linden Blogs headlines reader

Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
08-27-2006 20:44
CODE

//<-------------------------------------------------------------------------------------------------->//
//<----------------------------------------- HOT BLOGS v1.0 ----------------------------------------->//
//<------------------------------------ 2006 CFDT/ Osgeld Barmy ------------------------------------->//
//<-------------------------------------------------------------------------------------------------->//

// This script gets data off of my website, the url is pointed to a RSS reader thats been setup for LSL happy formatting, the RSS headlines are from the Offical Lindens Blogs @ http://blog.secondlife.com

// The way my RSS reader is setup you can only get the first 5 headlines, including url title
and a breif discription (or teaser text) and hits the LSL html limit of 2049 bytes quite easy, since the headline data is not hard set by either my website or the linden blog, a few long titles or ect could make the returing data larger than 2049 bytes, which will result in truncation of the last entry (altho its usually only by a few charaters)

// This script is setup to only refresh data after 5 min of inactivity .. and will not refresh the data untill it is requested by an agent (so im not constantly fetching data from the secondlife website)

// This script is public domain, and anyone who wishes to read data off my website is welcome to

// Options
string rss_feed = "http://www.cheesefactory.us/slrss/getrss.php";
string spacer = "||";
integer chat_chan = 1234567;

// Varibles
integer x; //counter
integer p; //counter
integer in_use; //switch
integer listencon; //switch
string home_menu; //data
list blog_data; //data
key placehold; //data

// Subroutines
get_feed(){llHTTPRequest(rss_feed,[HTTP_METHOD,"GET"],"");}

set_text(string text, vector color){llSetText(text,color,1);}

dialog(key id, string message,list buttons){llDialog(id,message,buttons,chat_chan);}

// Script
default
{
state_entry()
{
set_text("sending request",<1.0,0.0,0.0>);
llSetTimerEvent(10); // just incase of website timeout
get_feed();
}

http_response(key request_id, integer status, list metablog_data, string body)
{
llSetTimerEvent(0);
blog_data = llParseString2List(body,[spacer],[]);

if (llGetListLength(blog_data) != 15) // 5 headlines * 3 variables (default)
{
if (x < 5) // try upto 5 times, if list doesnt match 15 entrys (default)
{
set_text("invalid blog_data,trying again"+"("+(string)x+")",<1.0,0.0,0.0>);
++x;
get_feed();
}

else // feed error message, microsoft style (no usefull info)
{
set_text("please check your RSS feed format, URL, or script",<0.5,0.5,0.5>);
}
}

else
{
p = 1;
home_menu = "Please Choose\n";

for (x = 1; x < 15; x += 3)
{
home_menu += "("+(string)p +") "+llList2String(blog_data,x) + "\n\n";
++p;
}

set_text("Touch Here \n to check the latest in Linden blogs",<0.0,1.0,0.0>);
llResetTime();
state running;
}
}

timer()
{
set_text("Request timed out, trying again",<1.0,0.0,0.0>);
get_feed();
}
}

state running
{
state_entry()
{
listencon = llListen(chat_chan,"",NULL_KEY,"");

if (placehold != NULL_KEY)
{
llListenControl(listencon, 1);
dialog(placehold,home_menu,["3","4","5","1","2"]);
placehold = NULL_KEY;
}
}

touch_start(integer nd)
{
if (llGetTime() >= 300.0 && in_use != 1)
{
in_use = 1;
placehold = llDetectedKey(0);
state default;
}
else
{
if (in_use != 1) in_use = 1;

llListenControl(listencon, 1);
dialog(llDetectedKey(0),home_menu,["3","4","5","1","2"]);
}
}

listen(integer channel, string name, key id, string message)
{
llSetTimerEvent(120);

if (message == "Home")
{
dialog(id,home_menu,["3","4","5","1","2"]);
}

else if ((integer)message >= 1 && (integer)message <= 5)
{
p = ( ((integer)message * 3) - 1);

dialog(id,llList2String(blog_data,p),["Home","Read More "+message]);
}

else if (llGetSubString(message,0,8) == "Read More")
{
p = ( ((integer)llGetSubString(message,12,12) * 3) - 3);

llLoadURL(id,"this will minimise SL and load up your browser",llList2String(blog_data,p));
}
}

timer()
{
llListenControl(listencon,0);
in_use = 0;
llSetTimerEvent(0);
}
}


non screwed over copy
http://www.cheesefactory.us/slrss/hotblogs
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
09-05-2006 07:26
/15/17/133249/1.html
_____________________
i've got nothing. ;)