JustinReno Posted July 5, 2007 Share Posted July 5, 2007 First, I'm using Autochat Bot by James Brooks. I'm trying to edit it in adding new functions. This is a weird situation, the author is still learning about possibilities so I cant ask him. And the topic wasnt in the general support forum. First, here is the code (edited for more functionality)#cs Name: AutoChat Bot Author: James Brooks Version: 0.01#ce#include <GUIConstants.au3>#include <Array.au3>#include <Misc.au3>$GUI = GUICreate("AutoChat Bot :: James Brooks", 458, 330, -1, -1)GUISetBkColor(0xC0DCC0)$ChatText = GUICtrlCreateEdit("", 0, 0, 457, 297, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL))$ChatInput = GUICtrlCreateInput("", 0, 304, 369, 21)$Send = GUICtrlCreateButton("&Send", 376, 304, 81, 25, 0)GUICtrlSetState($ChatInput,$GUI_FOCUS) ; AUTOMATICALLY FOCUSSES ON THE INPUTGUISetState(@SW_SHOW)While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Send, $ChatInput ; PRESS ENTER WHILE IN THE INPUT BOX TO SEND THE MESSAGE $string = StringSplit(GuiCtrlRead($ChatInput), Chr(44)) Switch $String[1] Case "Hey", "Hi", "Howdy", "Hello" _WriteBack("Hello, " & @Username) GuiCtrlSetData($ChatInput, "") Case "How are you?" _WriteBack(" I'm alright. What about yourself?") GuiCtrlSetData($ChatInput, "") Case "What have you been up to?", "What you upto?", "What are you doing?" _WriteBack("Nothin, just talkin to people") GuiCtrlSetData($ChatInput, "") Case "I am not too good!", "I am not good" _WriteBack("How come?") GuiCtrlSetData($ChatInput, "") Case "I cannot tell you!", "I dont want to say!" _WriteBack("OK, but you just remember I cannot tell anyone else!") GuiCtrlSetData($ChatInput, "") Case "newfunc" _writeback("loading...") _newfunc GuiCtrlSetData($ChatInput, "") Case Else _WriteBack("I do not understand you. Please try adding that sentence to my brainbank!") GuiCtrlSetData($ChatInput, "") EndSwitch EndSwitchWEndFunc _WriteBack($text) GUICtrlSetData($ChatText, $text & @crlf, GUICtrlRead($ChatInput))EndFuncFunc _newfunc($text) So far, the _newfunc is unfinished. This is what I want _newfunc to doI already got to the point were when the user types in "newfunc", the script will ask for what the user wants to add to the "brain". The user can put phrases, words, whatever. Then ask the user how the chatbot should reply. Then it will write that to an ini file (or create one and write to it) the phrase, word, whatever and the reply in which ever time the application starts it checks for that file and reads the data and when the user types the new data (how are you?) it will reply. I know this might not make sense but any help is appreciated Link to comment Share on other sites More sharing options...
enaiman Posted July 5, 2007 Share Posted July 5, 2007 I really doubt that you will be satisfied by how your bot will work (just to give you an example ... instead of "How are you?" someone will type "How r u?"... and then your bot won't understand ...) but ... you asked for help and here is your answer: Write an ini file where to put the questions and answers in the following format: question=answer "question" will be the key name "answer" will be the key value Anytime an user asks something you will have to search all the ini file to find if it is already there and to read/return the value read from that key. The problems I see? Very soon the ini file will have a huge number of entries and the search wil take longer and longer. Even a minor difference like "?" not being used ... or anything else - will create a new key and it will become frustrating in the end. Anyway - I'm not here to judge other's work but to help if I can and to give advices. Good luck ........ or Good Luck! or Good Luck, SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
BananaFredSoft Posted July 6, 2007 Share Posted July 6, 2007 Maybe use StringLower so that it won't matter whether they capitalize their words or not. Oh, and you could also add "Sup" and "Wussup" -ColinSite:www.bananafredsoft.comStuff:Simple Text Editor - MediaPlayer - Animator - BananaDB - BananaNotes - Chatta - Filesearch - Excuse GeneratorMy YouTube channel:http://www.youtube.com/user/colipat Link to comment Share on other sites More sharing options...
tAKTelapis Posted July 6, 2007 Share Posted July 6, 2007 Enaiman makes a very good point. Using SQLite instead of an INI file could speed up the process a fair bit. having your bot only give one answer, say: "I am a computer, i do not have feelings" is a much more reasonable approach. Also, whenever a bot is questioned, and it does not know the answer, have it say "i do not know how to answer that, please provide a suggestion" on the upshot, the ini file will not accept multiple Key names (it might, over multiple sections), so once the answer for one question is set ie: "How r u?" then that is the answer the bot stays with. To circumvent such things, i would suggestion checking each individual word of a chat against a basic dictionary (no meanings, just words) if a user says: How r u? the bot can say, "i do not recognize your English, please use full words" the user can then respond: How are you? just be sure to strip extra characters where needed, such as commas and fullstops. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now