Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
ChatBot ChatBot  

ChatBot

Chatbot for PersonalityForge. Get a free account at http://www.personalityforge.com.
5,000 chats are free.
Get an API ID, and add it to the apiKey below
Add the domain *.secondlife.com or your OpenSim server IP to the list of authorized domains at http://www.personalityforge.com/botland/myapi.php
add a checkmark to the Enable Simple API
click on the Simple API tab and pick a chatbot ID from the list of chatbots under the heading "Selecting A Chat Bot ID"
for example, Countess Elvira is 99232. Put that in chatBot ID below.
754 is for a ssex flirt.

Category: ChatBot
By : Ferd Frederix
Created: 2014-08-11 Edited: 2015-08-27
Worlds: OpenSim

the Zip file

Download all files for ChatBot
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. avatar_type.bvh
Get file # 2. [107893 bytes] chatbot codes.jpg
Get file # 3. chatbot.lsl
Get file # 4. NPCchatbot.lsl
Get file # 5. Script.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 key requestid;
2 string apiKey = "jkeU6Hv3tbk318wn1"; // your supplied apiKey from your Chat Bot API subscription
3 string chatBotID = "754"; // the ID of the chat bot you're talking to
4 integer debug = FALSE;
5
6 DEBUG(string msg)
7 {
8 if(debug) llSay(0,msg);
9 }
10
11 default
12 {
14 {
15 llListen(0,"","","");
16 }
17
18 on_rez(integer param)
19 {
21 }
22
23 listen(integer channel, string name, key id, string message)
24 {
25
26 // if the speaker is a prim, it will have a creator
28 key spkrKey = llList2Key(what,0);
29
30 if(spkrKey != NULL_KEY)
31 {
32 return; // we do not want to listen to objects
33 }
34
35 list names = llParseString2List(name,[" "],[]);
36 string firstname = llList2String(names,0);
37 string lastname = llList2String(names,1);
38
39 requestid = llHTTPRequest("http://www.personalityforge.com/api/chat"
40 + "?apiKey=" + llEscapeURL(apiKey)
41 + "&message=" + llEscapeURL(message)
42 + "&chatBotID=" + llEscapeURL(chatBotID)
43 + "&externalID=" + llEscapeURL(name)
44 + "&firstName=" + llEscapeURL(firstname)
45 + "&lastName=" + llEscapeURL(lastname)
46 ,[HTTP_METHOD,"GET"],"");
47 }
48 http_response(key request_id, integer status, list metadata, string body)
49 {
50
51 DEBUG(body);
52 // typical body:
53 // Checking origin: '71.252.253.190' (regex: '71\.252\.253\.190')<br>Matched!<br>{"success":1,"errorMessage":"","message":{"chatBotName":"Liddora","chatBotID":"754","message":"Look up. It's Liddora. So how have you been lately, hello?","emotion":"asking"}}
54
55 if(request_id == requestid)
56 {
57 integer begin = llSubStringIndex(body, "message\":\"");
58 DEBUG((string) begin);
59
60 string msg = llGetSubString(body, begin +10, -1);
61 DEBUG((string) msg);
62
63 integer end = llSubStringIndex(msg, "emotion");
64 DEBUG((string) end);
65
66 string reply = llGetSubString(msg, 0, end-4);
67 llSay(0,reply);
68 }
69 }
70 }

ChatBot

This chatbot is for OpenSim Only. It only works on NPC's.
Rev 1.1 08-27-2015 made API use first name as the Hypergid names were too long
Chatbot for PersonalityForge. Get a free account at http://www.personalityforge.com.
5,000 chats are free.

Category: ChatBot
By : Ferd Frederix
Created: 2014-08-11 Edited: 2015-08-27
Worlds: OpenSim


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // fiorst, get a free account at http://www.personalityforge.com.
3 // Get an API ID, and add it to the apiKey :
4
5 string apiKey = "jkeU6Hv3tbssk318wn1"; // your supplied apiKey from your Chat Bot API subscription
6
7 // Add the domain *.secondlife.com or your OpenSim server IP to the list of authorized domains at http://www.personalityforge.com/botland/myapi.php
8 // Add a checkmark to the "Enable Simple API" in tyour account.
9 // Click on the Simple API tab and pick a chatbot ID from the list of chatbots under the heading "Selecting A Chat Bot ID"
10 // for example, Countess Elvira is 99232. Put that in chatBot ID below.
11 // Sex Bot Ciran is 100387. Type menu for choices
12 // 754 is Liddora a sexy tart
13
14 // look at http://www.personalityforge.com/bookofapi.php for more public chat bots
15
16 string chatBotID = "754"; // the ID of the chat bot you're talking to
17 integer greeting = TRUE; // if TRUE, say hello when anyone comes up.
18
19
20 integer debug = TRUE; // Set this TRUE to see the gory details
21
22 ////////// REMOVE THESE IN WORLD ////////////////
23 ///////// LSLEDIT DEBUG ONLY////////////////////
24 //osNpcSetRot(key npc, rotation rot) {llSay(0,"Roatating to " + (vector) llRot2Euler(rot));}
25 //osNpcStopAnimation(key npc, string animation) {llSay(0,"Stopped " + animation);}
26 //osNpcPlayAnimation(key npc, string animation) {llSay(0,"Playing " + animation);}
27 //osNpcSay(string speach) {llSay(0,speach);}
28 /////////////////////////////////////////////////////////////////////
29
30 // various tuneable code bits
31 float range = 15; // haw far awy an avatar is before we greet them/. No point in making this more than 20, that cannot hear us after that
32 float wpm = 50; // 33 wpm = 2.75 cps @ 5 chars per word for a typical avatar to type with.
33 // Larger numbers make your NPC answer quicker.
34 float cps;
35 integer emotionchannel = 199; // a secret channel that the chatbot sends emotion strings on.
36 // You can listen for these with other scripts worn by your chatbot, and animate something to show how your chat bot is feeling.
37 // this is also sent on Link Message Number 1 to all scripts in your chatbox prim
38
39 // global variables
40 key npcKey ; // the NPC wearing this
41 string npcName; // ditto
42 integer starttime; // the time we started typing
43 key requestid; // check for out HTTP answer
44 integer AvatarPresent;// true is someone is here
45
46 // first of stride is the response from the bot, the second is the built-in animation
47 list gAnimations = ["normal", "hello",
48 "happy","express_smile",
49 "angry","express_anger",
50 "averse","express_embarrased",
51 "sad","express_sad",
52 "evil","express_repulsed",
53 "fuming","express_worry",
54 "hurt","express_cry",
55 "surprised","express_surprise",
56 "insulted","express_afraid",
57 "confused","express_shrug",
58 "amused","express_laugh",
59 "asking","express_shrug"];
60
61
62 list lAvatars; // a list of visitors
63
64 DEBUG(string msg)
65 {
66 if(debug) llSay(0,msg);
67 }
68
69 string strReplace(string str, string search, string replace) {
70 return llDumpList2String(llParseStringKeepNulls(str, [search], []), replace);
71 }
72
73 default
74 {
75
76 on_rez(integer param)
77 {
79 }
80
82 {
83
84 npcKey = llGetOwner();
85 npcName = llKey2Name(npcKey);
86 DEBUG("npc is named " + npcName);
87
88 llListen(0,"","","");
89 cps = wpm * 5 / 60; // change from words per minute to cps.
90 DEBUG("CPS = " + (string) cps);
91 if(greeting)
92 llSensorRepeat("","",AGENT,range,PI,10);
93 }
94
95 sensor(integer N) {
96 integer i;
97 for (i = 0 ; i < N; i ++) {
98 key avatarKey = llDetectedKey(i);
99
100 if(llListFindList(lAvatars,[avatarKey]) == -1) {
101 osNpcSay(npcKey,"Hi there, " + llDetectedName(i));
102 lAvatars += avatarKey;
103 if(llGetListLength(lAvatars) > 1000) {
104 lAvatars = llDeleteSubList(lAvatars, 0,0);
105 }
106 } else {
107 osNpcSay(npcKey,"Hello again, " + llDetectedName(i));
108
109 }
110 }
111 }
112
113 no_sensor()
114 {
115 AvatarPresent = FALSE; }
116
117 listen(integer channel, string name, key id, string message)
118 {
119 // if the speaker is a prim, it will have a creator. Avatars do not have a creator
121 key spkrKey = llList2Key(what,0);
122
123 if(spkrKey != NULL_KEY && !debug)
124 {
125 if(! debug)
126 return; // we do not want to listen to objects
127 }
128
129 list names = llParseString2List(name,[" "],[]);
130 string firstname = llList2String(names,0);
131 string lastname = llList2String(names,1);
132
133 requestid = llHTTPRequest("http://www.personalityforge.com/api/chat"
134 + "?apiKey=" + llEscapeURL(apiKey)
135 + "&message=" + llEscapeURL(message)
136 + "&chatBotID=" + llEscapeURL(chatBotID)
137 + "&externalID=" + llEscapeURL(firstname)
138 + "&firstName=" + llEscapeURL(firstname)
139 + "&lastName=" + llEscapeURL(lastname)
140 ,[HTTP_METHOD,"GET"],"");
141
142 llSleep(llFrand(3)+2); // think for two to five seconds before we type - for realism
143
144 starttime = llGetUnixTime();
145 vector vspeaker = llList2Vector(what,1);
146 rotation rdelta = llRotBetween( llGetPos(), vspeaker );
147
148 rotation newRot = rdelta * llGetRot();
149 //-- rotate the offset to be relative to npc rotation - vector now points to speaker
150
151 osNpcSetRot(npcKey,newRot); // * = add for quats
152
153 osNpcPlayAnimation(npcKey,"type");
154 llSetTimerEvent(10); // for safety in case web site is down.
155 }
156
157 timer()
158 {
159 osNpcStopAnimation(npcKey,"type");
161 }
162
163 http_response(key request_id, integer status, list metadata, string body)
164 {
165 DEBUG(body);
166 // typical body:
167 // Checking origin: '71.252.253.290' (regex: '71\.252\.253\.290')<br>Matched!<br>{"success":1,"errorMessage":"","message":{"chatBotName":"Liddora","chatBotID":"754","message":"Look up. It's Liddora. So how have you been lately, hello?","emotion":"asking"}}
168
169 if(request_id == requestid)
170 {
171 llSetTimerEvent(0); // shut off the error handler
172
173 // get the name of the bot from the reponse
174 integer botname = llSubStringIndex(body,"chatBotName");
175 string namestr = llGetSubString(body,botname,-1);
176 integer botnameend = llSubStringIndex(namestr,"\",\"");
177
178 string botName = llGetSubString(namestr,14, botnameend-1);
179 DEBUG("Bot Name:" + (string) botName);
180
181 integer begin = llSubStringIndex(body, "message\":\"");
182 string msg = llGetSubString(body, begin +10, -1);
183 integer msgend = llSubStringIndex(msg, "emotion");
184 string reply = llGetSubString(msg, 0, msgend-4);
185 DEBUG("reponse:" + reply);
186
187 // change the name in the reply to the bots real name.
188 DEBUG("reply:" + reply);
189 DEBUG("botName:" + botName);
190 DEBUG("npcName:" + npcName);
191
192
193 reply = strReplace(reply,botName,npcName);
194
195 DEBUG("after nameswap:" + reply);
196 DEBUG("Len:" + llStringLength(reply));
197 // calculate how long it would take for a person to type the answer in cps or wpm
198 float delay = (float) llStringLength(reply) / cps;
199 delay -= llGetUnixTime() - starttime ; // subtract how long it has taken to look up the bots answer since we started typing.
200 if(delay > 0) {
201 DEBUG("delay:" + (string) delay);
202 llSleep(delay) ; // fake out the delay that happens when an avatar is typing an answer
203 }
204
205
206 // Emotion Logic - speak on a chat channel what emotional stste the bot is in, for other scripts to use.
207 string emotion = llGetSubString(msg, msgend,-1);
208 DEBUG((string) emotion);
209
210 msgend = llSubStringIndex(emotion, "\"}");
211 emotion = llGetSubString(emotion, 10,msgend-1);
212 DEBUG("Emotion:" + (string) emotion);
213
214 // sends a link animate to prim animator, attempts to play an animation
215 // normal, happy, angry, averse, sad, evil, fuming,
216 // hurt, surprised, insulted, confused, amused, asking.
217
218 llMessageLinked(LINK_SET,1,emotion,"");
219
220 // and also chats it on channel "emotionchannel" for external gadgetry to respond with.
221 llSay(emotionchannel,emotion); // for controlling external gadgets based on emotes
222
223 osNpcStopAnimation(npcKey,"type");
224
225 // emotional state output
226
227 // you can override the built-in emotion by adding an animation
228 // with any of the following names to the inventory
229 // normal, happy, angry, averse, sad, evil, fuming,
230 // hurt, surprised, insulted, confused, amused, asking.
231
233 DEBUG("Playing animation from inventory named " + emotion);
234 osNpcPlayAnimation(npcKey,emotion);
235 } else {
236 integer index = llListFindList(gAnimations,[emotion]);
237 if(index != -1) {
238 string toPlay = llList2String(gAnimations,index + 1);
239 DEBUG("Playing built-in animation named " + toPlay);
240 osNpcPlayAnimation(npcKey,toPlay);
241 }
242 }
243 osNpcSay(npcKey,reply); // now speak it.
244
245 }
246 }
247 }

ChatBot

NPC for Opensim Chatbot script

Category: ChatBot
By : Ferd Frederix
Created: 2014-08-11 Edited: 2015-08-27
Worlds: OpenSim


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 //integer gToggle = 0;
2 integer gAnimNumber;
3 integer gTotalAnims;
4 integer gTotalAnims2;
5 integer gInList2;
6
7 string gAnimName = "type";
8
9
10 list gAnimations = [ "aim_R_bazooka", "aim_R_handgun", "aim_R_rifle", "angry_fingerwag",
11 "angry_tantrum", "away", "backflip", "blowkiss", "bow", "brush", "clap",
12 "courtbow", "cross_arms", "crouch", "crouchwalk", "curtsy",
13 "dance1", "dance2", "dance3", "dance4", "dance5", "dance6", "dance7", "dance8",
14 "dead", "drink", "express_afraid", "express_anger", "express_bored",
15 "express_cry", "express_embarrased", "express_laugh", "express_repulsed",
16 "express_sad", "express_shrug", "express_surprise", "express_wink",
17 "express_worry", "falldown", "female_walk", "fist_pump", "fly", "flyslow",
18 "hello", "hold_R_bazooka", "hold_R_handgun", "hold_R_rifle",
19 "hold_throw_R", "hover", "hover_down", "hover_up", "impatient",
20 "jump", "jumpforjoy", "kick_roundhouse_R", "kissmybutt", "kneel_left",
21 "kneel_right", "land", "musclebeach", "no_head", "no_unhappy",
22 "nyanya", "peace", "point_me", "point_you", "prejump", "punch_L",
23 "punch_onetwo", "punch_R", "RPS_countdown" ];
24
25 list gAnimations2 = [ "RPS_paper", "RPS_rock",
26 "RPS_scissors", "run", "salute", "shout", "sit", "sit_ground", "sit_to_stand",
27 "sleep", "slowwalk", "smoke_idle", "smoke_inhale", "smoke_throw_down",
28 "snapshot", "soft_land", "stand", "standup", "stand_1", "stand_2",
29 "stand_3", "stand_4", "stretch", "stride", "surf", "sword_strike_R",
30 "talk", "throw_R", "tryon_shirt", "turnback_180", "turnleft", "turnright",
31 "turn_180", "type", "uphillwalk", "walk", "whisper", "whistle", "wink_hollywood", "yell",
32 "yes_happy", "yes_head", "yoga_float" ];
33
34 default {
35 state_entry() {
36 //llSay(0, "Init...");
38 gTotalAnims = llGetListLength(gAnimations);
39 gTotalAnims2 = llGetListLength(gAnimations2);
40 gAnimNumber = -1;
41 gInList2 = FALSE;
42 llListen(0, "", llGetOwner(), "");
43 }
44
45 on_rez(integer param) {
46 llGiveInventory(llGetOwner(), "Animation Names");
48 }
49
50 listen(integer channel, string name, key id, string mesg) {
51 string preamble = llGetSubString(mesg, 0, 3);
52 if(preamble != "anim" && preamble != "stop")
53 return;
54
56
57 if( !(perm & PERMISSION_TRIGGER_ANIMATION)) {
59 return;
60 }
61
62 list parsed = llParseString2List(mesg, [ " " ], []);
63 //llSay(0, (string)parsed);
64
65 string anim = llList2String(parsed, 1);
66
67 if(preamble == "stop") {
68 //llSay(0, "Stopping: " + llGetAnimation(llGetOwner()));
70 if(anim == "")
71 anim = gAnimName;
72
73 if(anim == "all") {
74 integer i;
75 llSay(0, "Stoping");
76 for (i=0; i<gTotalAnims; i++)
77 llStopAnimation(llList2String(gAnimations, i));
78
79 for (i=0; i<gTotalAnims2; i++)
80 llStopAnimation(llList2String(gAnimations2, i));
81
82 llSay(0, "Done.");
83
84 return;
85 }
86
87 //llSay(0, "Stopping: " + anim);
88 llStopAnimation(anim);
89 return;
90 }
91
92 gAnimName = anim;
93 //llSay(0, "Animation: " + gAnimName);
94 llStartAnimation(gAnimName);
95 }
96
98 //llStopAnimation(gAnimName);
99 //gToggle = 0;
100 }
101
102 attach(key id) {
104
105 if(id != NULL_KEY) {
106
109 }
110 }
111 else {
112
114 llStopAnimation(gAnimName);
115 }
116 }
117 }
118
119 touch_start(integer total_number) {
121 return;
122
124
126 if(gAnimNumber != -1) {
127 if(gInList2)
128 llStopAnimation( llList2String(gAnimations2, gAnimNumber) );
129 else
130 llStopAnimation( llList2String(gAnimations, gAnimNumber) );
131 }
132
133
134 gAnimNumber++;
135
136 if(gInList2) {
137 if(gAnimNumber == gTotalAnims2) {
138 gAnimNumber = 0;
139 gInList2 = FALSE;
140 }
141 }
142 else {
143 if(gAnimNumber == gTotalAnims) {
144 gAnimNumber = 0;
145 gInList2 = TRUE;
146 }
147 }
148
149 if(gInList2)
150 gAnimName = llList2String(gAnimations2, gAnimNumber);
151 else
152 gAnimName = llList2String(gAnimations, gAnimNumber);
153
154 llStartAnimation( gAnimName );
155 llSay(0, "Animation: " + gAnimName);
156 }
157 else {
159 }
160 }
161 }

Back to the Best Free Tools in Second Life and OpenSim.