mIRC Home    About    Download    Register    News    Help

Print Thread
#155192 04/08/06 06:18 AM
Joined: May 2006
Posts: 122
J
jizzy Offline OP
Vogon poet
OP Offline
Vogon poet
J
Joined: May 2006
Posts: 122
I am currently working on a socket bot for mirc. I am using the end of motd reply to tell when the bot is connected and ready to send msg's but Im not 100% sure if all ircds return this. So is there better way to tell when the connection has been established?


If only women came with popup menus and online help.
Joined: May 2005
Posts: 449
Fjord artisan
Offline
Fjord artisan
Joined: May 2005
Posts: 449
You can tell you're connected when you get a ping from the server. You'll get something like "PING <hexadecimal number here>".

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
The easiest way to detect when you are connected is to use RAW 001 (to 004).

RAW 001:*: echo -s Now connected


Quote:

Raw 001
-------
Format : 001 :Welcome to the Internet Relay Network <nickname>
Example: 001 :Welcome to the Internet Relay Network Gemini
Network: All

Parameters
----------
<nickname> Your nickname.

Info
----
Sent to all clients once a connection has been established and the user has successfully registered.

Notes
-----
This is the first point where a script or client can be sure that the user's connection has been accepted without errors or problems.

This reply is sent once upon connection automatically, and never again during an IRC session.

Variations
----------
On many networks (such as DALnet) the user's full address will be given instead of just a nickname, for example-

001 :Welcome to the Internet Relay Network Gemini!zodiac@port123.stupid.com

Also, many networks change the message itself to include the network's name in the message, for example-

001 :Welcome to the DALnet IRC Network pai!goddess@21.9.234.32

You cannot be guaranteed that the network name or user's nickname/address will always be in the same position.

See Also
--------
The following are sent in sequence on connection-

001, 002, 003, 004



-genius_at_work

Joined: Dec 2005
Posts: 58
S
Babel fish
Offline
Babel fish
S
Joined: Dec 2005
Posts: 58
it connects with socket you cant use mirc's events you must take with if then else.. but explanation is good.


i like that
Joined: Jul 2006
Posts: 53
O
Babel fish
Offline
Babel fish
O
Joined: Jul 2006
Posts: 53
just as an example...

Code:
on *:sockread:bot*: {
  sockread %blah
  tokenize 32 %blah
  window @socketinfo
  echo @socketinfo %blah
  var %_ntoks = $numtok($1-,44)
  if (%_ntoks == 2 &amp;&amp; $1,$3 isnum) {
    sockwrite -n $sockname $3 , $1 : USERID : UNIX : SocketBot 
  }
  if ($1 == PING &amp;&amp; $2) { sockwrite -n $sockname PONG $2- 
  }
  if ($2 == 376) { echo -a SocketBot Successfully Connected... 
  } 
}


Link Copied to Clipboard