Sign in to follow this  
Followers 0
WhiteTiger

[udf] _ircconnect

5 posts in this topic

#1 ·  Posted (edited)

udf to connect to an IRC server

just made this for my irc-bot , but this might be usefull for some other peepz :-)

you only need to fil in server but you can fill in a load more shit

if there are peepz who like it then i shall write a better instructon , and uh , hf :-)

Func _ircconnect($server,$port=6667,$name="WhiteTigerUDF",$chan="#autoit",$flag=false)
    if $server = "" then Return -1
    TCPStartup()
    $con = TCPConnect(TCPNameToIP($server),$port)
    if $con = -1 then Return -2
    $send1 = TCPSend($con,"NICK "&$name &@CRLF)
    if $send1 = 0 then Return -3
    do
        $recv = TCPRecv($con,1024)
    until $recv <> ""
    if StringInStr($recv,"PING :") then 
    $lijn = StringSplit($recv,@CR)
    $lijn = StringReplace($lijn[2],"PING :","PONG :")
    msgbox(0,"",$lijn)
    tcpsend($con,$lijn &@CRLF)
    endif 
    tcpsend($con,"USER "&$name&" 0 0 "&$name&@crlf)
    do
        $recv = TCPRecv($con,1024)
    until $recv <> ""
    if StringInStr($recv,"PING :") then 
        $lijn = StringSplit($recv,@CR)
        $lijn = StringReplace($lijn[2],"PING :","PONG :")
        if StringInStr($lijn,@lf) then StringReplace($lijn,@lf,"")
        if StringInStr($lijn,@cr) then StringReplace($lijn,@cr,"")
        if StringInStr($lijn,@crlf) then StringReplace($lijn,@crlf,"")
        if stringinstr($lijn,asc(10)) then StringReplace($lijn,asc(10),"")
        $lijn = StringStripCR($lijn)
        $lijn = StringStripWS($lijn,1)
        tcpsend($con,$lijn &@CRLF)
endif 
tcpsend($con,"JOIN "&$chan &@CRLF)
do 
    $recv = TCPRecv($con,1024)
until $recv <> ""
if $flag = 1 then Return $con &@CRLF &$recv
if $flag = "" or $flag = 0 then Return $con

EndFunc
Edited by WhiteTiger

Share this post


Link to post
Share on other sites



no need for the Ifs just declare it like this

Func _ircconnect($server,$port = 6667,$name = "IrcConnectByWhiteTiger",$chan = "#WhiteTiger",$flag = False)

Share this post


Link to post
Share on other sites

thnx :-) , i shall edit it ^^ but do you like the idea of the udf ? :">

Share this post


Link to post
Share on other sites

Nice, I made an IRC Bot, I update it periodically. Ill post my text decipher for the send commands .

Func _CleanText ( $text )
    Local $ret[3]
    $ret[0] = StringTrimLeft ( StringLeft ( $text, StringInStr ( $text, "!" )-1), 1)
    $chantext = StringTrimLeft ( $text, StringInStr ( $text, "PRIVMSG" )+7)
    $ret[1] = StringTrimRight ( $chantext, StringLen ( $chantext ) - StringInStr ( $chantext, ":" )+ 2)
    $ret[2] = StringTrimLeft ( StringTrimLeft ( $text, StringInStr ( $text, "PRIVMSG" )), StringInStr ( StringTrimLeft ( $text, StringInStr ( $text, "PRIVMSG" )), ":"))
    Return $ret
EndFunc

[0] = User

[1] = Channel

[2] = Text

Share this post


Link to post
Share on other sites

Nice, I made an IRC Bot, I update it periodically. Ill post my text decipher for the send commands .

Func _CleanText ( $text )
    Local $ret[3]
    $ret[0] = StringTrimLeft ( StringLeft ( $text, StringInStr ( $text, "!" )-1), 1)
    $chantext = StringTrimLeft ( $text, StringInStr ( $text, "PRIVMSG" )+7)
    $ret[1] = StringTrimRight ( $chantext, StringLen ( $chantext ) - StringInStr ( $chantext, ":" )+ 2)
    $ret[2] = StringTrimLeft ( StringTrimLeft ( $text, StringInStr ( $text, "PRIVMSG" )), StringInStr ( StringTrimLeft ( $text, StringInStr ( $text, "PRIVMSG" )), ":"))
    Return $ret
EndFunc

[0] = User

[1] = Channel

[2] = Text

good reply :-) i will add more functions but at the moment of writing i dont have much time ;)

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