Jump to content

Autoit Chatbot (Project Live 0.1)


Recommended Posts

Hello good friends of Autoit, so I was looking around the Internet for a Autoit chatbot and saw few examples so I took my time to make a simple coded script called Project Live. The project is also open source so everyone can create their own versions. This bot has a feature which allows him to learn (but it's a little limited) Below is the code.

NOTE: the code below required the required files to work!! download is at the bottom.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>

$ReatIni4Count = IniRead(@ScriptDir & "\config.ini","Configuration","Count","default")
$FormName = "Project Live 0.1"
$Count = $ReatIni4Count
$ReatData = ""
$TalkStatus = "false"

HotKeySet("{ESC}","ESC")

Loader()

Func Loader()
    Global $Form = GUICreate($FormName, 421, 279, 192, 124)
    Global $Output = GUICtrlCreateEdit("", 8, 8, 401, 225, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL))
    Global $Input = GUICtrlCreateInput("Hello", 104, 240, 209, 21)
    $_GreetingsRan = Random(1,4)
    $_GreetingsFileReadLine = FileReadLine(@scriptdir & "\database\_greetings.txt",$_GreetingsRan)
    GUICtrlSetData($output,">> " & $_GreetingsFileReadLine)
    GUISetState(@SW_SHOW)
    ControlFocus($Formname,"",$input)
    HotKeySet("{ENTER}","SendText")
    Main()
EndFunc

func Main()
    HotKeySet("{ENTER}","SendText")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                IniWrite(@ScriptDIr & "\config.ini","Configuration","Count",$Count)
                IniWrite(@scriptdir & "\config.ini","Configuration","PreviousInput","")
                Exit
        EndSwitch
    WEnd
EndFunc


Func SendText()
    global $ReatInput = GUICtrlRead($Input)
    FileWrite(@ScriptDIr & "\data.txt",$ReatInput)
    FileWriteLine(@ScriptDIr & "\data.txt","")
    $Count += 1
    $ReatData = FileReadLine(@ScriptDir & "\data.txt",$Count)
    Check()
EndFunc

Func Check()
    global $Ran1_3 = Random(1,4)
    global $Ran1_4 = Random(1,5)
    global $Ran1_5 = Random(1,6)
    global $Ran1_6 = Random(1,7)
    global $Ran1_7 = Random(1,8)
    global $Ran1_8 = Random(1,9)
    global $Ran1_9 = Random(1,10)
    global $Ran1_10 = Random(1,11)
    global $Ran1_11 = Random(1,12)
    global $Ran1_12 = Random(1,13)
    global $Ran1_13 = Random(1,14)
    global $Ran1_14 = Random(1,15)
    global $Ran1_15 = Random(1,16)
    global $Ran1_16 = Random(1,17)
    global $Ran1_17 = Random(1,18)
    global $Ran1_18 = Random(1,19)
    $CheckForPreviousInput = IniRead(@ScriptDir & "\config.ini","Configuration","PreviousInput","default")
    If $CheckForPreviousInput = $ReatData then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\_PreviousInput.txt",$Ran1_5)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    IniWrite(@ScriptDIr & "\config.ini","Configuration","PreviousInput",$ReatData)

;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"woah") or StringInStr($ReatData,"amazing") or StringInStr($ReatData,"incredible") or StringInStr($ReatData,"unbelievable") or StringInStr($ReatData,"stunning") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\woah.txt",$Ran1_5)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"your name") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\yourname.txt",$Ran1_5)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"are you") Then
        If StringInStr($ReatData,"who are you") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\whoareyou.txt",$Ran1_11)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
            ClearInputBox()
        EndIf
        If StringInStr($ReatData,"how are you") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\howareyou.txt",$Ran1_9)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
            ClearInputBox()
        EndIf
        If StringInStr($ReatData,"when are you") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\whenareyou.txt",$Ran1_5)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
            ClearInputBox()
        EndIf
        If StringInStr($ReatData,"why are you") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\whyareyou.txt",$Ran1_7)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
            ClearInputBox()
        EndIf
        If StringInStr($ReatData,"where are you") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\whereareyou.txt",$Ran1_7)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
            ClearInputBox()
        EndIf
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\areyou.txt",$Ran1_10)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"my name is") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\mynameis.txt",$Ran1_13)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"yes") or StringInStr($ReatData,"okay") or StringInStr($ReatData,"yep") or StringInStr($ReatData,"agree") or StringInStr($ReatData,"yea") or StringInStr($ReatInput,"ok") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\yes.txt",$Ran1_8)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"good") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\good.txt",$Ran1_7)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"fine") Then
        If StringInStr($ReatData,"doing fine") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\doingfine.txt",$Ran1_3)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
            ClearInputBox()
        EndIf
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\fine.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"who am I") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\whoami.txt",$Ran1_8)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"do you think") Then
        If StringInStr($ReatData,"what do you think about") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\whatdoyouthinkabout.txt",$Ran1_6)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
        ClearInputBox()
        EndIf
        If StringInStr($ReatData,"who do you think") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\whodoyouthink.txt",$Ran1_11)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ClearInputBox()
        EndIf
        If StringInStr($ReatData,"who do you think about") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\whodoyouthinkabout.txt",$Ran1_6)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ClearInputBox()
        EndIf
        If StringInStr($ReatData,"where do you think") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\wheredoyouthink.txt",$Ran1_15)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
        ClearInputBox()
        EndIf
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\doyouthink.txt",$Ran1_7)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"hello") or StringInStr($ReatData,"hi") or StringInStr($ReatData,"hey") or StringInStr($ReatData,"greetings") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\hello.txt",$Ran1_8)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"talk") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\talk.txt",$Ran1_7)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"where do you live") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\wheredoyoulive.txt",$Ran1_5)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"do you know") Then
        If StringInStr($ReatData,"who do you know about") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\whodoyouknowabout.txt",$Ran1_5)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
            ClearInputBox()
        EndIf
        if StringInStr($ReatData,"what do you know about ") Then
            global $BrainStrInStr = stringright($ReatInput,stringlen($ReatInput) - stringlen("what do you know about ") - StringInStr($ReatInput,"what do you know about ") + 1)
            If FileExists(@scriptdir & "\brain\" & $BrainStrInStr & ".ini") Then
                $ReatBrain1 = IniRead(@scriptdir & "\brain\" & $BrainStrInStr & ".ini","Brain","response","default")
                $BrainRan = Random(1,5)
                $ReatBrain2 = FileReadLine(@ScriptDir & "\database\_ILearntThis.txt",$BrainRan)
                GUICtrlSetData($Output,">> " & $ReatBrain2 & $ReatBrain1)
                If $TalkStatus = "true" then
                    ControlDisable($Formname,"",$Input)
                    $SpeakText = $ReatBrain2 & $ReatBrain1
                    Local $o_speech = ObjCreate("SAPI.SpVoice")
                    $o_speech.Speak($SpeakText)
                    $o_speech = ""
                    ControlEnable($Formname,"",$Input)
                    ClearInputBox()
                EndIf
                ClearInputBox()
            EndIf
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\_NoUnderstand1.txt",$Ran1_5)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            ClearInputBox()
        EndIf
        If StringInStr($ReatData,"what do you know about") Then
            $ReatDatabase = FileReadLine(@ScriptDir & "\database\whatdoyouknowabout.txt",$Ran1_5)
            GUICtrlSetData($Output,">> " & $ReatDatabase)
            If $TalkStatus = "true" then
                ControlDisable($Formname,"",$Input)
                $SpeakText = $ReatDatabase
                Local $o_speech = ObjCreate("SAPI.SpVoice")
                $o_speech.Speak($SpeakText)
                $o_speech = ""
                ControlEnable($Formname,"",$Input)
            EndIf
            ClearInputBox()
        EndIf
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\doyouknow.txt",$Ran1_7)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"/clear") Then
        GUICtrlSetData($Output,">> ")
        IniWrite(@scriptdir & "\config.ini","Configuration","Count","0")
        FileDelete(@scriptdir & "\data.txt")
        _FileCreate(@scriptdir & "\data.txt")
        Run(@ScriptFullPath)
        Exit
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"bye") or StringInStr($ReatData,"see ya") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\bye.txt",$Ran1_4)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"spanish") or StringInStr($ReatData,"espanol") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\spanish.txt",$Ran1_4)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"universe") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\universe.txt",$Ran1_4)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"thank you") or StringInStr($ReatData,"thanks") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\thankyou.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"robot") or StringInStr($ReatData,"bot") or StringInStr($ReatData,"machine") or StringInStr($ReatData,"computer") or StringInStr($ReatData,"program") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\robot.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"cat") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\cat.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"dog") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\dog.txt",$Ran1_4)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"horse") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\horse.txt",$Ran1_5)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"fuck you") or StringInStr($ReatData,"shit") or StringInStr($ReatData,"asshole") or StringInStr($ReatData,"motherfucker") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\badwords.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"my mother") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\mymother.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"my father") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\myfather.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,"i love you") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\iloveyou.txt",$Ran1_5)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    If StringInStr($ReatData,":D") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\(happyface).txt",$Ran1_5)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        ClearInputBox()
    EndIf
    ;~  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    $ReatDatabase = FileReadLine(@ScriptDir & "\database\_NoUnderstand.txt",$Ran1_10)
    GUICtrlSetData($Output,">> " & $ReatDatabase)
    If $TalkStatus = "true" then
        ControlDisable($Formname,"",$Input)
        $SpeakText = $ReatDatabase
        Local $o_speech = ObjCreate("SAPI.SpVoice")
        $o_speech.Speak($SpeakText)
        $o_speech = ""
        ControlEnable($Formname,"",$Input)
    EndIf
    GUICtrlSetData($Input,"")
    ClearInputBox()
EndFunc

Func ClearInputBox()
    GUICtrlSetData($Input,"")
    Main()
EndFunc

Func _Learn_WhatDoYouKnowAbout()
    $ReatInput = GUICtrlRead($Input)
    GUICtrlSetData($Input,"")
    If StringInStr($ReatInput,"yes") or StringInStr($ReatInput,"okay") or StringInStr($ReatInput,"sure") or StringInStr($ReatInput,"yep") or StringInStr($ReatInput,"yea") or StringInStr($ReatInput,"ok") Then
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\_Learn_WhatAreWeTalkingAbout.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        HotKeySet("{ENTER}","_Learn_WhatDoYouKnowAbout_one")
        while 1
            sleep(100)
        WEnd
    EndIf
    $ReatDatabase = FileReadLine(@ScriptDir & "\database\_Learn_NoLearn.txt",$Ran1_3)
    GUICtrlSetData($Output,">> " & $ReatDatabase)
    If $TalkStatus = "true" then
        ControlDisable($Formname,"",$Input)
        $SpeakText = $ReatDatabase
        Local $o_speech = ObjCreate("SAPI.SpVoice")
        $o_speech.Speak($SpeakText)
        $o_speech = ""
        ControlEnable($Formname,"",$Input)
    EndIf
    ClearInputBox()
EndFunc

func _Learn_WhatDoYouKnowAbout_one()
    $ReatInput = GUICtrlRead($Input)
    GUICtrlSetData($Input,"")
    If StringInStr($ReatInput,"place") Then
        global $BrainCategory = "place"
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\_Learn_GiveMeADescription.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        $SpeakText = $ReatDatabase
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        HotKeySet("{ENTER}","_Learn_WhatDoYouKnowAbout_two")
        while 1
            sleep(100)
        WEnd
    EndIf
    If StringInStr($ReatInput,"thing") Then
        global $BrainCategory = "thing"
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\_Learn_GiveMeADescription.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        $SpeakText = $ReatDatabase
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        HotKeySet("{ENTER}","_Learn_WhatDoYouKnowAbout_two")
        while 1
            sleep(100)
        WEnd
    EndIf
    If StringInStr($ReatInput,"person") Then
        global $BrainCategory = "place"
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\_Learn_GiveMeADescription.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        $SpeakText = $ReatDatabase
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        HotKeySet("{ENTER}","_Learn_WhatDoYouKnowAbout_two")
        while 1
            sleep(100)
        WEnd
    EndIf
    If StringInStr($ReatInput,"animal") Then
        global $BrainCategory = "place"
        $ReatDatabase = FileReadLine(@ScriptDir & "\database\_Learn_GiveMeADescription.txt",$Ran1_3)
        GUICtrlSetData($Output,">> " & $ReatDatabase)
        $SpeakText = $ReatDatabase
        If $TalkStatus = "true" then
            ControlDisable($Formname,"",$Input)
            $SpeakText = $ReatDatabase
            Local $o_speech = ObjCreate("SAPI.SpVoice")
            $o_speech.Speak($SpeakText)
            $o_speech = ""
            ControlEnable($Formname,"",$Input)
        EndIf
        HotKeySet("{ENTER}","_Learn_WhatDoYouKnowAbout_two")
        while 1
            sleep(100)
        WEnd
    EndIf
    $ReatDatabase = FileReadLine(@ScriptDir & "\database\_Learn_NoLearn_NoUnderstand.txt",$Ran1_3)
    GUICtrlSetData($Output,">> " & $ReatDatabase)
    If $TalkStatus = "true" then
        ControlDisable($Formname,"",$Input)
        $SpeakText = $ReatDatabase
        Local $o_speech = ObjCreate("SAPI.SpVoice")
        $o_speech.Speak($SpeakText)
        $o_speech = ""
        ControlEnable($Formname,"",$Input)
    EndIf
    ClearInputBox()
EndFunc

func _Learn_WhatDoYouKnowAbout_two()
    $ReatInput = GUICtrlRead($Input)
    GUICtrlSetData($Input,"")
    $BrainDescription = $ReatInput
    $ReatDatabase = FileReadLine(@ScriptDir & "\database\_Learn_IWillRemember.txt",$Ran1_5)
    GUICtrlSetData($Output,">> " & $ReatDatabase)
    IniWrite(@scriptdir & "\brain\" & $BrainStrInStr & ".ini","Brain","response",$BrainDescription)
    IniWrite(@scriptdir & "\brain\" & $BrainStrInStr & ".ini","Brain","category",$BrainCategory)
    ClearInputBox()
EndFunc

func ESC()
    Exit
EndFunc

[You can use this commands]

/clear [Reset configuration files, use if bot is crazy]

what do you know about ANYTHINGHERE [This command is to teach the bot something, the bot will respond "I don't know, would you like to teach me?", say yes, then the bot will ask you what is it (a place, person, animal or thing) you say what it is then you give a brief CORRECT description and the bot will save the data in "@scriptdir\brain\<WORDLEARNED>" you can check in "@Scriptdir\<WORDLEARNED>" and edit the ini files to fix a false or incorrect word description. If you need any help just respond.]

ALSO: you can make the bot talk by changing the variable "$TalkStatus = "false"" to "$TalkStatus = "true""

Please give me suggestions to improve my project (which I'm obsessed about). Thank you good friends!

Project Live.rar

Edited by TheNewHunter

Hello.

If in someway I have helped, please consider liking my post(s).

The formula for the right answer: You + Right Question = Answer

(Think) BEFORE you post.

Link to comment
Share on other sites

I'm gonna be adding another feature: the bot's face which will move his lips when he talks ($TalkStatus must be "true").

Hello.

If in someway I have helped, please consider liking my post(s).

The formula for the right answer: You + Right Question = Answer

(Think) BEFORE you post.

Link to comment
Share on other sites

I'm making a newer version, a smarter and less complicated (simple) and with a nice editing gui, I'll soon release it. I wrote this chatbot on "ugly code" so I recommend you to wait for the new version which is very simple. The new version will feature emotions such as angry, happy, sad ect.

Hello.

If in someway I have helped, please consider liking my post(s).

The formula for the right answer: You + Right Question = Answer

(Think) BEFORE you post.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...