Table of Contents

Shortnote

The script must be configured to match the secret from the bot as well as change a few lines to message the bot rather than the default settings.

Configuration

The following code segment occurrs twice in the script and has to be changed to your case:

        llInstantMessage("ea62501a-12a0-4f9c-a12f-134ae701df10", "auth C55OPS");
        llSleep(1.1-llGetRegionTimeDilation());
        llInstantMessage("ea62501a-12a0-4f9c-a12f-134ae701df10", "c " + URL);

The first line messages the bot the authentication code:

llInstantMessage("ea62501a-12a0-4f9c-a12f-134ae701df10", "auth C55OPS");

this must be changed so that ea62501a-12a0-4f9c-a12f-134ae701df10 is replaced with the UUID of the bot. then C55OPS must be changed to your bot's secret in its configuration file (see the bot configuration).

The third line:

llInstantMessage("ea62501a-12a0-4f9c-a12f-134ae701df10", "c " + URL);

sends the primitive's URL to the bot. The UUID ea62501a-12a0-4f9c-a12f-134ae701df10 has to be changed to the UUID of the bot.

This has to be repeated two times by searching the script below and replacing where these tokens occur.

Code

convey.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2012 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
string URL = "";
key oKey = NULL_KEY;
 
 
//////////////////////////////////////////////////////////
// Obtain an URL.
//////////////////////////////////////////////////////////
default {
    state_entry() {
        llSetText("Getting URL...", <1,1,0>, 1);
        llSetText("", <0,0,0>, 1);
        llRequestURL();
    }
    http_request(key id, string method, string body) {
        if(method != URL_REQUEST_GRANTED) llResetScript();
        URL = body;
        state setup;
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
//////////////////////////////////////////////////////////
// Handshake with the bot.
//////////////////////////////////////////////////////////
state setup {
    state_entry() {
        llSetText("Handshaking...", <1,1,0>, 1);
        llInstantMessage("ea62501a-12a0-4f9c-a12f-134ae701df10", "auth C55OPS");
        llSleep(1.1-llGetRegionTimeDilation());
        llInstantMessage("ea62501a-12a0-4f9c-a12f-134ae701df10", "c " + URL);
        // alarm 60s
        llSetTimerEvent(60);
    }
    http_request(key id, string method, string body) {
        if(method != "POST") return;
        list data = llParseString2List(body, ["->"], []);
        // Test to see whether we have a complete handshake.
        // Did we get an answer from convey?
        if(llList2String(data, 0) != "CONVEY") return;
        // Is it going to relay messages to our URL?
        if(llList2String(data, 1) != URL) llResetScript();
        // Be polite and answer the request.
        llHTTPResponse(id, 200, "OK");
        // Handshake completed at this point, switch to main.
        state main;
    }
    timer() {
        llResetScript();
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
//////////////////////////////////////////////////////////
// Process messages and periodically re-auth.
//////////////////////////////////////////////////////////
state main {
    state_entry() {
        llSetText("Processing Messages", <0,1,0>, 1);
        llSetTimerEvent(60);
    }
    http_request(key id, string method, string body) {
        ///////////////////////////////////
        // This block answers a re-auth.
        ///////////////////////////////////
        if(method != "POST") jump try_PUT;
        list data = llParseString2List(body, ["->"], []);
        // Test to see whether we have a complete handshake.
        // Did we get an answer from convey?
        if(llList2String(data, 0) != "CONVEY") return;
        // Is it going to relay messages to our URL?
        if(llList2String(data, 1) != URL) llResetScript();
        // Be polite and answer the request.
        llHTTPResponse(id, 200, "OK");
        return;
@try_PUT;
        ///////////////////////////////////
        // This block processes an instant
        // message sent to the bot.
        ///////////////////////////////////
        // Was it an instant message from the bot?
        if(method != "PUT") return;
        // Be courteous and answer Convey's message first.
        llHTTPResponse(id, 200, "OK");
 
        ///////////////EDIT////////////////
        // Now "body" contains the message.
        ///////////////////////////////////
        llSay(0, body);
        ///////////////////////////////////
 
    }
    timer() {
        llInstantMessage("ea62501a-12a0-4f9c-a12f-134ae701df10", "auth C55OPS");
        llSleep(1.1-llGetRegionTimeDilation());
        llInstantMessage("ea62501a-12a0-4f9c-a12f-134ae701df10", "c " + URL);
    }
    on_rez(integer num) {
        llResetScript();
    }
}

secondlife/scripted_agents/convey/primitive.txt ยท Last modified: 2022/11/24 07:45 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.