In-world automation

Free OneBot LSL scripts

Copy or download ready-made scripts that call your hosted bot over the HTTP API. No L$ payment endpoints—status, chat, groups, and inventory only.

Setup (every script)

  1. Create an API token on your bot's API tab in the customer portal (include the scopes listed on each card).
  2. Add a notecard named OneBot config to the object with at least:
bot_id=12345
token=obt_example_replace_in_portal
api_base=https://getonebot.com
// Optional per-script keys: group, item, channel, greet_message, cooldown …
  • Scripts send Authorization: Bearer … and X-SecondLife-Owner-Key (owner UUID), matching the API docs.
  • Set the object no modify in-world so visitors cannot read the notecard token.
  • Never share your real token—use the portal to rotate if exposed.

Touch Group Joiner

Touch to send a group invite through your bot. Confirms in local chat and throttles repeat invites per avatar.

Scopes: Groups

// OneBot — Touch Group Joiner. Requires notecard "OneBot config" (bot_id, token, group).
// API token scopes: Groups. Generate at your bot's API tab (portal).

string NOTECARD = "OneBot config";
string apiBase = "https://getonebot.com";
integer botId;
string apiToken = "";
string groupUuid = "";
integer cooldownSec = 300;

integer configLine;
key configQuery;
integer configReady;

list cooldownKeys;
list cooldownUntil;

list apiHeaders(string method)
{
    list h = [
        HTTP_METHOD, method,
        HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + apiToken,
        HTTP_CUSTOM_HEADER, "X-SecondLife-Owner-Key", (string)llGetOwner()
    ];
    if (method == "POST")
    {
        h += [HTTP_MIMETYPE, "text/plain"];
    }
    return h;
}

string apiUrl(string suffix)
{
    return apiBase + "/api/v1/bot/" + (string)botId + "/" + suffix;
}

integer cooldownActive(key avatar)
{
    integer i;
    integer n = llGetListLength(cooldownKeys);
    for (i = 0; i < n; i++)
    {
        if (llList2Key(cooldownKeys, i) == avatar)
        {
            if (llGetUnixTime() < llList2Integer(cooldownUntil, i))
            {
                return TRUE;
            }
            cooldownKeys = llDeleteSubList(cooldownKeys, i, i);
            cooldownUntil = llDeleteSubList(cooldownUntil, i, i);
            return FALSE;
        }
    }
    return FALSE;
}

setCooldown(key avatar)
{
    cooldownKeys += [avatar];
    cooldownUntil += [llGetUnixTime() + cooldownSec];
    integer maxPairs = 24;
    while (llGetListLength(cooldownKeys) > maxPairs)
    {
        cooldownKeys = llDeleteSubList(cooldownKeys, 0, 0);
        cooldownUntil = llDeleteSubList(cooldownUntil, 0, 0);
    }
}

applyConfigLine(string line)
{
    line = llStringTrim(line, STRING_TRIM);
    if (line == "" || llSubStringIndex(line, "//") == 0)
    {
        return;
    }
    integer eq = llSubStringIndex(line, "=");
    if (eq < 1)
    {
        return;
    }
    string k = llToLower(llStringTrim(llGetSubString(line, 0, eq - 1), STRING_TRIM));
    string v = llStringTrim(llGetSubString(line, eq + 1, -1), STRING_TRIM);
    if (k == "bot_id")
    {
        botId = (integer)v;
    }
    else if (k == "token")
    {
        apiToken = v;
    }
    else if (k == "api_base")
    {
        apiBase = v;
    }
    else if (k == "group")
    {
        groupUuid = v;
    }
    else if (k == "cooldown")
    {
        cooldownSec = (integer)v;
        if (cooldownSec < 30)
        {
            cooldownSec = 30;
        }
    }
}

beginLoadConfig()
{
    configReady = FALSE;
    if (llGetInventoryType(NOTECARD) != INVENTORY_NOTECARD)
    {
        llOwnerSay("OneBot: drop a notecard named '" + NOTECARD + "' with bot_id and token.");
        return;
    }
    botId = 0;
    apiToken = "";
    groupUuid = "";
    configLine = 0;
    configQuery = llGetNotecardLine(NOTECARD, configLine);
}

finishConfig()
{
    if (botId < 1 || apiToken == "" || groupUuid == "")
    {
        llOwnerSay("OneBot: config needs bot_id, token, and group (group UUID).");
        return;
    }
    configReady = TRUE;
}

postGroupInvite(key avatar)
{
    string body = "group|" + groupUuid + "|avatar|" + (string)avatar;
    llHTTPRequest(apiUrl("group/invite?format=text"), apiHeaders("POST"), body);
}

handleHttp(integer status, string body)
{
    if (status != 200)
    {
        llOwnerSay("OneBot HTTP " + (string)status + (body != "" ? (": " + body) : ""));
        return;
    }
    if (llSubStringIndex(body, "error:") == 0)
    {
        llOwnerSay(llGetSubString(body, 6, -1));
    }
}

default
{
    state_entry()
    {
        llSetObjectDesc("OneBot group joiner");
        beginLoadConfig();
    }

    on_rez(integer start)
    {
        llResetScript();
    }

    dataserver(key query_id, string data)
    {
        if (query_id != configQuery)
        {
            return;
        }
        if (data == EOF)
        {
            finishConfig();
            return;
        }
        applyConfigLine(data);
        configLine++;
        configQuery = llGetNotecardLine(NOTECARD, configLine);
    }

    touch_start(integer n)
    {
        if (!configReady)
        {
            llRegionSayTo(llDetectedKey(0), 0, "Group joiner is not configured yet.");
            return;
        }
        key who = llDetectedKey(0);
        if (cooldownActive(who))
        {
            llRegionSayTo(who, 0, "Please wait before requesting another invite.");
            return;
        }
        postGroupInvite(who);
        setCooldown(who);
        llRegionSayTo(who, 0, "Invite requested via OneBot — check your Groups offers.");
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        handleHttp(status, body);
    }

    changed(integer change)
    {
        if (change & (CHANGED_INVENTORY | CHANGED_OWNER))
        {
            llResetScript();
        }
    }
}

Group Joiner Kiosk

Same invite flow as the touch joiner, plus hover text that reflects bot online/offline (status poll every 60s).

Scopes: Groups, Status

// OneBot — Group Joiner Kiosk (touch invite + hover status). Notecard "OneBot config".
// Scopes: Groups, Status.

string NOTECARD = "OneBot config";
string apiBase = "https://getonebot.com";
integer botId;
string apiToken = "";
string groupUuid = "";
integer cooldownSec = 300;
float statusPollSec = 60.0;

integer configLine;
key configQuery;
integer configReady;
integer botOnline;

list cooldownKeys;
list cooldownUntil;

list apiHeaders(string method)
{
    list h = [
        HTTP_METHOD, method,
        HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + apiToken,
        HTTP_CUSTOM_HEADER, "X-SecondLife-Owner-Key", (string)llGetOwner()
    ];
    if (method == "POST")
    {
        h += [HTTP_MIMETYPE, "text/plain"];
    }
    return h;
}

string apiUrl(string suffix)
{
    return apiBase + "/api/v1/bot/" + (string)botId + "/" + suffix;
}

integer cooldownActive(key avatar)
{
    integer i;
    integer n = llGetListLength(cooldownKeys);
    for (i = 0; i < n; i++)
    {
        if (llList2Key(cooldownKeys, i) == avatar)
        {
            if (llGetUnixTime() < llList2Integer(cooldownUntil, i))
            {
                return TRUE;
            }
            cooldownKeys = llDeleteSubList(cooldownKeys, i, i);
            cooldownUntil = llDeleteSubList(cooldownUntil, i, i);
            return FALSE;
        }
    }
    return FALSE;
}

setCooldown(key avatar)
{
    cooldownKeys += [avatar];
    cooldownUntil += [llGetUnixTime() + cooldownSec];
    while (llGetListLength(cooldownKeys) > 24)
    {
        cooldownKeys = llDeleteSubList(cooldownKeys, 0, 0);
        cooldownUntil = llDeleteSubList(cooldownUntil, 0, 0);
    }
}

applyConfigLine(string line)
{
    line = llStringTrim(line, STRING_TRIM);
    if (line == "" || llSubStringIndex(line, "//") == 0)
    {
        return;
    }
    integer eq = llSubStringIndex(line, "=");
    if (eq < 1)
    {
        return;
    }
    string k = llToLower(llStringTrim(llGetSubString(line, 0, eq - 1), STRING_TRIM));
    string v = llStringTrim(llGetSubString(line, eq + 1, -1), STRING_TRIM);
    if (k == "bot_id")
    {
        botId = (integer)v;
    }
    else if (k == "token")
    {
        apiToken = v;
    }
    else if (k == "api_base")
    {
        apiBase = v;
    }
    else if (k == "group")
    {
        groupUuid = v;
    }
    else if (k == "cooldown")
    {
        cooldownSec = (integer)v;
    }
}

updateHover()
{
    string t = "OneBot Group";
    if (botOnline)
    {
        t += "\nBot online — touch to join";
        llSetColor(<0.2, 0.75, 0.35>, ALL_SIDES);
    }
    else
    {
        t += "\nBot offline — try again soon";
        llSetColor(<0.55, 0.15, 0.15>, ALL_SIDES);
    }
    llSetText(t, <1.0, 1.0, 1.0>, 1.0);
}

beginLoadConfig()
{
    configReady = FALSE;
    if (llGetInventoryType(NOTECARD) != INVENTORY_NOTECARD)
    {
        llOwnerSay("OneBot: missing '" + NOTECARD + "' notecard.");
        return;
    }
    botId = 0;
    apiToken = "";
    groupUuid = "";
    configLine = 0;
    configQuery = llGetNotecardLine(NOTECARD, configLine);
}

finishConfig()
{
    if (botId < 1 || apiToken == "" || groupUuid == "")
    {
        llOwnerSay("OneBot: config needs bot_id, token, and group.");
        return;
    }
    configReady = TRUE;
    llSetTimerEvent(statusPollSec);
    llHTTPRequest(apiUrl("status"), apiHeaders("GET"), "");
    updateHover();
}

default
{
    state_entry()
    {
        beginLoadConfig();
    }

    on_rez(integer p)
    {
        llResetScript();
    }

    dataserver(key q, string data)
    {
        if (q != configQuery)
        {
            return;
        }
        if (data == EOF)
        {
            finishConfig();
            return;
        }
        applyConfigLine(data);
        configLine++;
        configQuery = llGetNotecardLine(NOTECARD, configLine);
    }

    timer()
    {
        if (!configReady)
        {
            return;
        }
        llHTTPRequest(apiUrl("status"), apiHeaders("GET"), "");
    }

    touch_start(integer n)
    {
        if (!configReady)
        {
            return;
        }
        if (!botOnline)
        {
            llRegionSayTo(llDetectedKey(0), 0, "The bot is offline right now.");
            return;
        }
        key who = llDetectedKey(0);
        if (cooldownActive(who))
        {
            llRegionSayTo(who, 0, "Please wait before another invite.");
            return;
        }
        string body = "group|" + groupUuid + "|avatar|" + (string)who;
        llHTTPRequest(apiUrl("group/invite?format=text"), apiHeaders("POST"), body);
        setCooldown(who);
        llRegionSayTo(who, 0, "Group invite sent via OneBot.");
    }

    http_response(key id, integer status, list meta, string body)
    {
        if (!configReady)
        {
            return;
        }
        if (status != 200)
        {
            llOwnerSay("OneBot status/invite HTTP " + (string)status);
            return;
        }
        if (llSubStringIndex(body, "error:") == 0)
        {
            llOwnerSay(llGetSubString(body, 6, -1));
            return;
        }
        if (llSubStringIndex(body, "online") >= 0)
        {
            botOnline = (llSubStringIndex(body, "\"online\":true") >= 0);
            updateHover();
        }
    }

    changed(integer c)
    {
        if (c & (CHANGED_INVENTORY | CHANGED_OWNER))
        {
            llResetScript();
        }
    }
}

Group Notice Board

Owner chat on a private channel (default /7): subject|message posts a group notice via the bot.

Scopes: Groups

// OneBot — Group Notice Board. Owner chat channel (default 7): subject|message
// Scopes: Groups. Config: bot_id, token, group, channel (optional).

string NOTECARD = "OneBot config";
string apiBase = "https://getonebot.com";
integer botId;
string apiToken = "";
string groupUuid = "";
integer noticeChannel = 7;

integer configLine;
key configQuery;
integer configReady;
integer listenHandle;

list apiHeaders(string method)
{
    list h = [
        HTTP_METHOD, method,
        HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + apiToken,
        HTTP_CUSTOM_HEADER, "X-SecondLife-Owner-Key", (string)llGetOwner()
    ];
    if (method == "POST")
    {
        h += [HTTP_MIMETYPE, "text/plain"];
    }
    return h;
}

string apiUrl(string suffix)
{
    return apiBase + "/api/v1/bot/" + (string)botId + "/" + suffix;
}

applyConfigLine(string line)
{
    line = llStringTrim(line, STRING_TRIM);
    if (line == "" || llSubStringIndex(line, "//") == 0)
    {
        return;
    }
    integer eq = llSubStringIndex(line, "=");
    if (eq < 1)
    {
        return;
    }
    string k = llToLower(llStringTrim(llGetSubString(line, 0, eq - 1), STRING_TRIM));
    string v = llStringTrim(llGetSubString(line, eq + 1, -1), STRING_TRIM);
    if (k == "bot_id")
    {
        botId = (integer)v;
    }
    else if (k == "token")
    {
        apiToken = v;
    }
    else if (k == "api_base")
    {
        apiBase = v;
    }
    else if (k == "group")
    {
        groupUuid = v;
    }
    else if (k == "channel")
    {
        noticeChannel = (integer)v;
    }
}

beginLoadConfig()
{
    configReady = FALSE;
    if (llGetInventoryType(NOTECARD) != INVENTORY_NOTECARD)
    {
        llOwnerSay("OneBot: missing '" + NOTECARD + "' notecard.");
        return;
    }
    configLine = 0;
    configQuery = llGetNotecardLine(NOTECARD, configLine);
}

finishConfig()
{
    if (botId < 1 || apiToken == "" || groupUuid == "")
    {
        llOwnerSay("OneBot: config needs bot_id, token, and group.");
        return;
    }
    configReady = TRUE;
    if (listenHandle)
    {
        llListenRemove(listenHandle);
    }
    listenHandle = llListen(noticeChannel, "", llGetOwner(), "");
    llOwnerSay("Notice board listening on /" + (string)noticeChannel + " — format: subject|message");
}

default
{
    state_entry()
    {
        beginLoadConfig();
    }

    on_rez(integer p)
    {
        llResetScript();
    }

    dataserver(key q, string data)
    {
        if (q != configQuery)
        {
            return;
        }
        if (data == EOF)
        {
            finishConfig();
            return;
        }
        applyConfigLine(data);
        configLine++;
        configQuery = llGetNotecardLine(NOTECARD, configLine);
    }

    listen(integer chan, string name, key id, string msg)
    {
        if (!configReady || id != llGetOwner())
        {
            return;
        }
        msg = llStringTrim(msg, STRING_TRIM);
        integer bar = llSubStringIndex(msg, "|");
        if (bar < 1)
        {
            llOwnerSay("Use: subject|message");
            return;
        }
        string subj = llStringTrim(llGetSubString(msg, 0, bar - 1), STRING_TRIM);
        string bodyMsg = llStringTrim(llGetSubString(msg, bar + 1, -1), STRING_TRIM);
        if (bodyMsg == "")
        {
            llOwnerSay("Message cannot be empty.");
            return;
        }
        string body = "group|" + groupUuid + "|subject|" + subj + "|message|" + bodyMsg;
        llHTTPRequest(apiUrl("group/notice?format=text"), apiHeaders("POST"), body);
    }

    http_response(key id, integer status, list meta, string body)
    {
        if (status != 200 || llSubStringIndex(body, "error:") == 0)
        {
            if (llSubStringIndex(body, "error:") == 0)
            {
                llOwnerSay(llGetSubString(body, 6, -1));
            }
            else
            {
                llOwnerSay("OneBot HTTP " + (string)status);
            }
            return;
        }
        llOwnerSay("Group notice queued.");
    }

    changed(integer c)
    {
        if (c & (CHANGED_INVENTORY | CHANGED_OWNER))
        {
            llResetScript();
        }
    }
}

Visitor Greeter

Sensor greets visitors with one IM per avatar per day; remembers recent avatars in a capped list.

Scopes: Chat

// OneBot — Visitor Greeter. Sensor + one IM per avatar per 24h. Scopes: Chat.

string NOTECARD = "OneBot config";
string apiBase = "https://getonebot.com";
integer botId;
string apiToken = "";
string greetMessage = "Hello — thanks for visiting!";
float sensorRange = 10.0;
float sensorRepeat = 30.0;

integer configLine;
key configQuery;
integer configReady;

list seenKeys;
list seenUntil;
integer maxSeen = 20;

list apiHeaders(string method)
{
    list h = [
        HTTP_METHOD, method,
        HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + apiToken,
        HTTP_CUSTOM_HEADER, "X-SecondLife-Owner-Key", (string)llGetOwner()
    ];
    if (method == "POST")
    {
        h += [HTTP_MIMETYPE, "text/plain"];
    }
    return h;
}

string apiUrl(string suffix)
{
    return apiBase + "/api/v1/bot/" + (string)botId + "/" + suffix;
}

integer shouldGreet(key avatar)
{
    integer now = llGetUnixTime();
    integer i;
    integer n = llGetListLength(seenKeys);
    for (i = 0; i < n; i++)
    {
        if (llList2Key(seenKeys, i) == avatar)
        {
            if (now < llList2Integer(seenUntil, i))
            {
                return FALSE;
            }
            seenKeys = llDeleteSubList(seenKeys, i, i);
            seenUntil = llDeleteSubList(seenUntil, i, i);
            return TRUE;
        }
    }
    return TRUE;
}

markGreeted(key avatar)
{
    seenKeys += [avatar];
    seenUntil += [llGetUnixTime() + 86400];
    while (llGetListLength(seenKeys) > maxSeen)
    {
        seenKeys = llDeleteSubList(seenKeys, 0, 0);
        seenUntil = llDeleteSubList(seenUntil, 0, 0);
    }
}

applyConfigLine(string line)
{
    line = llStringTrim(line, STRING_TRIM);
    if (line == "" || llSubStringIndex(line, "//") == 0)
    {
        return;
    }
    integer eq = llSubStringIndex(line, "=");
    if (eq < 1)
    {
        return;
    }
    string k = llToLower(llStringTrim(llGetSubString(line, 0, eq - 1), STRING_TRIM));
    string v = llStringTrim(llGetSubString(line, eq + 1, -1), STRING_TRIM);
    if (k == "bot_id")
    {
        botId = (integer)v;
    }
    else if (k == "token")
    {
        apiToken = v;
    }
    else if (k == "api_base")
    {
        apiBase = v;
    }
    else if (k == "greet_message")
    {
        greetMessage = v;
    }
    else if (k == "sensor_range")
    {
        sensorRange = (float)v;
    }
}

beginLoadConfig()
{
    configReady = FALSE;
    if (llGetInventoryType(NOTECARD) != INVENTORY_NOTECARD)
    {
        llOwnerSay("OneBot: missing '" + NOTECARD + "' notecard.");
        return;
    }
    configLine = 0;
    configQuery = llGetNotecardLine(NOTECARD, configLine);
}

finishConfig()
{
    if (botId < 1 || apiToken == "")
    {
        llOwnerSay("OneBot: config needs bot_id and token.");
        return;
    }
    configReady = TRUE;
    llSensorRepeat("", NULL_KEY, AGENT, sensorRange, PI, sensorRepeat);
}

default
{
    state_entry()
    {
        beginLoadConfig();
    }

    on_rez(integer p)
    {
        llResetScript();
    }

    dataserver(key q, string data)
    {
        if (q != configQuery)
        {
            return;
        }
        if (data == EOF)
        {
            finishConfig();
            return;
        }
        applyConfigLine(data);
        configLine++;
        configQuery = llGetNotecardLine(NOTECARD, configLine);
    }

    sensor(integer n)
    {
        if (!configReady)
        {
            return;
        }
        integer i;
        for (i = 0; i < n; i++)
        {
            key who = llDetectedKey(i);
            if (who == llGetOwner())
            {
                jump next;
            }
            if (!shouldGreet(who))
            {
                jump next;
            }
            string body = "to|" + (string)who + "|message|" + greetMessage;
            llHTTPRequest(apiUrl("im?format=text"), apiHeaders("POST"), body);
            markGreeted(who);
            @next;
        }
    }

    http_response(key id, integer status, list meta, string body)
    {
        if (status != 200 || llSubStringIndex(body, "error:") == 0)
        {
            if (llSubStringIndex(body, "error:") == 0)
            {
                llOwnerSay(llGetSubString(body, 6, -1));
            }
        }
    }

    changed(integer c)
    {
        if (c & (CHANGED_INVENTORY | CHANGED_OWNER))
        {
            llResetScript();
        }
    }
}

Greeter (greet API)

Sensor greets visitors via POST /greet — choose local chat or IM with channel= in the notecard.

Scopes: Chat

// OneBot — Greeter. Sensor calls POST …/greet (local or IM). Scopes: Chat.

string NOTECARD = "OneBot config";
string apiBase = "https://getonebot.com";
integer botId;
string apiToken = "";
string greetMessage = "Welcome — thanks for stopping by!";
string greetChannel = "im";
float sensorRange = 12.0;
float sensorRepeat = 20.0;
integer cooldownSec = 86400;

integer configLine;
key configQuery;
integer configReady;

list seenKeys;
list seenUntil;
integer maxSeen = 32;

list apiHeaders(string method)
{
    list h = [
        HTTP_METHOD, method,
        HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + apiToken,
        HTTP_CUSTOM_HEADER, "X-SecondLife-Owner-Key", (string)llGetOwner()
    ];
    if (method == "POST")
    {
        h += [HTTP_MIMETYPE, "text/plain"];
    }
    return h;
}

string apiUrl(string suffix)
{
    return apiBase + "/api/v1/bot/" + (string)botId + "/" + suffix;
}

integer shouldGreet(key avatar)
{
    integer now = llGetUnixTime();
    integer i;
    integer n = llGetListLength(seenKeys);
    for (i = 0; i < n; i++)
    {
        if (llList2Key(seenKeys, i) == avatar)
        {
            if (now < llList2Integer(seenUntil, i))
            {
                return FALSE;
            }
            seenKeys = llDeleteSubList(seenKeys, i, i);
            seenUntil = llDeleteSubList(seenUntil, i, i);
            return TRUE;
        }
    }
    return TRUE;
}

markGreeted(key avatar)
{
    seenKeys += [avatar];
    seenUntil += [llGetUnixTime() + cooldownSec];
    while (llGetListLength(seenKeys) > maxSeen)
    {
        seenKeys = llDeleteSubList(seenKeys, 0, 0);
        seenUntil = llDeleteSubList(seenUntil, 0, 0);
    }
}

applyConfigLine(string line)
{
    line = llStringTrim(line, STRING_TRIM);
    if (line == "" || llSubStringIndex(line, "//") == 0)
    {
        return;
    }
    integer eq = llSubStringIndex(line, "=");
    if (eq < 1)
    {
        return;
    }
    string k = llToLower(llStringTrim(llGetSubString(line, 0, eq - 1), STRING_TRIM));
    string v = llStringTrim(llGetSubString(line, eq + 1, -1), STRING_TRIM);
    if (k == "bot_id")
    {
        botId = (integer)v;
    }
    else if (k == "token")
    {
        apiToken = v;
    }
    else if (k == "api_base")
    {
        apiBase = v;
    }
    else if (k == "greet_message")
    {
        greetMessage = v;
    }
    else if (k == "channel")
    {
        greetChannel = llToLower(v);
    }
    else if (k == "sensor_range")
    {
        sensorRange = (float)v;
    }
    else if (k == "cooldown")
    {
        cooldownSec = (integer)v;
    }
}

beginLoadConfig()
{
    configReady = FALSE;
    if (llGetInventoryType(NOTECARD) != INVENTORY_NOTECARD)
    {
        llOwnerSay("OneBot: missing '" + NOTECARD + "' notecard.");
        return;
    }
    configLine = 0;
    configQuery = llGetNotecardLine(NOTECARD, configLine);
}

finishConfig()
{
    if (botId < 1 || apiToken == "")
    {
        llOwnerSay("OneBot: config needs bot_id and token.");
        return;
    }
    if (greetChannel != "local" && greetChannel != "im")
    {
        greetChannel = "im";
    }
    configReady = TRUE;
    llSensorRepeat("", NULL_KEY, AGENT, sensorRange, PI, sensorRepeat);
}

postGreet(key who)
{
    string body = "visitor|" + (string)who + "|message|" + greetMessage + "|channel|" + greetChannel;
    llHTTPRequest(apiUrl("greet?format=text"), apiHeaders("POST"), body);
}

default
{
    state_entry()
    {
        beginLoadConfig();
    }

    on_rez(integer p)
    {
        llResetScript();
    }

    dataserver(key q, string data)
    {
        if (q != configQuery)
        {
            return;
        }
        if (data == EOF)
        {
            finishConfig();
            return;
        }
        applyConfigLine(data);
        configLine++;
        configQuery = llGetNotecardLine(NOTECARD, configLine);
    }

    sensor(integer n)
    {
        if (!configReady)
        {
            return;
        }
        integer i;
        for (i = 0; i < n; i++)
        {
            key who = llDetectedKey(i);
            if (who == llGetOwner())
            {
                jump next;
            }
            if (!shouldGreet(who))
            {
                jump next;
            }
            postGreet(who);
            markGreeted(who);
            @next;
        }
    }

    http_response(key id, integer status, list meta, string body)
    {
        if (status != 200 || llSubStringIndex(body, "error:") == 0)
        {
            if (llSubStringIndex(body, "error:") == 0)
            {
                llOwnerSay(llGetSubString(body, 6, -1));
            }
        }
    }

    changed(integer c)
    {
        if (c & (CHANGED_INVENTORY | CHANGED_OWNER))
        {
            llResetScript();
        }
    }
}

Gift Giver

Touch to deliver a configured inventory item from the bot's inventory, with per-avatar cooldown.

Scopes: Inventory

// OneBot — Gift Giver. Touch to give inventory item (UUID in config "item"). Scopes: Inventory.

string NOTECARD = "OneBot config";
string apiBase = "https://getonebot.com";
integer botId;
string apiToken = "";
string itemUuid = "";
integer cooldownSec = 120;

integer configLine;
key configQuery;
integer configReady;

list cooldownKeys;
list cooldownUntil;

list apiHeaders(string method)
{
    list h = [
        HTTP_METHOD, method,
        HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + apiToken,
        HTTP_CUSTOM_HEADER, "X-SecondLife-Owner-Key", (string)llGetOwner()
    ];
    if (method == "POST")
    {
        h += [HTTP_MIMETYPE, "text/plain"];
    }
    return h;
}

string apiUrl(string suffix)
{
    return apiBase + "/api/v1/bot/" + (string)botId + "/" + suffix;
}

integer cooldownActive(key avatar)
{
    integer i;
    integer n = llGetListLength(cooldownKeys);
    for (i = 0; i < n; i++)
    {
        if (llList2Key(cooldownKeys, i) == avatar)
        {
            if (llGetUnixTime() < llList2Integer(cooldownUntil, i))
            {
                return TRUE;
            }
            cooldownKeys = llDeleteSubList(cooldownKeys, i, i);
            cooldownUntil = llDeleteSubList(cooldownUntil, i, i);
            return FALSE;
        }
    }
    return FALSE;
}

setCooldown(key avatar)
{
    cooldownKeys += [avatar];
    cooldownUntil += [llGetUnixTime() + cooldownSec];
    while (llGetListLength(cooldownKeys) > 24)
    {
        cooldownKeys = llDeleteSubList(cooldownKeys, 0, 0);
        cooldownUntil = llDeleteSubList(cooldownUntil, 0, 0);
    }
}

applyConfigLine(string line)
{
    line = llStringTrim(line, STRING_TRIM);
    if (line == "" || llSubStringIndex(line, "//") == 0)
    {
        return;
    }
    integer eq = llSubStringIndex(line, "=");
    if (eq < 1)
    {
        return;
    }
    string k = llToLower(llStringTrim(llGetSubString(line, 0, eq - 1), STRING_TRIM));
    string v = llStringTrim(llGetSubString(line, eq + 1, -1), STRING_TRIM);
    if (k == "bot_id")
    {
        botId = (integer)v;
    }
    else if (k == "token")
    {
        apiToken = v;
    }
    else if (k == "api_base")
    {
        apiBase = v;
    }
    else if (k == "item")
    {
        itemUuid = v;
    }
    else if (k == "cooldown")
    {
        cooldownSec = (integer)v;
    }
}

beginLoadConfig()
{
    configReady = FALSE;
    if (llGetInventoryType(NOTECARD) != INVENTORY_NOTECARD)
    {
        llOwnerSay("OneBot: missing '" + NOTECARD + "' notecard.");
        return;
    }
    configLine = 0;
    configQuery = llGetNotecardLine(NOTECARD, configLine);
}

finishConfig()
{
    if (botId < 1 || apiToken == "" || itemUuid == "")
    {
        llOwnerSay("OneBot: config needs bot_id, token, and item (inventory UUID).");
        return;
    }
    configReady = TRUE;
    llSetText("Touch for gift", <1.0, 1.0, 1.0>, 1.0);
}

default
{
    state_entry()
    {
        beginLoadConfig();
    }

    on_rez(integer p)
    {
        llResetScript();
    }

    dataserver(key q, string data)
    {
        if (q != configQuery)
        {
            return;
        }
        if (data == EOF)
        {
            finishConfig();
            return;
        }
        applyConfigLine(data);
        configLine++;
        configQuery = llGetNotecardLine(NOTECARD, configLine);
    }

    touch_start(integer n)
    {
        if (!configReady)
        {
            return;
        }
        key who = llDetectedKey(0);
        if (cooldownActive(who))
        {
            llRegionSayTo(who, 0, "Please wait before another gift.");
            return;
        }
        string body = "item|" + itemUuid + "|avatar|" + (string)who;
        llHTTPRequest(apiUrl("give?format=text"), apiHeaders("POST"), body);
        setCooldown(who);
        llRegionSayTo(who, 0, "Gift requested from OneBot.");
    }

    http_response(key id, integer status, list meta, string body)
    {
        if (status != 200 || llSubStringIndex(body, "error:") == 0)
        {
            if (llSubStringIndex(body, "error:") == 0)
            {
                llOwnerSay(llGetSubString(body, 6, -1));
            }
            else
            {
                llOwnerSay("OneBot HTTP " + (string)status);
            }
        }
    }

    changed(integer c)
    {
        if (c & (CHANGED_INVENTORY | CHANGED_OWNER))
        {
            llResetScript();
        }
    }
}

Bot Status Sign

Polls bot status and updates hover text and prim color for online vs offline.

Scopes: Status

// OneBot — Bot Status Sign. Polls /status for hover text + color. Scopes: Status.

string NOTECARD = "OneBot config";
string apiBase = "https://getonebot.com";
integer botId;
string apiToken = "";
float pollSec = 60.0;

integer configLine;
key configQuery;
integer configReady;
integer botOnline = FALSE;
string botRegion = "";

list apiHeaders(string method)
{
    return [
        HTTP_METHOD, method,
        HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + apiToken,
        HTTP_CUSTOM_HEADER, "X-SecondLife-Owner-Key", (string)llGetOwner()
    ];
}

string apiUrl(string suffix)
{
    return apiBase + "/api/v1/bot/" + (string)botId + "/" + suffix;
}

applyConfigLine(string line)
{
    line = llStringTrim(line, STRING_TRIM);
    if (line == "" || llSubStringIndex(line, "//") == 0)
    {
        return;
    }
    integer eq = llSubStringIndex(line, "=");
    if (eq < 1)
    {
        return;
    }
    string k = llToLower(llStringTrim(llGetSubString(line, 0, eq - 1), STRING_TRIM));
    string v = llStringTrim(llGetSubString(line, eq + 1, -1), STRING_TRIM);
    if (k == "bot_id")
    {
        botId = (integer)v;
    }
    else if (k == "token")
    {
        apiToken = v;
    }
    else if (k == "api_base")
    {
        apiBase = v;
    }
    else if (k == "poll_seconds")
    {
        pollSec = (float)v;
        if (pollSec < 15.0)
        {
            pollSec = 15.0;
        }
    }
}

updateSign()
{
    string t = "OneBot";
    vector col = <0.45, 0.45, 0.45>;
    if (botOnline)
    {
        t += "\nOnline";
        if (botRegion != "")
        {
            t += "\n" + botRegion;
        }
        col = <0.15, 0.8, 0.35>;
    }
    else
    {
        t += "\nOffline";
        col = <0.7, 0.2, 0.2>;
    }
    llSetText(t, <1.0, 1.0, 1.0>, 1.0);
    llSetColor(col, ALL_SIDES);
}

beginLoadConfig()
{
    configReady = FALSE;
    if (llGetInventoryType(NOTECARD) != INVENTORY_NOTECARD)
    {
        llOwnerSay("OneBot: missing '" + NOTECARD + "' notecard.");
        return;
    }
    configLine = 0;
    configQuery = llGetNotecardLine(NOTECARD, configLine);
}

finishConfig()
{
    if (botId < 1 || apiToken == "")
    {
        llOwnerSay("OneBot: config needs bot_id and token.");
        return;
    }
    configReady = TRUE;
    llSetTimerEvent(pollSec);
    llHTTPRequest(apiUrl("status"), apiHeaders("GET"), "");
    updateSign();
}

parseStatus(string body)
{
    botOnline = (llSubStringIndex(body, "\"online\":true") >= 0);
    integer r = llSubStringIndex(body, "\"region\":\"");
    if (r >= 0)
    {
        string tail = llGetSubString(body, r + 11, -1);
        integer end = llSubStringIndex(tail, "\"");
        if (end > 0)
        {
            botRegion = llGetSubString(tail, 0, end - 1);
        }
    }
    else
    {
        botRegion = "";
    }
    updateSign();
}

default
{
    state_entry()
    {
        beginLoadConfig();
    }

    on_rez(integer p)
    {
        llResetScript();
    }

    dataserver(key q, string data)
    {
        if (q != configQuery)
        {
            return;
        }
        if (data == EOF)
        {
            finishConfig();
            return;
        }
        applyConfigLine(data);
        configLine++;
        configQuery = llGetNotecardLine(NOTECARD, configLine);
    }

    timer()
    {
        if (configReady)
        {
            llHTTPRequest(apiUrl("status"), apiHeaders("GET"), "");
        }
    }

    http_response(key id, integer status, list meta, string body)
    {
        if (!configReady)
        {
            return;
        }
        if (status != 200)
        {
            botOnline = FALSE;
            botRegion = "";
            updateSign();
            llOwnerSay("OneBot status HTTP " + (string)status);
            return;
        }
        if (llSubStringIndex(body, "error:") == 0)
        {
            llOwnerSay(llGetSubString(body, 6, -1));
            return;
        }
        parseStatus(body);
    }

    changed(integer c)
    {
        if (c & (CHANGED_INVENTORY | CHANGED_OWNER))
        {
            llResetScript();
        }
    }
}