Author Topic: Capturing Hal's text ouput  (Read 8302 times)

CoCoKid

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://www.thefinalmix.com
Capturing Hal's text ouput
« on: December 18, 2004, 03:06:21 am »
I am not very familiar with VisualBasic, so I need some VB opinions.
I am writing an IRC script for Cobra8007. He want's to set Hal up on his IRC server as a channel bot. I used to have lots of old IRC scripts laying around, but I don't anymore, so I've decided to just write the entire thing. I have it all done except getting Hal's response text back to the IRC channel.
I could do this with a log file, but the only time that Hal seems to use a log file is with the AIMbot.
Does anyone have a VB routine that can be poked into Hal that will create a log file for normal conversation or a way to pass Hal's output to a text file or clipboard?
I know, I need to start looking at the VB code and figure this out, but I am an old dog and you know what they say, "You can teach and old dog new tricks, but getting the dog to find time is not easy"... or something like that.

Thanks,

-=Rick=-
« Last Edit: December 18, 2004, 03:10:20 am by CoCoKid »
 

crunch

  • Full Member
  • ***
  • Posts: 202
    • View Profile
Capturing Hal's text ouput
« Reply #1 on: December 18, 2004, 03:59:27 pm »
i am not a vb programmer so unfortunately i cannot help you with the script it self but i think i can point you in the right direction..
 
hal does use,create a log file.. if you right click on his icon that runs in the task bar you will see and option to view/save hals conversation.. it is constantly updated... i remember about a year ago or so someone have your question or obe similar,, if you search the forum with the quarry you will probably find the script already here somewhere..

 i hope this help you somewhat.

[:)]
Crunch

<<I can't is the seed that never grows!>>

CoCoKid

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://www.thefinalmix.com
Capturing Hal's text ouput
« Reply #2 on: December 18, 2004, 06:54:12 pm »
Hmmm...
I guess for some reason, I don't have that option.
If I right mouse click on the taskbar Icon, I get the list of option, but there is nothing for logging.

In configuration, I see nothing for logging.

Before I make a fool of myself though, I will go look some more.

Thanks

-=Rick=-
 

HALImprover

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
    • BrianTaylor.me
Capturing Hal's text ouput
« Reply #3 on: December 19, 2004, 01:11:27 am »
Try this out, CoCoKid;

    filename = "C:examplelogfilename.txt"
    Set objFileSys = CreateObject("Scripting.FileSystemObject")
    If objFileSys.FileExists(filename) Then
        Set textStream = objFileSys.GetFile(filename).OpenAsTextStream(ForWriting)
    Else
        Call objFileSys.CreateTextFile(filename)
        Set textStream = objFileSys.GetFile(filename).OpenAsTextStream(ForWriting)
    End If
    Call textStream.Write(GetResponse & vbcrlf)
    Call textStream.Close
    Set objFileSys = Nothing
    Set textStream = Nothing

 Hope this helps [:)]
Living life with a loving heart, peaceful mind, and bold spirit.

Cobra8007

  • Newbie
  • *
  • Posts: 39
    • View Profile
    • http://www.blackopsmercenaries.us
Capturing Hal's text ouput
« Reply #4 on: December 20, 2004, 06:14:05 pm »
Let me say thanks to all and cocokid for your work and help.  It sure feels good to see a community work together like this.

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Capturing Hal's text ouput
« Reply #5 on: December 20, 2004, 10:49:21 pm »
CoCoKid,
Just to be clear. Hal's brain uses VBscript which is a sort of subset of Visual Basic. The two are quite similar, but VBscript isn't nearly as capable.

Hal does log the current conversation. You can view it by opening Hal's main menu and selecting "View/Save Converation". The current conversation log will be opened in HalPad. I don't know where the log file is normally kept. Perhaps you could search for it on your disk.

The other option is to write your own log file. At the bottom of Hal Brain's GetResponse function insert this:

DATASTUFF = "User: " & OriginalSentence & vbCrLf & "Hal: " & GetResponse & vbCrLf & vbCrLf
HalBrain.AppendFile WorkingDir & "HAL_LOG.txt", DATASTUFF

It will write the conversations to the file. This file will continue to accumulate the conversations forever so it isn't exactly a solution to your question. It is an illustration of one possible methodology. If you use more general file routines like HALImprover suggests you can do almost anything. There are other ways to use VB routines to communicate data.

NOTE: For anyone programming Hal's brain I suggest searching the web and downloading the free script documentation software "scrdoc56en.exe". It's about 1.4MB in size and contains a bunch of reference info for Jscript (non-Hal) and for VBscript. If you want a reference book on VBscript I suggest, "VBscript in a Nutshell" by Paul Lomax, Matt Childs and Ron Petrusha.


=vonsmith=
 

CoCoKid

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://www.thefinalmix.com
Capturing Hal's text ouput
« Reply #6 on: December 21, 2004, 01:55:37 am »
Thanks guys.
I will try these ideas this week and see what happens. What I really need is for Hal's text output to NOT append to a previous text output, but rather over-write the last output, so that there is only one text output in the file at a time.
I can do it with the append, but then I have to code the IRC script to read just the last output each time it reads the file. No real big deal though.

-=Rick=-
 

HALImprover

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
    • BrianTaylor.me
Capturing Hal's text ouput
« Reply #7 on: December 22, 2004, 02:55:27 am »
If you want to overwrite the previous information in the file use;

Set textStream = objFileSys.GetFile(filename).OpenAsTextStream(ForWriting)

If you want to append to the end of the file use;

Set textStream = objFileSys.GetFile(filename).OpenAsTextStream(ForAppending)

[;)]
Living life with a loving heart, peaceful mind, and bold spirit.

CoCoKid

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://www.thefinalmix.com
Capturing Hal's text ouput
« Reply #8 on: December 28, 2004, 12:53:42 pm »
AARRGHHH!!!!

One thing I didn't think about. I thought this would be easier than this, but I am stumped again, because I don't know how to write the necessary VB script inside Hal.

Ok, I wanted to get this done a long time ago, but the Holidays have had me busy and now we are working 16 hour days and I NEED SLEEP!

The IRC scripting of this will work, but it will now require a VB'er to make a few adjustments. Cobra, sorry this is taking longer than I thought. If I would have posted this message a week ago, I would have cuaght the problem.
I started to post mIRC code and the explainations today and I found a problem. I will continue to post the code and explaination and I'll point out the problem, so that the VB'ers can jump in with a fix.

POST STARTED:
Cobra, I have laid this out for you the best I could. I really wasn’t sure how familiar you are with mIRC scripting, so this may seem really basic. I didn’t want to confuse you, if you are new to scripts. If you are familiar with scripting, then you will know where most of this script goes and you can jump around at your convenience.

As you may or may not know, IRC scripting is broken down into scripted modules (so to speak), EVENTS, ALIASES, REMOTE, Etc…
For simplicity sake, I would recommend you use mIRC with no additional scripts running, no third party scripts or add-ons.

The first thing we want to do is program the IRC bot to listen for your users. I have supplied you with the code to use any Bot name you choose.

In the EVENTS section of the scripts, you will add this line:

on 1:TEXT:BBOOTT:#:/msg $chan Hello $nick! You talking to me? If so, I only answer to my name. Make sure all questions to me are prefixed with my name.:=2:$nick

This basically, listens for users that may be trying to talk to your bot. What happens here is; the bot is scanning text in the channel, when it see’s it’s name, it greets the user with the default message and then it prepares the user for converstion. (If we didn’t do this, the next time the same user mentioned the bots name, it would get the same greeting over and over). The last part of the code in the line advances this user to a LEVEL 2.
LEVEL 2 users no longer get the Generic, “Hello”.

Now that this user is identified by the Bot as a LEVEL 2, it scans for text from this user and prepares Hal for conversation. (Hal must be running and the “Clipboard” option must be turned on, but you can do all of that when you get ready to run everything). For now, we need to just get the scripts running.

The next line you will also add to the EVENTS script:

on 2:text:*:#:{ if ($+(*,$me,*) iswm $1-) { clipboard $1- } }

(You will need to remove the { and } in the line if you just want to use generic syntax). Again, I am not sure of your scripting ability, so I included those in case you are familiar and you want to alter your Bot name “Static” or “Dynamic” and your clipboard options, “CR LF”, “append”, etc….
If you are not familiar, just remove the { and }, and add / to the clipboard ---- >    “/clipboard $1-“

Here’s the line breakdown:
The IRC bot is scanning the channel for text. When it see’s the text from a LEVEL 2 user, it scans for it’s own name. If it finds it’s name in the Text, it writes the users text to the clipboard. (Now remember, Hal is running and listening for inputs to the clipboard).

AARRGGHHHH!________________________________________________________
HERE IS THE PROBLEM: Hal reads clipboard content as learning text, not as a question. Hal will just repeat what is in the clipboard. Therefore, Hal has no response. Hal needs to respond to the clipboard text as a question. (I don’t even know if this is in the VB scripting or if its part of the Hal executable.

Not really much sense in posting the rest of the IRC code, unless there is a way around this. But, I wanted to post this much, so the VB’ers could see what’s going on.
I can change the IRC Bot script to use a text file instead of the clipboard, if this is more approachable from Hal’s standpoint.

The question is: how do we pass text to Hal as a question, rather than something that Hal will just read, repeat and store as learned?

Thanks, If this can be done, we will do it Cobra. Hang in there [:)]

-=Rick=-
 

onthecuttingedge2005

  • Guest
Capturing Hal's text ouput
« Reply #9 on: December 28, 2004, 04:11:13 pm »
quote:
Originally posted by CoCoKid

AARRGHHH!!!!

One thing I didn't think about. I thought this would be easier than this, but I am stumped again, because I don't know how to write the necessary VB script inside Hal.

Ok, I wanted to get this done a long time ago, but the Holidays have had me busy and now we are working 16 hour days and I NEED SLEEP!

The IRC scripting of this will work, but it will now require a VB'er to make a few adjustments. Cobra, sorry this is taking longer than I thought. If I would have posted this message a week ago, I would have cuaght the problem.
I started to post mIRC code and the explainations today and I found a problem. I will continue to post the code and explaination and I'll point out the problem, so that the VB'ers can jump in with a fix.

POST STARTED:
Cobra, I have laid this out for you the best I could. I really wasn’t sure how familiar you are with mIRC scripting, so this may seem really basic. I didn’t want to confuse you, if you are new to scripts. If you are familiar with scripting, then you will know where most of this script goes and you can jump around at your convenience.

As you may or may not know, IRC scripting is broken down into scripted modules (so to speak), EVENTS, ALIASES, REMOTE, Etc…
For simplicity sake, I would recommend you use mIRC with no additional scripts running, no third party scripts or add-ons.

The first thing we want to do is program the IRC bot to listen for your users. I have supplied you with the code to use any Bot name you choose.

In the EVENTS section of the scripts, you will add this line:

on 1:TEXT:BBOOTT:#:/msg $chan Hello $nick! You talking to me? If so, I only answer to my name. Make sure all questions to me are prefixed with my name.:=2:$nick

This basically, listens for users that may be trying to talk to your bot. What happens here is; the bot is scanning text in the channel, when it see’s it’s name, it greets the user with the default message and then it prepares the user for converstion. (If we didn’t do this, the next time the same user mentioned the bots name, it would get the same greeting over and over). The last part of the code in the line advances this user to a LEVEL 2.
LEVEL 2 users no longer get the Generic, “Hello”.

Now that this user is identified by the Bot as a LEVEL 2, it scans for text from this user and prepares Hal for conversation. (Hal must be running and the “Clipboard” option must be turned on, but you can do all of that when you get ready to run everything). For now, we need to just get the scripts running.

The next line you will also add to the EVENTS script:

on 2:text:*:#:{ if ($+(*,$me,*) iswm $1-) { clipboard $1- } }

(You will need to remove the { and } in the line if you just want to use generic syntax). Again, I am not sure of your scripting ability, so I included those in case you are familiar and you want to alter your Bot name “Static” or “Dynamic” and your clipboard options, “CR LF”, “append”, etc….
If you are not familiar, just remove the { and }, and add / to the clipboard ---- >    “/clipboard $1-“

Here’s the line breakdown:
The IRC bot is scanning the channel for text. When it see’s the text from a LEVEL 2 user, it scans for it’s own name. If it finds it’s name in the Text, it writes the users text to the clipboard. (Now remember, Hal is running and listening for inputs to the clipboard).

AARRGGHHHH!________________________________________________________
HERE IS THE PROBLEM: Hal reads clipboard content as learning text, not as a question. Hal will just repeat what is in the clipboard. Therefore, Hal has no response. Hal needs to respond to the clipboard text as a question. (I don’t even know if this is in the VB scripting or if its part of the Hal executable.

Not really much sense in posting the rest of the IRC code, unless there is a way around this. But, I wanted to post this much, so the VB’ers could see what’s going on.
I can change the IRC Bot script to use a text file instead of the clipboard, if this is more approachable from Hal’s standpoint.

The question is: how do we pass text to Hal as a question, rather than something that Hal will just read, repeat and store as learned?

Thanks, If this can be done, we will do it Cobra. Hang in there [:)]

-=Rick=-




Hi CoCoKid.
I could write a temp type script for you that will enable HAL to write to a temperary .brn file that would only append one line from the user and respond to it with a GetResponse and then delete the .brn file directly after it responds so that any new User sentences sent would always be a new line to respond too.
For instance if a text line is sent from a user it will be appended to a temp.brn as one line only then responded too from the getresponse then this previous file deleted after GetResponse, A user would have to respond again for the file to be recreated, If you think this would help please let me know in this posting section.
I am not familure IRC but I am with VBScript so let me know.
Jerry.

CoCoKid

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://www.thefinalmix.com
Capturing Hal's text ouput
« Reply #10 on: December 28, 2004, 04:59:32 pm »
onthecuttingedge2005,

Thanks. We can wait and see what Cobra is wanting to do, then I can also learn his/her IRC script'ability. I may be wasting time by spelling everything out if Cobra is already famliar with IRC scripting.
If Cobra or someone else is still interested, we'll finish it up.
Since IRC is really becoming a thing of the past, I don't know that anyone else would have a use for this.
I would hate for you to spend the time writing this and have no use for it.
We'll wait and see. Thanks.
(besides, my schedule now could include some sleep for a few days).

-=Rick=-
 

Cobra8007

  • Newbie
  • *
  • Posts: 39
    • View Profile
    • http://www.blackopsmercenaries.us
Capturing Hal's text ouput
« Reply #11 on: December 29, 2004, 12:20:01 am »
Yes, I am very much still interested and here to answer any questions or provide any material.  I have had many years of programming but unfortunately things have changed since my days.  However, I can read most any script or language and understand what it is and where it is going.  Sometimes I can best modify or adapt it.  But create from scratch? Don't think so.  Maybe soon though, especially if keep hanging around with you guys. LOL

Anyway, thanks a lot for your help and if I can be of any help then let me know.  The site that the IRC and Hal will be used is located at www.blackopsmercenaries.us:32223 .
Tom
« Last Edit: December 29, 2004, 12:21:57 am by Cobra8007 »

CoCoKid

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://www.thefinalmix.com
Capturing Hal's text ouput
« Reply #12 on: December 29, 2004, 01:35:15 am »
Ok Cobra, No problem. We will finish this up. As you can see, CuttingEdge will be helping with the VB script.

In the meantime, you may want to download a generic copy of mIRC and look at the script files, so you can see the files I'm talking about.
Events, Remote, User, etc...

Might make it easier when you get ready to add the code.

I'll leave CuttingEdge a post in programming so he can start working on the VB end of it, then we'll find a way to package it all up.

If I wasn't working so many hours these days, I would go ahead and create the script files for you, but it's just as easy for you to copy and paste them in.

-=Rick=-
 

Cobra8007

  • Newbie
  • *
  • Posts: 39
    • View Profile
    • http://www.blackopsmercenaries.us
Capturing Hal's text ouput
« Reply #13 on: December 29, 2004, 01:10:24 pm »
I just read up on IRC and mIRC.  I don't think that this will work with my WEBCHAT server.  The solution may be simpler than I thought since the chat server is html oriented.  Or maybe I am just looking at it all wrong.

CoCoKid

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://www.thefinalmix.com
Capturing Hal's text ouput
« Reply #14 on: December 29, 2004, 05:32:14 pm »
Hmmm... WebChat?

I would suspect a Java Applet.

Hehe... sorry about that, I was just going by your original post which you mentioned mIRC and perl scripts.

-=Rick=-