Pandora Bots

The following script contributed by JP Bluebird from Bluebird Designs will listen to local chat, and forward messages to Pandora Bots, retrieve the reply and then make Corrade say the reply on local chat.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Corrade AI ChatBot (Pandorabots Example)
//
// Script Setup Instructions:
//
//   01. Fill in the Settings below with your Corrade Bot UUID Key, Group, and Password that you used in your
//       corrade.ini file.
//
//   02. Follow the Pandorabot Setup Steps.
//
// Pandorabot Setup Steps:
//
//   01. Register a Free Account at Pandorabots - http://www.pandorabots.com
//   02. Visit your Pandorabot's bot webpage (allows you to chat with your Pandorabot).
//   03. From the Address Bar of your browser copy the ID after "botid=".
//   04. Paste that ID into the Settings Below (Pandorabot ID).
//
// Contributed by JP Bluebird (Bluebird Designs)
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Settings
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
string  gCORRADE  = "00000000-0000-0000-0000-000000000000";   // Your Corrade Bot's UUID Key
string  gGROUP    = "GROUP NAME";                             // Bot's Group Name as defined in the ini File
string  gPASSWORD = "GROUP PASSWORD";                         // Bot's Password as defined in the ini File
string  gPBOTID   = "PANDORABOT ID";                          // Your Pandorbot ID
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Functions
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
string wasKeyValueEncode(list kvp)
{
  if(llGetListLength(kvp) < 2) return "";
  string k = llList2String(kvp, 0);
  kvp      = llDeleteSubList(kvp, 0, 0);
  string v = llList2String(kvp, 0);
  kvp      = llDeleteSubList(kvp, 0, 0);
  if(llGetListLength(kvp) < 2) return k + "=" + v;
  return k + "=" + v + "&" + wasKeyValueEncode(kvp);
}
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// States
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
default
{
  state_entry()
  {
    llListen(PUBLIC_CHANNEL, "", "", "");
  }
 
  listen(integer channel, string name, key id, string message)
  {
    if (id == gCORRADE || message == "") return;
    string tQUERY = "botid="+gPBOTID+"&costid="+(string)id+"&input="+llEscapeURL(message);
    llHTTPRequest("http://www.pandorabots.com/pandora/talk-xml?"+tQUERY, [], "");
  }
 
  http_response(key request_id, integer status, list metadata, string body)
  {
    list   response = llParseString2List(body,["<that>"],["</that>"]);
    string answer   = llList2String(response, 1);
 
    llInstantMessage(gCORRADE, wasKeyValueEncode([
      "command",  "tell",
      "group",    llEscapeURL(gGROUP),
      "password", llEscapeURL(gPASSWORD),
      "entity",   "local",
      "type",     "Normal",
      "message",  llEscapeURL(answer)
    ]));
  }
}

secondlife/scripted_agents/corrade/tutorials/artificial_intelligence/external_services/pandora_bots.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.