Jump to content

Recommended Posts

Posted (edited)

this is my code for a greeting BOt for a chat room

the BOT run, but have some serious matter lol

multiline of text make the BOT crash

single line of text without " : " also make bot crash

i also want to know how i can use 2 string of text to concatenate into one

as example $a = $b + c$

ok

now the code ( ive find many coded in this forum in many post )

;set empty prevline var used later to check against new text

$prevline = ""

; Begin loop

$l = 0

do

; Read from the chat window bon ca ca compte les lignes the texte dans la room apres avoir mouse clicker sur le main chat

$totallines = ControlCommand($RoomName, "", "RichEdit20A1", "GetLineCount", "")

$currentline = ControlCommand($RoomName, "", "RichEdit20A1", "GetLine", $totallines - 1)

; Check for new text

If $prevline <> $currentline Then

; Store current text for check against new text

$prevline = $currentline

; Write to the LOG FILE

; OPEN the LOG FILE

$file1 = FileOpen(@DesktopDir & "\AnyFileNameHere.txt",1)

FileWriteLine($file1, $currentline & @CRLF)

FileClose($file1)

EndIf

; Get username from chat text

$split = StringSplit($currentline, "*")

$split2 = StringSplit($split[1], ":")

$username = $split2[1]

;test pour voir la variable

;MsgBox(0, "Line TEXT is:", $prevline)

; Get username from chat text

$split = StringSplit($currentline, "*")

$split2 = StringSplit($split[1], ":")

$split3 = StringSplit($split2[2],":")

$username = $split2[1]

$username2 = $split3[1]

;test pour voir la variable

;MsgBox(0, "UserName is", $username2)

;

IF $username = $join Then

; fonctionne pas

;$greetings = $username2 + " : Welcome to the room"

;test pour voir la variable

;MsgBox(0, "UserName is", $greetings)

;test pour voir la variable

;MsgBox(0, "A Droite du :", $username2)

;test pour voir la variable

;MsgBox(0, "toute la lignes astie:", $split)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; open the advert file read it and paste text in the chat room

; $file = FileOpen("Greetings.txt", 0)

; Check if file opened for reading OK

; If $file = -1 Then

; MsgBox(0, "Error", "Unable to open file.")

; Exit

; EndIf

; Read in lines of text until the EOF is reached

;While 1

; $line = FileReadLine($file)

; If @error = -1 Then ExitLoop

;MsgBox(0, "Line read:", $line)

ControlSetText($RoomName, "", "[iD:1042]", $username2 )

;ControlSetText($RoomName, "", "[iD:1042]", " : Welcome to chat room" )

ControlClick($RoomName, "", "[iD:1019]")

;sleep(20000)

; FileClose($file)

; Wend

$prevline = ""

EndIf

; Restart the Do loop

Until $l = 1

i will appreciate any help

thanks you so much

sorry to be newbie lol

Edited by west
Posted (edited)

$a = $b & $c

yes work but why its a carriage return when i paste in the room

Bot : dewidar

,Welcome to the chat room

I want it do

Bot : dewidar ,Welcome to the chat room

Edited by west
Posted (edited)

I think u need this somewhere

$string = StringStripCR($string)

yap ive add at this place

; Get username from chat text

$split = StringSplit($currentline, "*")

$split2 = StringSplit($split[1], ":")

$split3 = StringSplit($split2[2], ":")

$username = $split2[1]

$username2 = StringStripCR($split3[1])

;test pour voir la variable

;MsgBox(0, "UserName is", $username2)

$Greeting_Word = ", Welcome to the chat room"

$Greeting = $username2 & $Greeting_Word

the greetings work perfectly now

but still the same issue with multiple line of text

see

BOT : 121212121

121212

in this example i will got error cause its on 2 lines

error is

$split3 = stringsplit($split2[2], ":"

$split3 = stringsplit(^ERROR

Error : Array variable has incorrect munber of subscripts or subscripts dimmension range exceeded.

every time i got multiple line BOT gor this error

how i can avoid this???? is it because in multine line the second line there is not : caracter?????

thanks you

Edited by west
  • 2 weeks later...
Posted

MMMMM can somebody help me

this script work somewhat fine but its kill the CPU

75% of the CPU is took while its runing

Thanks a lots

Posted

If you're running this in a loop, put a sleep(10) statement immediately after your For, While or Do statement. That'll help on the processor load

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Posted

If you're running this in a loop, put a sleep(10) statement immediately after your For, While or Do statement. That'll help on the processor load

:) ya CPU load is 0% now just add the sleep(10) after the DO statement hehe good tips

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
  • Recently Browsing   0 members

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