Jump to content

My New Irc Client


Recommended Posts

okeoke the code might be a bit messy, but most of it works. The reason its in the support forum, is because i have a problem :)

Normealy it should place the message it gets, in the correct edit control in the correct tab. But it doesn't do that.

so does anyone knows why ??

and are # chars allowed in variable names ??

; Zirc Client v0.8
; Made by zeroZshadow
;
; Do not change or sell without permission.

opt("GuiOnEventMode",1)

global $server = "irc.rizon.net"
global $port = 6667
global $nickname = "Basher"
global $message
global $text

$GUI = GuiCreate("Zero Irc V0.8",500,520)
$INPUT = GuiCtrlCreateInput("",0,500,450,20)
$GO = GUICtrlCreateButton("Send",450,500,50,20)
$tab=GUICtrlCreateTab (0,0, 500,500)
$servertab=GUICtrlCreateTabItem("Server")
$SERVEREDIT = GuiCtrlCreateEdit("",3,25,491,470)
GUISetOnEvent(-3,"OnAutoItExit")
GUICtrlSetOnEvent($GO,"_Send")
GuiSetState()

TCPStartup ()
$ip = TCPNameToIP($server)

$socket = TCPConnect( $ip, $port)
If $socket = -1 Then
    MsgBox(49,"Error","Could not connect")
    Exit
EndIf
GuiCtrlSetData($SERVEREDIT,"Connected"&@CRLF)

TCPSend($socket, " NICK" & " " & $nickname & @CRLF)
TCPSend ($socket,"USER martijn_g 0 0 martijn_g" & @CRLF)
_Response()
_JoinChannel("#ZeroIRC")

while 1
    _Response()
WEnd

Func _Response()
    $response = 0
    while $response = 0
        $message = tcpRecv($socket,512000)
        if not $message = "" then 
            FileWrite("c:\log.txt",$message)
        ;If StringinStr($message,'VERSION') Then
        ;   TCPSend($socket,"Zirc v0.5 by zeroZshadow"&@CRLF)
        ;EndIf
            If StringinStr($message,'PING') Then
                TCPSend($socket,StringReplace ( $message, "PING", "PONG")&@CRLF)
            EndIf
            If StringinStr($message,'PRIVMSG') Then
            ;:RizonMon!rizon@rizon.monitor PRIVMSG Basher :VERSION
                $REST = StringSplit ($message," ")
                $nameraw = Stringsplit($REST[1],"!")
                $name = StringTrimLeft($nameraw[1],1)
                if not stringinstr($REST[3],"#") Then
                    $toname = $REST[3]
                    if not IsDeclared ($name) and not Eval($name)="" then _private($name)
                    $privmsg = $REST[4]
                    $result = "<" & $name & "> " & $privmsg
                    GuiCtrlSetData(Eval($name&"EDIT"),$result&@CR)
                else
                    $fromchannel = $rest[3]
                    $privmsg = $REST[4]
                    $result = "<" & $name & "> " & $privmsg
                    $result = GuiCtrlRead(Eval($fromchannel&"EDIT"))&$result
                    GuiCtrlSetData(Eval($fromchannel&"EDIT"),$result&@CR)
                endif
            EndIf
        $result = GuiCtrlRead($SERVEREDIT)&$message
        GuiCtrlSetData($SERVEREDIT,$result&@CR)
        $response = 1
        endif
    WEnd
EndFunc

Func _Send()
    $send = GuiCtrlRead($INPUT)
    TCPSend ($socket,$send & @CRLF)
    If StringinStr($send,'PRIVMSG') Then
            ;:RizonMon!rizon@rizon.monitor PRIVMSG Basher :VERSION
                $REST = StringSplit ($send," ")
                $nameraw = Stringsplit($REST[1],"!")
                $name = StringTrimLeft($nameraw[1],1)
                if not stringinstr($REST[3],"#") Then
                    $toname = $REST[3]
                    if not IsDeclared ($name) and not Eval($name)="" then _private($name)
                    $privmsg = $REST[4]
                    $result = "<" & $name & "> " & $privmsg
                    GuiCtrlSetData(Eval($name&"EDIT"),$result&@CR)
                else
                    $fromchannel = $rest[3]
                    $privmsg = $REST[4]
                    $result = "<" & $name & "> " & $privmsg
                    $result = GuiCtrlRead(Eval($fromchannel&"EDIT"))&$result
                    GuiCtrlSetData(Eval($fromchannel&"EDIT"),$result&@CR)
                endif
            EndIf
EndFunc

Func OnAutoItExit()
    TCPSend($socket,"QUIT :Zirc V0.6 by zeroZshadow"& @CRLF)
    exit
EndFunc

Func _JoinChannel($channel)
    TCPSend ($socket,"JOIN " & $channel & @CRLF)
    TCPSend ($socket,"JOIN " & $channel & @CRLF)
    Assign ( $channel,GUICtrlCreateTabItem($channel),6)
    Assign ( $channel&"EDIT",GuiCtrlCreateEdit("",3,25,491,470),6)
    msgbox(0,"debug",$channel&"EDIT")
endfunc

Func _private($channel)
    Assign ( $channel,GUICtrlCreateTabItem($channel),6)
    Assign ( $channel&"EDIT",GuiCtrlCreateEdit("",3,25,491,470),6)
endfunc

please do not use this as your own work.

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

couldn't connect to the server.

Anyhow IMHO I dont like the way that if it doesnt connect it just exits regardless of what you click.

So how about a retry option?

TCPStartup ()
$ip = TCPNameToIP($server)

$socket = TCPConnect( $ip, $port)

While $socket = -1
    $retry = MsgBox(53,"Error","Could not connect")
    If $retry = 2 then Exit
        For $i = 1 to 10;10 attempts
            $socket = TCPConnect( $ip, $port)
            If $socket <> -1 then exitloop
                Sleep (200)
            Next
Wend
GuiCtrlSetData($SERVEREDIT,"Connected"&@CRLF)

Instead of your if -1 then exit

Link to comment
Share on other sites

Same here but looks nice :)

--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

Link to comment
Share on other sites

strange, because it connects just fine here -.-

but still, how do i fix the problem with the tabs ??

Edited by zeroZshadow
*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

maby u should try another server.

or open your firewall.

but for my question, are # signs allowed ??

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

If I create a variable called $Ch#ris then it doesn't work and I get errors so in answer to your question no you can not use the #chr in a variable name.

And I turned my firewall off and couldn't connect

Edited by ChrisL
Link to comment
Share on other sites

thanks man, it'll make a small change then.

i'll report when it'll work

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
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
 Share

  • Recently Browsing   0 members

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