Jump to content

AutoChat Bot


James
 Share

Recommended Posts

Hey,

I made a small example chat bot. Basically, it uses the same principles as i542's command interpreter but used slighlty differently.

#cs
    Name: AutoChat Bot
    Author: James Brooks
    Version: 0.01
#ce

#include <GUIConstants.au3>
#include <Array.au3>
#include <Misc.au3>

Global $BrainBank = @ScriptDir & '\brain\bw.ini'

Global $Brain[10]
$Brain[0] = "Hello"
$Brain[1] = @UserName
$Brain[2] = "Goodbye"
$Brain[3] = "How are you, " & $Brain[1] & "?"
$Brain[4] = "I am"
$Brain[5] = "How have you been?"
$Brain[6] = "I have been"
$Brain[7] = "Please"
$Brain[8] = "Thankyou"
$Brain[9] = "What have you been upto?"

Global $Active[3]
$Active[0] = "Not alot"
$Active[1] = "I have been doing some random things!"
$Active[2] = "Nothing. I have been so bored!"

Global $Emotion[6]
$Emotion[0] = "bad"
$Emotion[1] = "OK"
$Emotion[2] = "medioka"
$Emotion[3] = "great"
$Emotion[4] = "not too good"
$Emotion[5] = "brilliant"

$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 INPUT

GUISetState(@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?"
                        $Random = Random(0, UBound($Emotion)-1, 1)
                        $Result = $Emotion[$Random]
                        _WriteBack($Brain[4] & " " & $Result & ". What about yourself?")
                        GuiCtrlSetData($ChatInput, "")
                    Case "What have you been up to?", "What you upto?"
                        $Random1 = Random(0, UBound($Active)-1, 1)
                        $Result1 = $Active[$Random1]
                        _WriteBack($Brain[6] & " " & $Result1 & $Brain[9])
                        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 Else
                        _WriteBack("I do not understand you. Please try adding that sentence to my brainbank!")
                        GuiCtrlSetData($ChatInput, "")
                EndSwitch
    EndSwitch
WEnd

Func _Brain()
    $DataRead = GuiCtrlRead($ChatInput)
EndFunc

Func _AddWord()
    $NewWord = InputBox("AutoChat Bot", "Please enter a new word for Dillan's brain:")
    $NewReply = InputBox("AutoChat Bot", "Please enter a reply for, " & $NewWord)
    IniWrite($BrainBank, "Words", $NewWord, $NewWord)
    IniWrite($BrainBank, "Reply", $NewReply, $NewReply)
    _WriteBack($NewWord & " " & $NewReply & " have been successfully added to brain")
EndFunc

Func _WriteBack($text)
   GUICtrlSetData($ChatText, $text & @crlf, GUICtrlRead($ChatInput))
EndFunc

Thanks,

James

Edit: I know that not all $Brain is used! Also, thanks to Manadar for some error solving.

Edited by Secure_ICT
Link to comment
Share on other sites

Omg! U created a monster ! :rolleyes: xD J/K

But its cool... You just have to make it more Ai... If i say how are you? Its sais I am bad. What about you.

Then i answers: I am hungry. Its sais that it didnt understand me :rambo:

But, i couldnt have made it anny better myself.

[s]My scripts =)Password protect process (with tray menu lol)Clickous meousDisable ctrl+alt+del and password protect folder...Andous herous lolKp3s security center v.1Click me[/s]Ok... You shouldnt use annyone of them cuz they use alot of memory and contain alot of errors and stuff.. I was a n00b :P Ignore it... And if u for some reason want to use them... Watch out for my realy bad spelling :I

Link to comment
Share on other sites

I changed a bit to make it more userfriendly.

#cs
    Name: AutoChat Bot
    Author: James Brooks
    Version: 0.01
#ce

#include <GUIConstants.au3>
#include <Array.au3>
#include <Misc.au3>

Global $BrainBank = @ScriptDir & '\brain\bw.ini'

Global $Brain[10]
$Brain[0] = "Hello"
$Brain[1] = @UserName
$Brain[2] = "Goodbye"
$Brain[3] = "How are you, " & $Brain[1] & "?"
$Brain[4] = "I am"
$Brain[5] = "How have you been?"
$Brain[6] = "I have been"
$Brain[7] = "Please"
$Brain[8] = "Thankyou"
$Brain[9] = "What have you been upto?"

Global $Active[3]
$Active[0] = "Not alot"
$Active[1] = "I have been doing some random things!"
$Active[2] = "Nothing. I have been so bored!"

Global $Emotion[6]
$Emotion[0] = "bad"
$Emotion[1] = "OK"
$Emotion[2] = "medioka"
$Emotion[3] = "great"
$Emotion[4] = "not too good"
$Emotion[5] = "brilliant"

$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 INPUT

GUISetState(@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" ; PROBLEM SOLVED
                        _WriteBack("Hello, " & @Username)
                        GuiCtrlSetData($ChatInput, "")
                    Case "How are you?"
                        $Random = Random(0, UBound($Emotion)-1, 1)
                        $Result = $Emotion[$Random]
                        _WriteBack($Brain[4] & " " & $Result & ". What about yourself?")
                        GuiCtrlSetData($ChatInput, "")
                    Case "What have you been up to?"
                        $Random1 = Random(0, UBound($Active)-1, 1)
                        $Result1 = $Active[$Random1]
                        _WriteBack($Brain[6] & " " & $Result1 & $Brain[9])
                        GuiCtrlSetData($ChatInput, "")
                    Case "I am not too good!"
                        _WriteBack("How come?")
                        GuiCtrlSetData($ChatInput, "")
                    Case "I cannot tell you!"
                        _WriteBack("OK, but you just remember I cannot tell anyone else!")
                        GuiCtrlSetData($ChatInput, "")
                    Case Else
                        _WriteBack("I do not understand you. Please try adding that sentence to my brainbank!")
                        GuiCtrlSetData($ChatInput, "")
                EndSwitch
    EndSwitch
WEnd

Func _Brain()
    $DataRead = GuiCtrlRead($ChatInput)
EndFunc

Func _AddWord()
    $NewWord = InputBox("AutoChat Bot", "Please enter a new word for Dillan's brain:")
    $NewReply = InputBox("AutoChat Bot", "Please enter a reply for, " & $NewWord)
    IniWrite($BrainBank, "Words", $NewWord, $NewWord)
    IniWrite($BrainBank, "Reply", $NewReply, $NewReply)
    _WriteBack($NewWord & " " & $NewReply & " have been successfully added to brain")
EndFunc

Func _WriteBack($text)
   GUICtrlSetData($ChatText, $text & @crlf, GUICtrlRead($ChatInput))
EndFunc
Edited by Manadar
Link to comment
Share on other sites

  • 1 year later...

I got a error on line 41

"$ChatText=GUICtrlCreateEdit("",0,0,457,297,

BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSSCROLL))

$ChatText=GUICtrlCreateEdit("",0,0,457,297,BitOR(^ERROR

Error: Variable used without being declared

Can someone please help Me.

Thanks :)

Link to comment
Share on other sites

I also created some kinda script a long while ago, just with random words.

$GUI = GUICreate("Sigh,'", 220, 140, -1, -1)
GUICtrlCreateLabel("Typ your text", 10, 10)
$Input1 = GUICtrlCreateInput("<Text here>", 10, 30, 200, 20)
$Button1 = GUICtrlCreateButton("Tell", 10, 60, 60, 25)
GUICtrlCreateLabel("Answer back", 10, 90)
$Input2 = GUICtrlCreateInput("", 10, 110, 200, 20, 2048)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = -3
        Exit
    Case $nMsg = $Button1
        $Read = GUICtrlRead($Input1)
        If StringRight($Read, 1) = "?" Then
            GUICtrlSetData($Input2, _MsgBack2())
        ElseIf StringRight($Read, 1) = "!" Then
            GUICtrlSetData($Input2, _MsgBack3())
        Else
            GUICtrlSetData($Input2, _MsgBack())
        EndIf
    EndSelect
WEnd

Func _MsgBack()
    Local $n_Msg[18]
    $n_Msg[0] = "Hello!"
    $n_Msg[1] = "Don't want to talk right now."
    $n_Msg[2] = "Realy?!"
    $n_Msg[3] = "Oops! Sorry!"
    $n_Msg[4] = "Well, OK!"
    $n_Msg[5] = "Oh, hello again!"
    $n_Msg[6] = "Ye, I know."
    $n_Msg[7] = "Life is hard..."
    $n_Msg[8] = "Talk to your friend about it."
    $n_Msg[9] = "Do I look like I care?"
    $n_Msg[10] = "Tell you parents!"
    $n_Msg[11] = "Tralala LIE!"
    $n_Msg[12] = "Humptie Dumpie!"
    $n_Msg[13] = "How do you feel about it?"
    $n_Msg[14] = "What?"
    $n_Msg[15] = "Whoooohooooo!"
    $n_Msg[16] = "Wanne hear a story?"
    $n_Msg[17] = "I love AutoIt, do you?"
    Return $n_Msg[Random(18)]
EndFunc

Func _MsgBack2()
    Local $n_Msg[11]
    $n_Msg[0] = "I can't answer that question."
    $n_Msg[1] = "Hmmmm... Don't know that one!"
    $n_Msg[2] = "Well, ask you parents."
    $n_Msg[3] = "You already asked that."
    $n_Msg[4] = "What did u do?"
    $n_Msg[5] = "Why you ask me?"
    $n_Msg[6] = "Stop asking questions!"
    $n_Msg[7] = "Yes."
    $n_Msg[8] = "No."
    $n_Msg[9] = "I Fine."
    $n_Msg[10] = "Bad."
    Return $n_Msg[Random(11)]
EndFunc

Func _MsgBack3()
    Local $n_Msg[8]
    $n_Msg[0] = "Stop shouting at me!"
    $n_Msg[1] = "Stop yelling at me!"
    $n_Msg[2] = "I wont answer if you yell at me."
    $n_Msg[3] = "*IGNORE*"
    $n_Msg[4] = "I hate people who shout at me!"
    $n_Msg[5] = "Did I already say, STOP YELLING!"
    $n_Msg[6] = "Can you stop shouting?"
    $n_Msg[7] = "OK!"
    Return $n_Msg[Random(8)]
EndFunc

AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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...