bnc.txt by slinksi, mirc bnc script (has logging options) alias si { unset %si.* %si.nickname = $$?="nick" %si.ident = $$?="ident" %si.host = $$?="host" return : $+ %si.nickname $+ ! $+ %si.ident $+ @ $+ %si.host $1- } alias parsesock { return $gettok($1,2,46) } alias servlog { if ($window(%serv.name)) aline $iif(%window.wrap == 1,-p,$null) %serv.name $1- if (%serv.log) write %serv.logfile $time $date $1- return } alias serverauth { sw : $+ %server.name NOTICE $snick :WINBNC } alias getsock { if (!$sockname) return real. $+ $gettok($1,1,46) if (bnc isin $sockname) || (sub isin $sockname) return $sock($sockname).mark else return $sockname } alias info { window -e @info 0 0 325 200 if ($sock($1) == $null) { aline $iif(%window.wrap == 1,-p,$null) @info Socket: Not available. (disconnected?) | return } aline $iif(%window.wrap == 1,-p,$null) @info Socket Name: $1 aline $iif(%window.wrap == 1,-p,$null) @info Nickname: $gettok($geth($1,nick),1,58) aline $iif(%window.wrap == 1,-p,$null) @info User: $geth($1,user) aline $iif(%window.wrap == 1,-p,$null) @info Identified Pass: $geth($1,identified) aline $iif(%window.wrap == 1,-p,$null) @info Remote Host: $sock($1).ip aline $iif(%window.wrap == 1,-p,$null) @info Sockmark: $sock($1).mark aline $iif(%window.wrap == 1,-p,$null) @info Server: $sock($ssub($1)).ip $+ : $+ $sock($ssub($1)).port aline $iif(%window.wrap == 1,-p,$null) @info Received/Sent: $sock($ssub($1)).rcvd bytes/ $+ $sock($ssub($1)).sent bytes aline $iif(%window.wrap == 1,-p,$null) @info Channels: $geth($1,channels) aline $iif(%window.wrap == 1,-p,$null) @info Socket Connected: $sock($1).to seconds ( $+ $duration($sock($1).to) $+ ) aline $iif(%window.wrap == 1,-p,$null) @info ---------------------------- } alias listsock return $sock(real*,%listsocks) alias getwin { if (bnc isin $sockname) || (sub isin $sockname) return @ $+ $sock($sockname).mark else return @ $+ $sockname } alias spyon { window -e @ $+ $1 } alias manage { if (!$window(%manage.name)) window -l %manage.name manage.popups if ($1 == -u) { echo -a updating window -c %manage.name window -l %manage.name manage.popups %listsocks = 0 :loop inc %listsocks 1 echo $sock(real*,%listsocks) if ($sock(real*,%listsocks) == $null) goto end aline $iif(%window.wrap == 1,-p,$null) %manage.name $sock(real*,%listsocks) ( $+ $sock($listsock).ip $+ ) goto loop else goto end :end } } alias sw sockwrite -n $sockname $1- alias ssub { if ($sockname == $null) return sub. $+ $gettok($1,2,46) return sub. $+ $sid } alias sid { if (bnc isin $sockname) || (sub isin $sockname) return $gettok($sock($sockname).mark,2,46) return $gettok($sockname,2,46) } alias closesock { if ($2 == -r) { sockwrite -n sub.* QUIT : $+ $3- } sockclose real. $+ $parsesock($1) sockclose sub. $+ $parsesock($1) sockclose bnc. $+ $parse($1) } alias closesocket { %getsock.keep = $getsock %getsock.ip = $sock($getsock).ip sockclose $sock($sockname).mark if ($window(%manage.name)) dline %manage.name $fline(%manage.name,%getsock.keep ( $+ %getsock.ip $+ )) hfree %getsock.keep } alias listsock { %listsock.i = 0 :loop inc %listsock.i 1 if ($hget($1/ $+ %listsock.i $+ ) == $null) goto end echo $hget($1/ $+ %listsock.i $+ ) goto loop else goto end :end } alias sockmotd { unset %sockmotd* %sockmotd.i = 0 :loop inc %sockmotd.i 1 set %sockmotd $read -l $+ %sockmotd.i $2 if ($lines($2) < %sockmotd.i) goto end if (!$2) sockwrite -n $1 %sockmotd else sockwrite -n $1 $3- %sockmotd goto loop else goto end :end } alias sa return $sip $+ . $+ $sid ( $+ $snick $+ / $+ $suser $+ ) $+ $chr(91) $+ $sock($ssub).ip $+ : $+ $sock($ssub).port $+ $chr(93) alias geth { if ($sockname == $null) return $hget($1,$2) if (bnc isin $sockname) return $hget( $+ real. $+ $sock($sockname).mark,$2) if (sub isin $sockname) return $hget($sock($sockname).mark,$2) return $hget($sockname,$2) } alias al if ($window(%bncspy.name)) aline $iif(%window.wrap == 1,-p,$null) %server.window $sa $1- alias rd { if (bnc isin $sockname) hdel real. $+ $sock($sockname).mark $1- else hdel $sockname $1- } alias ad { if (bnc isin $sockname) hadd real. $+ $sock($sockname).mark $1- else hadd $sockname $1- } alias sip return $sock($sockname).ip alias suser return $geth($sockname,user) alias ssnick return $gettok($geth($sockname,nick),1,58) alias snick return $geth($sockname,nick) alias checkconfig { if (!%server.name) %server.name = bnc.com if (!%server.pass) %server.pass = war if (!%bncspy.name) %bncspy.name = @bncspy if (!%server.vhost) %server.vhost = www.fbi.gov if (!%manage.name) %manage.name = @manage if (!%info.name) %info.name = @info if (!%server.passstring) %server.passstring = You need to say /quote PASS password. if (!%server.motdfile) %server.motdfile = motd.txt if (!%serv.name) %serv.name = @serv if (!%serv.log) %serv.log = 1 if (!%serv.logfile) %serv.logfile = servlogfile.txt if (!%server.debug) %server.debug = 0 if (!%window.wrap) %window.wrap = 0 } on 1:start:if (!%bnc.inc) %bnc.inc = 0 | socklisten bnc 4245 | if (!$window(%server.window)) { window -e %server.window } | checkconfig on 1:socklisten:bnc*:{ inc %bnc.inc 1 inc %real.inc 1 set %bnc.real $sockname $+ . $+ %bnc.inc sockaccept %bnc.real sockmark %bnc.real %real.inc hmake -s real. $+ %real.inc } on 1:sockread:bnc*:{ if ($sockerr < 0) return sockread -f %bnc if ($sockbr == 0) return if ($gettok(%bnc,1,32) == USER) { if ($gettok(%bnc,4,32) == $null) return ad user $gettok(%bnc,2-,32) } if ($gettok(%bnc,1,32) == NICK) { if ($gettok(%bnc,2,32) == $null) return ad nick $gettok(%bnc,2-,32) } if ($geth($sockname,user)) && ($geth($sockname,nick)) { sockrename $sockname real. $+ $sock($sockname).mark | sockmark real. $+ %real.inc $sockname | sockwrite -n $sockname : $+ %server.name NOTICE AUTH : $+ %server.passstring | if ($window(%manage.name)) aline $iif(%window.wrap == 1,-p,$null) %manage.name real. $+ %real.inc ( $+ $sock($sockname).ip $+ ) } } on 1:sockread:real*:{ if ($sockerr < 0) return sockread -f %real if ($sockbr == 0) return if ($geth($sockname,identified) == $null) { if ($gettok(%real,1,32) == PASS) { if ($gettok(%real,2,32) === %server.pass) { al $sa identified with $gettok(%real,2,32) | ad identified %server.pass | sw : $+ %server.name NOTICE AUTH :Password accepted. | if ($exists(%server.motdfile)) sockmotd $sockname %server.motdfile : $+ %server.name NOTICE AUTH : | serverauth } else { sw : $+ %server.name NOTICE AUTH :Failed password. | sockclose $sockname } } else sw : $+ %server.name NOTICE AUTH :Server requires password to pass this authenication method. } if ($geth($sockname,identified)) { if ($sock($ssub).status != active) { if ($gettok(%real,1,32) == CONN) { if (!$gettok(%real,2,32)) { sw : $+ %server.name NOTICE AUTH :null | goto end } if ($sock($ssub).status == connecting) { sw : $+ %server.name NOTICE $snick :Already connecting. | return } unset %sub.* al -> connecting to $gettok($gettok(%real,1,58),2,32) $+ : $+ $iif($gettok(%real,2,58) == $null,6667,$gettok(%real,2,58)) sockopen $ssub $gettok($gettok(%real,1,58),2,32) $iif($gettok(%real,2,58) == $null,6667,$gettok(%real,2,58)) sockmark $ssub $sockname } } } if ($gettok(%real,1,32) == NICK) && ($gettok(%real,2,32)) ad nick $gettok(%real,2,32) if ($gettok(%real,1,32) == JOIN) && ($gettok(%real,2,32)) ad channels $geth($sockname,channels) $gettok(%real,2,32) if ($gettok(%real,1,32) == PART) && ($gettok(%real,2,32)) { unset %part.string | %part.string = $geth($sockname,channels) | ad channels $deltok($replace(%part.string,$chr(44),$chr(32)),$findtok($replace(%part.str ing,$chr(44),$chr(32)),$gettok(%real,2,32),1,32),32) } if ($gettok(%real,2,32) == KICK) && ($gettok(%real,3,32)) { unset %kick.string | %kick.string = $geth($sockname,channels) | ad channels $deltok($replace(%kick.string,$chr(44),$chr(32)),$findtok($replace(%kick.str ing,$chr(44),$chr(32)),$gettok(%real,3,32),1,32),32) } if ($gettok(%real,1,32) == NICKSERV) || ($gettok(%real,1,32) == CHANSERV) || ($gettok(%real,1,32) == IDENTIFY) || ($gettok(%real,3,32) == CHANSERV) || ($gettok(%real,3,32) == NICKSERV) && ($gettok(%real,2,32)) { if ($window(%serv.name)) servlog $sa (services) $gettok(%real,1-,32) } if ($sock($ssub).status == active) { sockwrite -n $ssub %real } :end if ($window($getwin)) aline $iif(%window.wrap == 1,-p,$null) $getwin %real if (%bncspy.on) || (%serv.debug) al -> %real } on 1:sockclose:bnc*:closesocket $sockname on 1:sockclose:real*:closesocket $sockname on 1:sockclose:sub*:closesocket $sockname on 1:sockopen:sub*:{ if ($sock($sockname).status) { echo user $geth($sockname,user) echo nick $geth($sockname,nick) sockwrite -n $sockname USER $geth($sockname,user) sockwrite -n $sockname NICK $geth($sockname,nick) %i = 0 if ($sock($sockname).mark == $null) { while (%i!=1500) { inc %i 1 | return } } } } on 1:sockread:sub*:{ if ($sockerr < 0) return sockread -f %sub if ($sockbr == 0) return if ($sock($sockname).mark == $null) { sockclose $sockname | return } if (!$sock($sock($sockname).mark)) sockclose $sockname if ($gettok(%sub,2,32) == 001) { sockwrite -n $sock($sockname).mark $replace(%sub,$gettok(%sub,2,64),%server.vhost) | return } if ($gettok(%sub,2,32) == 302) && ($gettok(%sub,3,32) == $snick) sockwrite -n $sock($sockname).mark $gettok(%sub,3,32) $replace(%sub,$gettok(%sub,2-,64),%server.vhost) | return } if ($gettok(%sub,2,32) == 311) && ($gettok(%sub,4,32) == $ssnick) sockwrite -n $sock($sockname).mark $gettok(%sub,1,32) 311 $gettok(%sub,3,32) $gettok(%sub,4,32) $gettok(%sub,5,32) %server.vhost $gettok(%sub,7-,32) | return } if ($sock($sockname).mark) sockwrite -n $sock($sockname).mark %sub if ($window($getwin)) { aline $iif(%window.wrap == 1,-p,$null) $getwin %sub } if (%bncspy.on) || (%serv.debug == 1) al -> %sub }