Orginal post: https://autohotkey.com/board/topic/29514-ahkliza-talk-to-me-and-i-answer-you/
Code: Select all
; AHKliza! v 0.7 lil script to chat with!
Menu,FileMenu,Add,Clear,Clear
Menu,FileMenu,Add,Save,Save
Menu,FileMenu,Add,Exit,GuiClose
Menu,MenuBar,Add,File,:FileMenu
Menu,MenuBar,Add,About,About
gosub init
Random,,%A_Now%
dlg := "AHKLiza: Hello my Name is AHKLiza. What is your name?`n"
gui, add, edit, r20 w400 vOut ReadOnly hwndOutHWND,%dlg%
Gui, Add, edit, r1 wp vIn
Gui, Add, Button, default w1 h1 hidden gAction!
Gui, Menu, MenuBar
Gui, Show
GuiControl, Focus, In
name := "You"
return
GuiEscape:
GuiClose:
ExitApp
Save:
FileSelectFile,fileName,s16,,Select a name to save your AHKLiza Chat,ChatLog (*.txt)
if (fileName) {
if (fileExist(fileName))
FileDelete,%fileName%
FileAppend,%dlg%,%fileName%
}
return
Clear:
dlg := ""
GuiControl,,Out,%dlg%
return
About:
MsgBox,0,AHKliza,A script to chat with. V 0.7 written by derRaphael
return
Action!:
GuiControlGet, text,, In
tophit := 0
hitcount := 0
line := ""
dlg := dlg name ": " text "`n"
text := RegExReplace(Text,"[^\w ]"," ")
if ((RegExMatch(Text,"i)my name is "))) {
name := substr(text,InStr(text,p := "my name is ") + strlen(p))
p := RegExMatch(name,"iU)(^.+\b)",name)
Answer := "Hello " name "! How are You?"
} else {
loop,parse,kb,`n
{
word := RegExReplace(A_LoopField,"\t.+")
if (RegExMatch(Text,"i)\b" word "\b")) {
p := RegExMatch(A_Loopfield,"\t(\d)\t",hitcount)
if (hitcount>=tophit) {
tophit := hitcount
line := A_LoopField
}
if (hitcount=6)
qcount++
}
}
line := RegExReplace(line,"i)^[a-z ]+\t\d\t") "|"
if !(hitcount)
Line := "I dont get you.|Can you just say it different?|"
. "Talk about something else, please.|No good.|"
. "Why do you say something like that?|"
if (c:=count(line,"|")) {
StringSplit, Answer, line, |
Random,rnd,1,%c%
Answer := Answer%rnd%
tophit := 0
line := ""
}
}
dlg := dlg "AHKLiza" ": " Answer "`n"
GuiControl,,In,
if (qcount=3) {
GuiControl, disable,In
dlg := dlg "AHKLiza: You have been warned. I wont talk to you anymore. :P`n"
SetTimer,rg,-10000
}
GuiControl,,Out,%dlg%
SendMessage, 0x115, 7, 0,, ahk_id %outHWND%
return
rg:
GuiControl,enable,In
dlg := dlg "AHKLiza: Ok, once again. Now Be nice!`n"
qcount := 0
GuiControl,,Out,%dlg%
SendMessage, 0x115, 7, 0,, ahk_id %outHWND%
return
Count(Haystack,Needle)
{
return, (a:=RegExReplace(HayStack,"\Q" Needle "\E",Needle, CountValues)) ? CountValues : 0
}
init:
kb=
(Join`n
Hello 3 How's it going?|Yo what's up?|Yo Yo Yo
Hello you 3 Howdy
Hello you there 3 G'day.
Hello friend 3 Hi Friend!
Goodbye 2 See ya later!|Good day, sir.|Later mang
Goodbye friend 2 Goodbye, friend.
c ya 2 See ya later!
c y 2 See ya later!
cyl8er 2 See ya later!
cy 2 See ya later!
read you 2 See ya later!
How 3 You got me!
How are you 3 I'm not sure|I'm doing fine|Swell, thanks for asking.
How r u 3 I'm not sure|I'm doing fine|Swell, thanks for asking.
How do 3 I don't know|I cannot answer that question
How is 3 I don't know how that is.
fun 2 What exactly is the fun about it!
no fun 2 Tell me why not.
You 2 Does that interest you?
U 2 Does that interest you?
You are 2 Let's not talk about me
name 4 I'm not good with names.
your name 4 Why is my name important?|Do you like my name?
yes 2 Ok, cool!|Fine with me.|Ok.
yo 2 Yeah, baby!
yep 2 I tell ya!
yeah 2 Cool!
no 3 Oh, ok.|Why not?|Oh really?|You seem to be a bit negative.
nope 3 Why not?|Oh really?|You seem to be a bit negative.
no im not 3 Yes You are!
Ok 3 If you say so.|Whatever you say =)|Fine with me.
Aight 3 If you say so.|Whatever you say =)|Fine with me.
Because 3 If you say so.|Whatever you say =)|Fine with me.
Have 3 Have what?
u have 3 I'm not sure if I have that.
have u 3 I'm not sure if I've done that.
you have 3 I'm not sure if I have that.
have you 3 I'm not sure if I've done that.
Doctor 4 I'm no doctor.|What's this about doctors?|Why does everybody think, i am a doctor? I'm not!
Doc 4 I'm no doctor.|What's this about doctors?|Why does everybody think, i am a doctor? I'm not!
Thanks 3 You're welcome!
Why 3 I'm not really sure.|Do you really have to know that?
know why 3 I don't know why.
Maybe 3 Ok.|Whatever you say.|If you say so.|I agree.
Probably 3 Ok.|Whatever you say.|If you say so.|I agree.
Possible 3 Ok.|Whatever you say.|If you say so.|I agree.
Where 4 I really couldn't tell you.
u live 4 Why do you want to know where I live?
u from 4 Why do you want to know where I'm from?
you live 4 Why do you want to know where I live?
you from 4 Why do you want to know where I'm from?
asl 4 None of your business. Lets talk about You.
a/s/l 4 None of your business. Lets talk about You.
What 3 WHAT!!!|I dont think thats a good idea.
Watt 3 WHAT!!!
father 4 Tell me about your family.|I'd like to hear more about your family.
mother 4 Tell me about your family.|I'd like to hear more about your family.
brother 4 Tell me about your family.|I'd like to hear more about your family.
sister 4 Tell me about your family.|I'd like to hear more about your family.
aunt 3 Tell me about your family.|I'd like to hear more about your family.
uncle 3 Tell me about your family.|I'd like to hear more about your family.
god 3 Sorry, I don't know him.|I'm not into religion, sorry.
Like 3 I'm not sure.
do you like 3 I don't know if I like that.|Do you think I like that?
Problem 5 I don't have any problems. I'm here to answer your problems =)
you have 5 I don't have any problems. I'm here to answer your problems =)
I have 5 Please tell me your problem.|I'd like to hear more about your problem.
I 2 Oh do you?|I see.
I am 2 Are you really?|Interesting.
programm 3 Sometimes i feel like a Softwareprogramm.|Me is just a script!
ahk 3 Autohotkey is great! Do you know any better?|I love that language, you too?.|AHK is easy to learn, dont u think?
Autohotkey 3 AHK is cool!|You can do funny things with Autohotkey.|The developer did a great job!
AutoIT 3 AutoIT stinks!|Yeah the sources from Autohotkey.|Who cares for AutoIT?
your developer 3 Check out the ahk forum for that. Wont you?
derRaphael 3 My dad!
)
return