Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // support name.surname and fix bad key picking if user is not foudn or hidden
- string sUrl = "http://anonymouse.org/cgi-bin/anon-www.cgi/http://search.secondlife.com/client_search.php?s=people&session=00000000-0000-0000-0000-000000000000&mat=7&q=";
- string sSearchString = "http://world.secondlife.com/resident/";
- string sLineStart = "<h3 class=\"result_title\">";
- string sLineEnd = "</h3>";
- integer iKeyLength = 36;
- string sMessage = "Please say the name in chat!";
- string sMessageSearching = "Searching for: ";
- string sMessageResult = "Result: ";
- float fTime = 20;
- integer iListen;
- string AVname;
- string strReplace(string str, string search, string replace) {
- return llDumpList2String(llParseStringKeepNulls((str = "") + str, [search], []), replace);
- }
- default
- {
- touch_start(integer total_number)
- {
- llSetTimerEvent(fTime);
- iListen = llListen(PUBLIC_CHANNEL, "", llDetectedKey(0), "");
- llSay(PUBLIC_CHANNEL, sMessage);
- }
- timer()
- {
- llListenRemove(iListen);
- llSetTimerEvent(0);
- }
- listen(integer channel, string name, key id, string message)
- {
- message = llStringTrim(message,STRING_TRIM);
- message = strReplace(llToLower(message),".","");
- if(llToLower(llGetSubString(message,-8,-1)) == "resident")
- {
- message =llGetSubString(message,0,-9);
- }
- AVname = strReplace(llToLower(message)," ",".");
- llListenRemove(iListen);
- llSay(PUBLIC_CHANNEL, sMessageSearching + AVname);
- llSetTimerEvent(0);
- llHTTPRequest(sUrl + llEscapeURL(message), [HTTP_BODY_MAXLENGTH,16384], "");
- }
- http_response(key request_id, integer status, list metadata, string body)
- {
- string sResultKey = "";
- integer iLineStart = llSubStringIndex(body,sLineStart) + llStringLength(sLineStart);
- integer iLineEnd = llSubStringIndex(body,sLineEnd) - 1;
- string LineFound = llGetSubString(body,iLineStart,iLineEnd);
- llOwnerSay(LineFound);
- if (llSubStringIndex(LineFound, "(" + AVname + ")") > 1)
- {
- integer iResultPos = llSubStringIndex(LineFound, sSearchString);
- if (iResultPos != -1)
- {
- iResultPos = iResultPos + llStringLength(sSearchString);
- sResultKey = llGetSubString(LineFound, iResultPos, iResultPos + iKeyLength-1);
- }
- else
- sResultKey = NULL_KEY;
- }
- else
- sResultKey = NULL_KEY;
- llSay(PUBLIC_CHANNEL, sMessageResult + sResultKey);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement