/* / IRC Announcer edited by Tengu / Load it: / /load -rs announcer.mrc / and follow the directions. / Edit the script file */ on *:LOAD:{ set %tbs_ia_port $$?="Enter the port you want this script to listen: " set %tbs_announce_chan $$?="Enter announce channel name (#channel): " } on *:CONNECT: { if ( $portfree( %tbs_ia_port ) ) { socklisten tbs_ia %tbs_ia_port } else { echo 4Port %tbs_ia_port is not free! Listener not started! } } on *:DISCONNECT: { sockclose tbs_ia } on *:SOCKLISTEN:tbs_ia: { echo -a $time 4*7*8* 3SiTENAME Connection:2 $sockname - 14incoming connection ;--- $sockname stands for the name of the socket, i.e. tbs_ia sockaccept tbs_ia_inc $+ $rand(100,999) $+ $ticks ;--- This will accept the incoming connection on port %tbs_ia_port, ;--- and will name the connection tbs_ia1-999. It can be any number ;--- from 100 to 999. Some people, including myself, like to use $ticks ;--- in the socket name, as its highly unlikely the script will even ;--- try to accept the connection under a sockname that already ;--- exists (as compared to $rand). Even better, I use a combination: ;--- sockaccept blah $+ $rand(100,999) $+ $ticks. } on *:SOCKREAD:tbs_ia_inc*: { unset %tbs_announce if ($sockerr > 0) return ;---The $sockerr identifier will only return a number greater than 0 when an error has occured in the connection. :nextread sockread %temp ;---reads the data coming from the socket if ($sockbr == 0) return ;---$sockbr returns the number of bytes read by the sockread command. Its a good way to check if you actually read anything ;---if i've read all the data, stop if (%temp == $null) %temp = - set %tbs_announce %tbs_announce %temp ;---if there was stuff received from the socket, then echo it goto nextread } on *:SOCKCLOSE:tbs_ia_inc*: { echo -a $time 4*7*8* 3SiTENAME Connection:6 $sockname - 14closed connection msg %tbs_announce_chan %tbs_announce unset %tbs_announce }