Waraxe IT Security Portal
Login or Register
November 17, 2024
Menu
Home
Logout
Discussions
Forums
Members List
IRC chat
Tools
Base64 coder
MD5 hash
CRC32 checksum
ROT13 coder
SHA-1 hash
URL-decoder
Sql Char Encoder
Affiliates
y3dips ITsec
Md5 Cracker
User Manuals
AlbumNow
Content
Content
Sections
FAQ
Top
Info
Feedback
Recommend Us
Search
Journal
Your Account
User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144

People Online:
Visitors: 85
Members: 0
Total: 85
Full disclosure
SEC Consult SA-20241112-0 :: Multiple vulnerabilities in Siemens Energy Omnivise T3000 (CVE-2024-38876, CVE-2024-38877, CVE-2024-38878, CVE-2024-38879)
Security issue in the TX Text Control .NET Server for ASP.NET.
SEC Consult SA-20241107-0 :: Multiple Vulnerabilities in HASOMED Elefant and Elefant Software Updater
Unsafe eval() in TestRail CLI
4 vulnerabilities in ibmsecurity
32 vulnerabilities in IBM Security Verify Access
xlibre Xnest security advisory & bugfix releases
APPLE-SA-10-29-2024-1 Safari 18.1
SEC Consult SA-20241030-0 :: Query Filter Injection in Ping Identity PingIDM (formerly known as ForgeRock Identity Management) (CVE-2024-23600)
SEC Consult SA-20241023-0 :: Authenticated Remote Code Execution in Multiple Xerox printers (CVE-2024-6333)
APPLE-SA-10-28-2024-8 visionOS 2.1
APPLE-SA-10-28-2024-7 tvOS 18.1
APPLE-SA-10-28-2024-6 watchOS 11.1
APPLE-SA-10-28-2024-5 macOS Ventura 13.7.1
APPLE-SA-10-28-2024-4 macOS Sonoma 14.7.1
Log in Register Forum FAQ Memberlist Search
IT Security and Insecurity Portal

www.waraxe.us Forum Index -> Perl -> Talk bot
Post new topicReply to topic View previous topic :: View next topic
Talk bot
PostPosted: Sun Dec 21, 2008 6:05 am Reply with quote
oploader
Regular user
Regular user
Joined: Dec 13, 2008
Posts: 17




Hey, Im trying to make a Talk bot...
That joins a IRC Channel..
And responds when people talk.. But i can't get it to work o.O I'm totally nooby at this stuff... Here is the script.

PS: Sorry for putting it in this section. But i made it with Autoit...
And there is no autoit section,

Thanks Very Happy

Code:

#include <guiconstants.au3>
#include <guiedit.au3>
#NoTrayIcon
#Compiler_Icon=brainbreak.ico
#Compiler_Allow_Decompile=n
#Compiler_Res_Comment=Brainbreak
#Compiler_Res_Description=An intelligent chat robot
#Compiler_Res_Fileversion=1.0
#Compiler_Res_LegalCopyright=Philip Bennefall
AutoItSetOption("GUIOnEventMode", 1)
AutoItSetOption("GUICloseOnESC",0)
$eng_weekdays = "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"
$eng_months = "January,February,March,April,May,June,July,August,September,October,November,December"
$eng_weekdays = StringSplit($eng_weekdays,",")
$eng_months = StringSplit($eng_months,",")
$language = ""
$tts = 1
$reason = ""
$shortterm = ""
$requesting_name = 0
$timer = 0
$your_name = ""
$data = ""
$filename = "brain.ini"
$found_phrase = 0
$said = ""
$said_original = ""
$gui = GUICreate("Brainbreak", 784, 550, 186, 113)
GUISetOnEvent($GUI_EVENT_CLOSE,"exit_program")
$edit = GUICtrlCreateEdit("", 80, 72, 569, 377,$ES_READONLY)
GUICtrlCreateLabel("HISTORY:", 16, 232, 63, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
$input = GUICtrlCreateInput("", 104, 24, 449, 21, BitOR($ES_AUTOHSCROLL,$WS_BORDER), $WS_EX_STATICEDGE)
GUICtrlSetState(-1,$GUI_FOCUS)
GUICtrlCreateLabel("Message:", 40, 24, 58, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
GUICtrlCreateButton("&Send", 560, 24, 97, 21, 0)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
GUICtrlSetOnEvent(-1,"analyse_data")
GUISetState()
$ttsvoice = ObjCreate("Sapi.SpVoice")
$error = ObjEvent("AutoIt.Error","error")
start()
While 1
$diff = TimerDiff($timer)
If $diff > 35000 Then
print_answer("autotalk")
$timer = TimerInit()
EndIf
Sleep(1000)
Wend
Func exit_program()
Exit
EndFunc
Func error()
EndFunc
Func start()
$test = scan_ini($filename)
If @Error Then
MsgBox(16,"Error","An error was encountered while trying to load the database." & @CRLF & "Error: " & $reason & "")
Exit
EndIf
$test = scan_language_file()
If @Error Then
MsgBox(16,"Error","An error was encountered while trying to load the language file (" & $language & ".ini)." & @CRLF & "Error: " & $reason & "")
Exit
EndIf
$your_name = RegRead("HKEY_CURRENT_USER\Software\Brainbreak","name")
If @Error Then
print_welcome()
Else
print_remember()
EndIf
EndFunc
Func scan_ini($filename)
$reason = ""
$sections = IniReadSectionNames($filename)
If @error Then
$reason = "Unable to open database."
SetError(1)
Return
EndIf
$found_information = 0
$found_language = 0
$found_welcome = 0
$found_remember = 0
$found_greeting = 0
$found_notfound = 0
$found_phrases = 0
$saved_sections = ""
$saved_keys = ""
For $i1 = 1 To $sections[0]
$current_section = $sections[$i1]
If $current_section = "" Then
SetError(1)
$reason = "Invalid section name." & @CRLF & "Section number: " & $i1 & ""
Return
EndIf
$low_section = StringLower($current_section)
If StringInStr($saved_sections,"#" & $low_section & "#") Then
SetError(1)
$reason = "Two sections with the same name can not be created." & @CRLF & "Section name: " & $current_section & ""
Return
EndIf
$saved_sections = "" & $saved_sections & "#" & $low_section & "#"
If $current_section = "information" Then $found_information = 1
If $current_section = "welcome" Then $found_welcome = 1
If $current_section = "remember" Then $found_remember = 1
If $current_section = "greeting" Then $found_greeting = 1
If $current_section = "notfound" Then $found_notfound = 1
If $current_section = "phrases" Then $found_phrases = 1
$saved_keys = ""
$keys = IniReadSection($filename,$current_section)
If @error Then
$reason = "Unable to find any entries in section." & @CRLF & "Section name: " & $current_section & ""
SetError(1)
Return
EndIf
For $i2 = 1 To $keys[0][0]
$key = "" & $keys[$i2][0] & ""
$value = "" & $keys[$i2][1] & ""
If $key = "" Then
$reason = "Invalid key name in section." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key number: " & $i2 & ""
SetError(1)
Return
EndIf
$first = StringLeft($key,1)
If $first <> "#" Then
$reason = "Invalid key name, # sign is missing." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key number: " & $i2 & ""
SetError(1)
Return
EndIf
$strippedkey = StringTrimLeft($key,1)
If $strippedkey = "" Then
$reason = "Invalid key name, # sign is missing." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key number: " & $i2 & ""
SetError(1)
Return
EndIf
If $value = "" Then
$reason = "Invalid key value in section." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key name: " & $strippedkey & ""
SetError(1)
Return
EndIf
$low_key = StringLower($strippedkey)
If StringInStr($saved_keys,"#" & $low_key & "#") Then
SetError(1)
$reason = "Two keys with the same name can not be created inside the same section." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key name: " & $strippedkey & ""
Return
EndIf
$saved_keys = "" & $saved_keys & "#" & $low_key & "#"

If $current_section = "information" Then
If $key = "#language" Then
$found_language = 1
If FileExists("" & $value & ".ini") Then
$language = $value
Else
MsgBox(16,"Error","The file with the rules for this language could not be found, make sure that the file " & $value & ".ini is located in the same directory as the database you are trying to load.")
Exit
EndIf
EndIf
EndIf
If $current_section <> "information" Then
If $current_section <> "phrases" Then
$strippedkey = StringLower($strippedkey)
If StringInStr($strippedkey,"recall") Then
If Not StringIsDigit($current_section) Then
$reason = "Invalid key name, the word recall may only appear in answer sections, not in custom ones." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key number: " & $i2 & ""
SetError(1)
Return

EndIf
$strippedkey = StringReplace($strippedkey,"recall","",1)
EndIf
If Not StringIsDigit($strippedkey) Then
$reason = "Invalid key name, the name must be a digit, with the exception of the word recall which can be inserted after or before the digit itself. The only sections where normal words can be used as key names are information and phrases." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key number: " & $i2 & ""
SetError(1)
Return
EndIf
EndIf
EndIf
If $current_section = "phrases" Then
If StringIsDigit($value) Then
$test = IniReadSection($filename,$value)
If @error Then
SetError(1)
$reason = "The value of a key in the phrases section refers to an answer section that does either not exist or is empty." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key name: " & $strippedkey & ""
Return
EndIf
Else
SetError(1)
$reason = "A value in the phrases section is something other than a number. All key values in the phrases section must be integers." & @CRLF & "Key name: " & $strippedkey & ""
Return
EndIf
EndIf
Next
Next
If $found_information = 0 Then
SetError(1)
$reason = "A mandatory section is missing. Required sections are information, welcome, remember, greeting, notfound and phrases. Missing section: information"
Return
EndIf
If $found_language = 0 Then
$reason = "A mandatory key is missing in the information section. A language must be specified in order to load language rules for this database."
SetError(1)
Return
EndIf
If $found_welcome = 0 Then
SetError(1)
$reason = "A mandatory section is missing. Required sections are information, welcome, remember, greeting, notfound and phrases. Missing section: welcome"
Return
EndIf
If $found_remember = 0 Then
SetError(1)
$reason = "A mandatory section is missing. Required sections are information, welcome, remember, greeting, notfound and phrases. Missing section: remember"
Return
EndIf
If $found_greeting = 0 Then
SetError(1)
$reason = "A mandatory section is missing. Required sections are information, welcome, remember, greeting, notfound and phrases. Missing section: greeting"
Return
EndIf
If $found_notfound = 0 Then
SetError(1)
$reason = "A mandatory section is missing. Required sections are information, welcome, remember, greeting, notfound and phrases. Missing section: notfound"
Return
EndIf
If $found_phrases = 0 Then
SetError(1)
$reason = "A mandatory section is missing. Required sections are information, welcome, remember, greeting, notfound and phrases. Missing section: phrases"
Return
EndIf
EndFunc
Func scan_language_file()
$found_weekdays = 0
$found_months = 0
$found_opposites = 0
$sections = IniReadSectionNames("" & $language & ".ini")
If @error Then
$reason = "Unable to open language database."
SetError(1)
Return
EndIf
For $i1 = 1 To $sections[0]
$current_section = $sections[$i1]
If $current_section <> "weekdays" Then
If $current_section <> "months" Then
If $current_section <> "opposites" Then
SetError(1)
$reason = "Unknown section name. Allowed sections are weekdays, months and opposites." & @CRLF & "Section number: " & $i1 & ""
Return
EndIf
EndIf
EndIf
If $current_section = "weekdays" Then $found_weekdays = 1
If $current_section = "months" Then $found_months = 1
If $current_section = "opposites" Then $found_opposites = 1
$keys = IniReadSection("" & $language & ".ini",$current_section)
If @error Then
$reason = "Unable to find any entries in section." & @CRLF & "Section name: " & $current_section & ""
SetError(1)
Return
EndIf
$length = $keys[0][0]
If $current_section = "weekdays" Then
If $length <> 7 Then
SetError(1)
$reason = "Invalid number of days in the weekdays section. There are 7 days in a week, not " & $length & "."
Return
EndIf
EndIf
If $current_section = "months" Then
If $length <> 12 Then
SetError(1)
$reason = "Invalid number of months in the months section. There are 12 months in a year, not " & $length & "."
Return
EndIf
EndIf
$current = 0
For $i2 = 1 To $keys[0][0]
$current = $current+1
If $current_section = "weekdays" Then
$array_val = $eng_weekdays[$current]
EndIf
If $current_section = "months" Then
$array_val = $eng_months[$current]
EndIf
$current_key = $keys[$i2][0]
$current_value = $keys[$i2][1]
If $current_key = "" Then
SetError(1)
$reason = "Invalid key name in section." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key number: " & $i2 & ""
Return
EndIf
If $current_value = "" Then
SetError(1)
$reason = "Invalid key value in section." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key name: " & $current_key & ""
Return
EndIf
If $current_section <> "opposites" Then
$lower = StringLower($current_key)
$array_val = StringLower($array_val)
If $array_val <> $lower Then
SetError(1)
$reason = "Wrong key name in section." & @CRLF & "Section name: " & $current_section & "" & @CRLF & "Key number: " & $i2 & "" & @CRLF & "Expected key name is: "
If $current_section = "weekdays" Then
$reason = "" & $reason & "" & $eng_weekdays[$current] & ""
EndIf
If $current_section = "months" Then
$reason = "" & $reason & "" & $eng_months[$current] & ""
EndIf
Return
EndIf
EndIf
Next
Next
If $found_weekdays = 0 Then
SetError(1)
$reason = "A mandatory section is missing. Required sections are weekdays, months and opposites." & @CRLF & "Missing section: weekdays"
Return
EndIf
If $found_months = 0 Then
SetError(1)
$reason = "A mandatory section is missing. Required sections are weekdays, months and opposites." & @CRLF & "Missing section: months"
Return
EndIf
If $found_opposites = 0 Then
SetError(1)
$reason = "A mandatory section is missing. Required sections are weekdays, months and opposites." & @CRLF & "Missing section: opposites"
Return
EndIf
EndFunc
Func analyse_data()
$said_original = ""
$data = GUICtrlRead($input)
If $data = "" Then Return
GUICtrlSetData($input,"")
$test = scan_ini($filename)
If @Error Then
MsgBox(16,"Error","An error was encountered while trying to read from the database." & @CRLF & "Error: " & $reason & "")
Exit
EndIf
$test = scan_language_file()
If @Error Then
MsgBox(16,"Error","An error was encountered while trying to read from the language file (" & $language & ".ini)." & @CRLF & "Error: " & $reason & "")
Exit
EndIf
If $requesting_name = 1 Then
$requesting_name = 0
$temp_name = clean_string($data)
$temp_name = StringSplit($temp_name," ")
$your_name = $temp_name[$temp_name[0]]

RegWrite("HKEY_CURRENT_USER\Software\Brainbreak","name","REG_SZ",$your_name)
$return = print_special_answer("greeting")
If $return = 0 Then
MsgBox(16,"Error","An error occured in the database while trying to find a suitable answer. The file might be corrupt.")
Exit
EndIf
$found_phrase = 0
Return
EndIf
$return = check_for_answer($data)
If $return = 0 Then
MsgBox(16,"Error","An error occured in the database while trying to find a suitable answer. The file might be corrupt.")
Exit
EndIf
If $said <> "" Then
$said_original = $said
$said = replace_opposites($said)
If IsInt($said) Then
MsgBox(16,"Error","An error occured in the language database (" & $language & ".ini) while trying to find entries for opposite words. The file might be corrupt.")
Exit
EndIf
EndIf
$next_return = try_to_recall($data)
If $next_return = 1 Then Return
If $return = 1 Then
print_special_answer("notfound")
Return
EndIf

$return = print_answer($found_phrase)
If $return = 0 Then
MsgBox(16,"Error","An error occured in the database while trying to find a suitable answer. The file might be corrupt.")
Exit
EndIf
EndFunc
Func try_to_recall($text)
$text = StringLower($text)
$text = StringReplace($text,Chr(10),"")
While 1
If StringInStr($text," ") Then
$text = StringReplace($text," "," ")
Else
ExitLoop
EndIf
Wend
$split = StringSplit($text," ")
$words = $split[0]
$current = 0
$new_phrase = ""
While 1
$current = $current+1
If $current > $words Then ExitLoop
$value = $split[$current]
If $value = " " Then ContinueLoop
$value = clean_string($value)
If $value = "" Then ContinueLoop
If $new_phrase = "" Then
$new_phrase = $value
Else
$new_phrase = "" & $new_phrase & " " & $value & ""
EndIf
Wend
$shortsplit = StringSplit($shortterm,Chr(10))
If $shortterm = "" Then
$shortterm = $new_phrase
Return 0
EndIf
$shortterm = "" & $shortterm & "" & Chr(10) & "" & $new_phrase & ""
$length = $shortsplit[0]
$current = 0
$highest_percent = 0
While 1
$current = $current+1
If $current > $length Then ExitLoop
$test_string = $shortsplit[$current]
$percent = compare_strings($new_phrase,$test_string)
If $percent > $highest_percent Then $highest_percent = $percent
Wend
If $highest_percent >= 70 Then
$return = print_answer($found_phrase,1)
If $return = 0 Then
$return = print_answer("recall")
If $return = 0 Then Return 0
EndIf
Return 1
Else
Return 0
EndIf
EndFunc
Func compare_strings($string1,$string2)
$string1split = StringSplit($string1," ")
$length1 = $string1split[0]
$string2split = StringSplit($string2," ")
$length2 = $string2split[0]
$using = 0
If $length1 = $length2 Then $using = 1
If $length2 > $length1 Then $using = 2
If $length1 > $length2 Then $using = 1
$current = 0
$points = 0
While 1
$current = $current+1
If $using = 1 Then
If $current > $length1 Then ExitLoop
$current_word = $string1split[$current]
$testing = StringRegExp($string2,".*\b" & $current_word & "\b.*",3)
If IsArray($testing) Then $points = $points+1
Else
If $current > $length1 Then ExitLoop
$current_word = $string2split[$current]
$testing = StringRegExp($string1,".*\b" & $current_word & "\b.*",3)
If IsArray($testing) Then $points = $points+1
EndIf
Wend
If $using = 1 Then $total = $length1
If $using = 2 Then $total = $length2
If $points = 0 Then Return 0
$percent = $points/$total*100
Return Round($percent)
EndFunc
Func check_for_answer($data)
$longest = 0
$found_phrase = ""
$said = ""
$using_two = 0
$found = 0
$keys = IniReadSection($filename,"phrases")
If @error Then Return
For $i = 1 To $keys[0][0]
$using_two = 0
$found = 0
$key = "" & $keys[$i][0] & ""
$value = "" & $keys[$i][1] & ""
If $key = "" Then Return
If $value = "" Then Return
$first = StringLeft($key,1)
If $first <> "#" Then Return
$key = StringTrimLeft($key,1)
While 1
$char = StringLeft($key,1)
If $char = "*" Then
$key = StringTrimLeft($key,1)
ContinueLoop
EndIf
If $char = " " Then
$key = StringTrimLeft($key,1)
ContinueLoop
EndIf
ExitLoop
Wend
While 1
$char = StringRight($key,1)
If $char = "*" Then
$key = StringTrimRight($key,1)
ContinueLoop
EndIf
If $char = " " Then
$key = StringTrimRight($key,1)
ContinueLoop
EndIf
ExitLoop
Wend
$oldkey = $key
$key = StringReplace($key,"*",".*")
If @Error Then Return
$test = StringRegExp($data,"(?i).*" & $key & "(.*)",3)
If IsArray($test) Then $found = 1
If $found = 0 Then
$test = StringRegExp($data,"(?i).*" & $key & "",3)
$using_two = 1
If IsArray($test) Then $found = 1
$wordtest = StringRegExp($data,"(?i).*\b" & $key & "\b",3)
If Not IsArray($wordtest) Then ContinueLoop
If $found = 0 Then ContinueLoop
EndIf
If $using_two = 0 Then
$last = UBound($test)
$last = $last-1
$extract = $test[$last]
$testchar = StringLeft($extract,1)
If StringIsAlNum($testchar) Then ContinueLoop
$extract = clean_string($extract)
Else
$extract = ""
EndIf
If $extract = "" Then
$test = contains_said($value)
If $test = 0 Then ContinueLoop
EndIf
If $longest = 0 Then
$longest = StringLen($key)
$found_phrase = $value
$said = $extract
Else
$curlength = StringLen($key)
If $curlength < $longest Then ContinueLoop
$longest = StringLen($key)
$found_phrase = $value
$said = $extract
EndIf
Next
If $longest > 0 Then Return 2
Return 1
EndFunc
Func clean_string($raw)
If $raw = "" Then Return ""
$output = ""
$split = StringSplit($raw,"")
For $i = 1 To $split[0]
$char = $split[$i]
If $char = " " Then
If $output = "" Then ContinueLoop
$lastchar = StringRight($output,1)
If $lastchar = " " Then ContinueLoop
EndIf
If $char = "." Then ContinueLoop
If $char = "," Then ContinueLoop
If $char = "!" Then ContinueLoop
If $char = "?" Then ContinueLoop
If $char = ";" Then ContinueLoop
If $char = "(" Then ContinueLoop
If $char = ")" Then ContinueLoop
If $char = """" Then ContinueLoop
If $char = "{" Then ContinueLoop
If $char = "}" Then ContinueLoop
If $char = "[" Then ContinueLoop
If $char = "]" Then ContinueLoop
$output = "" & $output & "" & $char & ""
Next
$lastchar = StringRight($output,1)
If $lastchar = " " Then $output = StringTrimRight($output,1)
Return $output
EndFunc
Func contains_said($phrase_id)
$phrasekeys = IniReadSection($filename,$phrase_id)
If @error Then Return
For $i2 = 1 To $phrasekeys[0][0]
$phrasevalue = "" & $phrasekeys[$i2][1] & ""
If $phrasevalue = "" Then Return
If StringInStr($phrasevalue,"%said%") Then
Else
Return 1
EndIf
Next
EndFunc
Func print_answer($phrase,$recall = 0)
$possible_answers = ""
$phrasekeys = IniReadSection($filename,$phrase)
If @error Then Return
For $i2 = 1 To $phrasekeys[0][0]
$phrasekey = "" & $phrasekeys[$i2][0] & ""
$phrasevalue = "" & $phrasekeys[$i2][1] & ""
If $phrasekey = "" Then Return
If $phrasevalue = "" Then Return
$first = StringLeft($phrasekey,1)
If $first <> "#" Then Return
$phrasekey = StringTrimLeft($phrasekey,1)
If $said = "" Then
If StringInStr($phrasevalue,"%said%") Then ContinueLoop
EndIf
$low_phrasekey = StringLower($phrasekey)
If $recall = 0 Then
If StringInStr($low_phrasekey,"recall") Then ContinueLoop
Else
If Not StringInStr($low_phrasekey,"recall") Then ContinueLoop
EndIf
If $possible_answers = "" Then
$possible_answers = $phrasekey
Else
$possible_answers = "" & $possible_answers & "$" & $phrasekey & ""
EndIf
Next
If $possible_answers = "" Then Return 0
If StringInStr($possible_answers,"$") Then
$split = StringSplit($possible_answers,"$")
$number_of_answers = $split[0]
$answer_id = Random(1,$number_of_answers,1)
$answer_id = $split[$answer_id]
Else
$answer_id = $possible_answers
EndIf
$answer = IniRead($filename,$phrase,"#" & $answer_id & "","")
If StringInStr($answer,"%save_name%") Then
$answer = StringReplace($answer,"%save_name%","")
If $said <> "" Then
$your_name = $said
RegWrite("HKEY_CURRENT_USER\Software\Brainbreak","name","REG_SZ",$your_name)
EndIf
EndIf
$answer = replace_variables($answer)
GUICtrlSetData($edit,"" & GUICtrlRead($edit) & "" & @CRLF & "You: " & $data & "" & @CRLF & "Brainbreak: " & $answer & "")
_GUICtrlEditLineScroll($edit,0,999999999)
speak($answer)
Return 1
EndFunc
Func print_welcome()
$possible_answers = ""
$phrasekeys = IniReadSection($filename,"welcome")
If @error Then Return
For $i2 = 1 To $phrasekeys[0][0]
$phrasekey = "" & $phrasekeys[$i2][0] & ""
$phrasevalue = "" & $phrasekeys[$i2][1] & ""
If $phrasekey = "" Then Return
If $phrasevalue = "" Then Return
$first = StringLeft($phrasekey,1)
If $first <> "#" Then Return
$phrasekey = StringTrimLeft($phrasekey,1)
If $said = "" Then
If StringInStr($phrasevalue,"%said%") Then ContinueLoop
EndIf
If $possible_answers = "" Then
$possible_answers = $phrasekey
Else
$possible_answers = "" & $possible_answers & "$" & $phrasekey & ""
EndIf
Next
If StringInStr($possible_answers,"$") Then
$split = StringSplit($possible_answers,"$")
$number_of_answers = $split[0]
$answer_id = Random(1,$number_of_answers,1)
$answer_id = $split[$answer_id]
Else
$answer_id = $possible_answers
EndIf
$answer = IniRead($filename,"welcome","#" & $answer_id & "","")
$answer = replace_variables($answer)
GUICtrlSetData($edit,"Brainbreak: " & $answer & "")
_GUICtrlEditLineScroll($edit,0,999999999)
speak($answer)
$requesting_name = 1
Return 1
EndFunc
Func print_remember()
$possible_answers = ""
$phrasekeys = IniReadSection($filename,"remember")
If @error Then Return
For $i2 = 1 To $phrasekeys[0][0]
$phrasekey = "" & $phrasekeys[$i2][0] & ""
$phrasevalue = "" & $phrasekeys[$i2][1] & ""
If $phrasekey = "" Then Return
If $phrasevalue = "" Then Return
$first = StringLeft($phrasekey,1)
If $first <> "#" Then Return
$phrasekey = StringTrimLeft($phrasekey,1)
If $said = "" Then
If StringInStr($phrasevalue,"%said%") Then ContinueLoop
EndIf
If $possible_answers = "" Then
$possible_answers = $phrasekey
Else
$possible_answers = "" & $possible_answers & "$" & $phrasekey & ""
EndIf
Next
If StringInStr($possible_answers,"$") Then
$split = StringSplit($possible_answers,"$")
$number_of_answers = $split[0]
$answer_id = Random(1,$number_of_answers,1)
$answer_id = $split[$answer_id]
Else
$answer_id = $possible_answers
EndIf
$answer = IniRead($filename,"remember","#" & $answer_id & "","")
$answer = replace_variables($answer)
GUICtrlSetData($edit,"Brainbreak: " & $answer & "")
_GUICtrlEditLineScroll($edit,0,999999999)
speak($answer)
Return 1
EndFunc
Func print_special_answer($phrase)
$possible_answers = ""
$phrasekeys = IniReadSection($filename,$phrase)
If @error Then Return
For $i2 = 1 To $phrasekeys[0][0]
$phrasekey = "" & $phrasekeys[$i2][0] & ""
$phrasevalue = "" & $phrasekeys[$i2][1] & ""
If $phrasekey = "" Then Return
If $phrasevalue = "" Then Return
$first = StringLeft($phrasekey,1)
If $first <> "#" Then Return
$phrasekey = StringTrimLeft($phrasekey,1)
If $said = "" Then
If StringInStr($phrasevalue,"%said%") Then ContinueLoop
EndIf
If $possible_answers = "" Then
$possible_answers = $phrasekey
Else
$possible_answers = "" & $possible_answers & "$" & $phrasekey & ""
EndIf
Next
If StringInStr($possible_answers,"$") Then
$split = StringSplit($possible_answers,"$")
$number_of_answers = $split[0]
$answer_id = Random(1,$number_of_answers,1)
$answer_id = $split[$answer_id]
Else
$answer_id = $possible_answers
EndIf
$answer = IniRead($filename,$phrase,"#" & $answer_id & "","")
$answer = replace_variables($answer)
GUICtrlSetData($edit,"" & GUICtrlRead($edit) & "" & @CRLF & "You: " & $data & "" & @CRLF & "Brainbreak: " & $answer & "")
_GUICtrlEditLineScroll($edit,0,999999999)
speak($answer)
Return 1
EndFunc
Func replace_variables($var)
$var = StringReplace($var,"%said%",$said)
$var = StringReplace($var,"%said_original%",$said_original)
$var = StringReplace($var,"%your_name%",$your_name)


$var = StringReplace($var,"%year%",@YEAR)
$var = StringReplace($var,"%month_number%",@MON)
$var = StringReplace($var,"%date%",@MDAY)
$var = StringReplace($var,"%hour%",@HOUR)
$var = StringReplace($var,"%minute%",@MIN)
$var = StringReplace($var,"%second%",@SEC)
If StringInStr($var,"%") Then
$first = -1
$second = -1
$current = -1
While 1
$current = $current+2
$first = StringInStr($var,"%",0,$current)
If $first = 0 Then ExitLoop
$currentplus = $current
$currentplus = $currentplus+1
$second = StringInStr($var,"%",0,$currentplus)
If $second = 0 Then ExitLoop
$diff = $second-$first+1
$variable = StringMid($var,$first,$diff)
If $variable = "%%" Then ContinueLoop
$section = StringTrimLeft($variable,1)
$section = StringTrimRight($section,1)
$possible_answers = ""
$phrasekeys = IniReadSection($filename,$section)
If @error Then
$current = $current-1
ContinueLoop
EndIf
If StringIsDigit($section) Then
$current = $current-1
ContinueLoop
EndIf
For $i4 = 1 To $phrasekeys[0][0]
$phrasekey = "" & $phrasekeys[$i4][0] & ""
$phrasevalue = "" & $phrasekeys[$i4][1] & ""
If $phrasekey = "" Then ContinueLoop
If $phrasevalue = "" Then ContinueLoop
$first = StringLeft($phrasekey,1)
If $first <> "#" Then ContinueLoop
$phrasekey = StringTrimLeft($phrasekey,1)
If $possible_answers = "" Then
$possible_answers = $phrasekey
Else
$possible_answers = "" & $possible_answers & "$" & $phrasekey & ""
EndIf
Next
If StringInStr($possible_answers,"$") Then
$split = StringSplit($possible_answers,"$")
$number_of_answers = $split[0]
$answer_id = Random(1,$number_of_answers,1)
$answer_id = $split[$answer_id]
Else
$answer_id = $possible_answers
EndIf
$answer = IniRead($filename,$section,"#" & $answer_id & "","")
$answer = StringReplace($answer,"%said%",$said)
$answer = StringReplace($answer,"%said_original%",$said_original)
$answer = StringReplace($answer,"%your_name%",$your_name)
$answer = StringReplace($answer,"%",chr(10))
$var = StringReplace($var,$variable,$answer)
$current = -1
Wend
EndIf
$var = StringReplace($var,chr(10),"%")
Return $var
EndFunc
Func replace_opposites($txt)
$opposites = IniReadSection("" & $language & ".ini","opposites")
If @Error Then
If FileExists("" & $language & ".ini") Then
$reason = "The file appears to be corrupt."
Else
$reason = "The file does not exist."
EndIf
MsgBox(16,"Error","An error occured while trying to use the set of language rules in the file " & $language & ".ini. " & $reason & "")
Exit
EndIf
$tag = "a<(++)(--)>a"
For $i5 = 1 To $opposites[0][0]
$oppositekey = "" & $opposites[$i5][0] & ""
$oppositevalue = "" & $opposites[$i5][1] & ""
If $oppositekey = "" Then Return
If $oppositevalue = "" Then Return
$txt = StringRegExpReplace($txt,"(?i)\b" & $oppositekey & "\b","" & $tag & "" & $oppositevalue & "" & $tag & "")
Next
$txt = StringReplace($txt,$tag,"")
Return $txt
EndFunc
Func speak($text)
$timer = TimerInit()
If $tts = 0 Then Return
$ttsvoice.Speak($text,3)
EndFunc

Very Happy Very Happy
View user's profile Send private message
PostPosted: Thu Jan 15, 2009 10:45 pm Reply with quote
yeat
Regular user
Regular user
Joined: Jan 16, 2009
Posts: 8
Location: Italy




change language...you must to study perl or PHP Smile autoit is an orrible language because it works just on windows.

regards
View user's profile Send private message MSN Messenger
Talk bot
www.waraxe.us Forum Index -> Perl
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT
Page 1 of 1

Post new topicReply to topic


Powered by phpBB © 2001-2008 phpBB Group



Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2024 Janek Vind "waraxe"
Page Generation: 0.047 Seconds