thedominance Posted June 27, 2011 Share Posted June 27, 2011 (edited) Hey all, I'm new to these forums and need some help!My IRCbot project has a few flaws already.- multi-line IRC data seems to get packed in one variable (I need one line in the variable, could use a split and needs more work) - Looks like data is missingHere is the main function.expandcollapse popupFunc MainLoop() ; Start The TCP Services ;============================================== TCPStartup() ; Connect to a server ;============================================== $IRCSock = TCPConnect(TCPNameToIP($cfg_server), $cfg_port) ; If the Socket creation fails, exit. If $IRCSock = -1 Then Exit ; Send User and Nick info, so the IRC server knows who you are IRCSend("USER " & $cfg_ident & " 8 * :" & $cfg_realname) IRCSend("NICK " & $cfg_nick) While 1 ; Try to receive 2048 bytes of data ;---------------------------------------------------------------- $recv = TCPRecv($IRCSock, 2048) ; If the receive failed with @error then the socket has disconnected ;---------------------------------------------------------------- If @error Then ExitLoop ; Check if there is some data, then show it. And if it is any usefull, use it! ;---------------------------------------------------------------- If $recv <> "" Then ConsoleWrite("[IN]: " & $recv) If StringLeft($recv, 6) = "PING :" Then IRCSend("PONG :" & StringRight($recv, 6)) EndIf EndIf WEnd TCPShutdown() EndFunc ;==>MainLoopBut when I run it, it doesn't seem to get it first Ping? Pong! event.[OUT]: USER hhh 8 * :ohlawd [OUT]: NICK pooppenis [IN]: :some.irc.server NOTICE AUTH :*** Looking up your hostname... :some.irc.server NOTICE AUTH :*** Found your hostname (cached) [IN]: ERROR :Closing Link: [111.111.111.111] (Ping timeout) +>AutoIT3.exe ended.rc:0While this should happen:-> USER hhh 9 * :ohlawd -> NICK pooppenis <- :some.irc.server NOTICE AUTH :*** Looking up your hostname... <- :some.irc.server NOTICE AUTH :*** Found your hostname (cached) <- PING :2E9F0472 -> PONG :2E9F0472 <- :some.irc.server 001 pooppenis :Welcome to the SomeNet IRC Network pooppenis!hhh@cool.hostname.comSo, why does '$recv = TCPRecv($IRCSock, 2048)' sometimes put those 2 lines in the same variable?And why doesn't it receive the incoming PING :ASFSDDF?// Thanks, The DominanceAlso, if this code inspired you or you just want to use/steal it, go ahead. Edited June 27, 2011 by thedominance Link to comment Share on other sites More sharing options...
thedominance Posted June 27, 2011 Author Share Posted June 27, 2011 (edited) OK, the Ping Pong is fixed because - An IRC message should have a CRLF behind it - I should have used 'StringTrimLeft' to remove the 'PING :' If StringLeft($recv, 6) = "PING :" Then IRCSend("PONG :" & StringTrimLeft($recv, 6)) Edited June 27, 2011 by thedominance Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now