Answering code (kinda, I suck at titles) |
Author: |
Message: |
Jonte135
Junior Member
Posts: 57
– / – /
Joined: Aug 2007
|
O.P. Answering code (kinda, I suck at titles)
I'm pretty new to this kind of coding, but could someone explain to me why this won't work:
jscript code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
//local variables
var sDetector = " ", sResponse = " "; /* sDetector is words to detect, sResponse is words to respond with */
var ofr, ofr1, ofr2, ForReading = 1; /* For reading from file */
ofr = new ActiveXObject("Scripting.FileSystemObject");
ofr1 = ofr.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\text.txt", ForReading); /* Open file "Detecting Words.txt" */
ofr2 = ofr1.ReadAll(); /* Read all file contents */
ofr1.Close(); /* Close the file */
sDetector = ofr2.split("\r\n"); /* Set sDetector to every word, separated by /r/n */
ofr1 = ofr.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\text.txt", ForReading); /* Open file "Responding Words.txt" */
ofr2 = ofr1.ReadAll(); /* Read all file contents */
ofr1.Close(); /* Close the file */
sResponse = ofr2.split("\r\n"); /* Set sResponse to every word, separated by \r\n */
/* 2 */
var sDetector2 = " ", sResponse2 = " "; /* sDetector is words to detect, sResponse is words to respond with */
var ofr2, ofr12, ofr22, ForReading2 = 1; /* For reading from file */
ofr2 = new ActiveXObject("Scripting.FileSystemObject");
ofr12 = ofr2.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\moretext.txt", ForReading); /* Open file "Detecting Words.txt" */
ofr22 = ofr12.ReadAll(); /* Read all file contents */
ofr12.Close(); /* Close the file */
sDetector2 = ofr22.split("\r\n"); /* Set sDetector to every word, separated by /r/n */
ofr12 = ofr2.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\moretext.txt", ForReading); /* Open file "Responding Words.txt" */
ofr22 = ofr12.ReadAll(); /* Read all file contents */
ofr12.Close(); /* Close the file */
sResponse = ofr2.split("\r\n"); /* Set sResponse to every word, separated by \r\n */
/* Respons */
var iCountUp = 0, iCountUpToo = 0;
if (Origin != Messenger.MyName) {
var sParts = Message.split(" ");
while(1) {
if (iCountUp == 10) {
break;
}
while(1) {
if (iCountUpToo == 10) {
break;
}
if (sParts[iCountUp] == sDetector[iCountUpToo] && sParts[iCountUp] == sDetector2[iCountUpToo]) {
ChatWnd.SendMessage(sResponse[Math.round(Math.random()%4)]);
}
iCountUpToo += 1;
}
iCountUp += 1;
}
}
What's I'm/the code is trying to do is that it will first identify a word from a file and see if that's the same as someone sends. If so it will reply. I tried to do so it would reply only if there were two words. Like instead of just "hello" it will reply on "hello mate" etc.
Thank you
|
|
12-09-2008 08:41 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Answering code (kinda, I suck at titles)
It would probably help you if you kept each of the problems/issues regarding the one script in the same thread. You have a bunch of questions with regards to the exact same problem.
|
|
12-09-2008 09:08 PM |
|
|
Jonte135
Junior Member
Posts: 57
– / – /
Joined: Aug 2007
|
O.P. RE: Answering code (kinda, I suck at titles)
Yes I know, I'm sorry about that. But the other topics included another code and no one would look in them if I edited it. I know it's a lame excuse but I won't do it again. From now on I will edit.
|
|
12-10-2008 07:51 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Answering code (kinda, I suck at titles)
Ok so here is what you want my recommendation would be
Instead of having text files have 1 XML file. The structure can be something like this:
xml code: <AutoResponder>
<Word>
<Trigger>hey</Trigger>
<Response>hi</Response>
<!--
Number between 1 - 10
10 being takes precedence over all others
1 being last one selected
-->
<Priority>9</Priority>
</Word>
<Word>
<Trigger>hey mate</Trigger>
<Response>hey mate how are you?</Response>
<Priority>10</Priority>
</Word>
</AutoResponder>
What that would allow you to do is have hey mate take priority over hey so if someone were to say hey mate you would say hey how are you instead of hi.
That would be how I would develop such a feature.
This post was edited on 12-10-2008 at 08:03 PM by matty.
|
|
12-10-2008 08:03 PM |
|
|
Jonte135
Junior Member
Posts: 57
– / – /
Joined: Aug 2007
|
O.P. RE: Answering code (kinda, I suck at titles)
Ok thanks for the response I don't really understand XML yet, is there any good tutorial on how it works?
|
|
12-10-2008 08:10 PM |
|
|
roflmao456
Skinning Contest Winner
Posts: 955 Reputation: 24
30 / /
Joined: Nov 2006
Status: Away
|
RE: Answering code (kinda, I suck at titles)
quote: Originally posted by Jonte135
Ok thanks for the response I don't really understand XML yet, is there any good tutorial on how it works?
Try looking at the ActiveX: Microsoft.XMLDOM
This post was edited on 12-10-2008 at 09:25 PM by roflmao456.
[quote]
Ultimatess6: What a noob mod
|
|
12-10-2008 09:25 PM |
|
|
Jonte135
Junior Member
Posts: 57
– / – /
Joined: Aug 2007
|
O.P. RE: Answering code (kinda, I suck at titles)
Where can I find that?
|
|
12-11-2008 08:48 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Answering code (kinda, I suck at titles)
|
|
12-12-2008 12:41 AM |
|
|
Jonte135
Junior Member
Posts: 57
– / – /
Joined: Aug 2007
|
O.P. RE: Answering code (kinda, I suck at titles)
Thanks Would it be possible to do something like this?
xml code: <AutoResponder>
<Word>
<Trigger>hey</Trigger>
<Response>hi</Response>
<!--
Number between 1 - 10
10 being takes precedence over all others
1 being last one selected
-->
<Priority>9</Priority>
</Word>
<Word>
<Trigger>
hey
hello
hi
yo
</Trigger>
<Response>hey mate how are you?</Response>
<Priority>10</Priority>
</Word>
</AutoResponder>
And it will respond to either hey, hello, hi or yo?
|
|
12-13-2008 09:41 AM |
|
|
Jonte135
Junior Member
Posts: 57
– / – /
Joined: Aug 2007
|
O.P. RE: Answering code (kinda, I suck at titles)
But how do Msg+ scripting work with XML?
|
|
12-19-2008 04:13 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|