Sign in to follow this  
Followers 0
program builder

I want to build a chat bot

11 posts in this topic

#1 ·  Posted (edited)

is it possible to set key words, that when you type something

it picks up on sertain words, and runs command, instead

of every word having to be written in exact order?

Edited by program builder

Share this post


Link to post
Share on other sites

Have a look at StringInStr

Share this post


Link to post
Share on other sites

If u meant to use a word as a hotkey, search in the forum "HotStrings.au3"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here is the code that I have. however I would like it to work like a search engine.

lets say i have 10,000 key words. I would like to be able to pick the best responce

compared to what order the words were written in.

I know this is kinda off the subject, but whenever the person puts in there responce,

and presses enter, I am going to set a winwaitactive that when sertain messages pop

up it will leave sertain comments back. Lets say message 1 says hey you, which it does

below. then it will hold that thought. then when they type another message it holds that

thought. lets say they say the bot askes them if they are a christian, and they say yes

then it holds that thought, later in the conversation they say i and smoke and pot in the

same sentience. The bot would say something like. Why do you smoke pot, if you are a

christian. However it comes out one word at a time, and the message comes out right below.

where you are typing in a chat box. if I programed this just right, and gave it like all of the

differnt ways that it could say each word, meaning like for one set of things it says by, or see ya,

or time for me to split, or goodbye, and each differn't thing was programed for each word that

comes out, do you think that it would sound as human like as possible? anyways here is the

code that I got, however I don't want to have to wright the exact words, for it to send messages.

while 1

$1 = "hi"

$text = InputBox("Instant Message", "You are chatting with molly")

If @error = 1 Then

exit

endif

If $text = $1 then

MsgBox(4096, "Message 1", "hey you")

exit

endif

wend

Edited by program builder

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Depending on the chat client you want to code for... but yes you can write a bot of this sort to reply to trigger keywords

Pls see ChatLion by Random667, an auto responder for a 3rd party Yahoo Chat client called YahELite. Its fairly straightforwards. You might start with this and improve upon it over time.

Edited by Gargy

01000001 01110101 01110100 01101111 01001001 01110100 00100000
An immortal object must be copied, so that we get a mortal copy of it, since we try not to destroy immortal objects.

Share this post


Link to post
Share on other sites

All I am asking, is if there is a way to program a word, that if that word shows up, then it sends saying. Exampe. I have the word good setup as one off the words. and someone says good for you. The bot would still say. It's good I know. but yet if the words that, and good was set up, then both words would have to be put in. someone would say something like that was good. and it would say, do you really think that was good. any help would be appreciated. Thanks.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Putting your post in center format is kind of annoying, and makes it harder to read than it is. Also, use [ code] [ /code] around your script data.

I think this script you want would require AI. Hmm,

Edited by Alienware

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

well.. you can possibly do something like this, all a-to-z and space key etc.:

hotkeyset("a","functionA")

func a()
hotkeyset("a")
send("a")
$inputString&="a"
hotkeyset("a","functionA")
checkString()
endfunc

then have a function to go through all the set hot key phrases, something like this,

$inputString=""
$trigger=0
$string="Search word"
func checkString()
if NOT StringCompare($inputString,$string) THEN
$trigger=1
else 
if StringInStr($string,$inputString)==1 THEN
$trigger=0
else
$trigger=-1
$inputString=""
endif
endif
endfunc

and finally check for $trigger flag to be set to call a function to send the required message.

You can implement this for more than one input strings and check for phrases instead of words and use that information to respond accordingly.

This can also be easily modified to look for words in strings.

Edited by ankitstr

[topic="80940"] AutoScript Creator, Script to automate anything![/topic]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

;How would I change the code below to whenever I type in who+any other caracters it still sends the message that gets sent if you type just who?

#include <WindowsConstants.au3>

#include <EditConstants.au3>

#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", "hi dude", "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 "who", "", "", ""

_WriteBack("I don't know who, but I will tell you if I ever learn., " & @Username)

GuiCtrlSetData($ChatInput, "")

Case Else

_WriteBack("Why?")

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 program builder

Share this post


Link to post
Share on other sites

bump

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

;How would I change the code below to whenever I type in who+any other caracters it still sends the message that gets sent if you type just who?

bump

Assuming that your native languages isn't English, like me, but do you really think this question would be understandable for anybody?

(oh, and better think before you start typing a reply to me because the next stages is "indefinitely")

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0