Sign in to follow this  
Followers 0
phew

StringRegExp()

4 posts in this topic

Hi,

i read the F1 helpfile for StringRegExp() but actually i didn't really understand it , so

Func doFUNKY($text1) 
    If (StringRegExp($text1, "353 (.*?) (.*?) (.*?) :(.*?)", 0) = 1) Then
        IniWrite("TEST.ini", "NAMES", "", "")
        IniWriteSection("TEST.ini", "NAMES", $text1)
    EndIf
EndFunc

i am trying to grab the names from a irc server (raw 353) reply

the packet i receive from the server is following:

<- :mediatraffic2.fi.quakenet.org 353 MYNICK @ #CHANNEL :MYNICK @NICK1 @NICK2 @NICK3 @NICK4 @NICK5 @ @NICK6
<- :mediatraffic2.fi.quakenet.org 366 MYNICK #CHANNEL :End of /NAMES list.

where MYNICK stands for my current nickname (e.g: phew)
NICK1 = eg: MichaelJackson
NICK2 = ...
NICK6 = eg: TBH|Neo^

#CHANNEL = eg: #help

i guess my function is completely wrong, so anyone can gimme an example perhaps?

Share this post


Link to post
Share on other sites



ok i'll try it

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

now i tried following:

Global $recv = ""
Global $file = "stringrcv.txt"
Func getNames($socket, $recv)
While (1)
    $recv = TCPRecv($socket, 1024)
    If ($recv <> "") Then
            $test = StringInStr($recv, "353")
            MsgBox(1, "", $test)
            ExitLoop
        Else 
            ContinueLoop
        EndIf
 WEnd
EndFunc

after i pressed the "JOIN" button and the bot joins a channel i wait for $recv to receive the server's packet and then i want to msgbox it's content but i only msgbox StringInStr() value instead of the line matching my "353"-string:

StringInStr ( "string", "substring" [, casesense [, occurrence]] )

Return Value

Success: Returns the position of the substring. 
Failure: Returns 0 if substring not found. 
@Error 0 - Normal operation 
 1 - Occurrence was 0. Occurrence must be a positive or negative integer.

but how do i msgbox the packet that matched string "353" in it's content?

EDIT: error in expression :)

Edited by phew

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