# DCC channels.. by Ian Frechette (shoot me now) (make it stop) # Started 2-13-93 # To use.. # /load dccchan # /makeid nickname # /openport port (to listen for connection on port) or # /closeport port (close listening port) # /opencon host port (to connect to existing dcc channel) # /whoon (list who is on the channel) # /query /d_msg # type to your hearts content # # /dpart to leave @ RCS.dccchan = [$$Header: /local/cvs/ircii/script/dccchan,v 1.2 2001/08/12 15:44:17 mrg Exp $$] @ dchan.portnum = 7000 # open listening connection on the specified port number # the $dchan.portnum is default if not given. alias openport { if (myuniquid) { if ([$0]) { @ dchan.portnum = [$0] } echo *** Opening listen on port $listen($dchan.portnum) } { echo *** Please use /makeid before opening port } } alias closeport { if ([$0]) { if ([$0]) { @ dchan.portnum = [$0] } echo *** closing listen on port $dchan.portnum dcc close raw_listen $dchan.portnum } { echo *** Please specify portnumber. /closeport } } # generate a unique_id NICK_TIME and nickname alias makeid { if ([$0]) { if (!myuniquid) { @ myuniquid = encode($0_$time()) @ mynick = [$0] } echo *** Your nickname is $mynick and uniquid is $decode($myuniquid) } { echo *** Please supply a nickname. /makeid nickname } } # opencon open a connection to another machine and port # $0 == name of machine # $1 == port number alias opencon { if (myuniquid) { echo *** Opening a connection to $0 on port $1 @ ctmp = connect($0 $1) if (ctmp) { eval @ co.$ctmp = [$ctmp $0] update_co $ctmp echo *** Connection to $0 established on port $1 } { echo *** Failed to connect to $0 on port $1 } } { echo *** Please use /makeid before opening port } } # strip ^M's from a line alias sm @ function_return = strip( $*) # strip the colon from the beginning of a line if there is 1. alias sc @temp = [$*];if ([$[1]0] == [:]) { @function_return = mid(1 ${@temp -1} $temp) } { @ function_return = temp } ^on #-dcc_raw -45 * debug RAW: $* ^on ^dcc_raw * ^on #^dcc_raw 45 "% % N *" add_connection $0 $1 ^on #^dcc_raw 45 "% % C*" remove_connection $sm($0) ^on #^dcc_raw 45 "% % D MEMBER *" add_member $sm($0 $4 $5) ^on #^dcc_raw 45 "% % D R_MEMBER *" rem_member $sm($0 $4) ^on #^dcc_raw 45 "% % D MSG *" do_msg $sm($0 $4-) ^on #^dcc_raw 45 "% % D NICK *" do_nick $sm($0 $4 $5) ^on #^dcc_raw 45 "% % D END *" # do nothing for now # d_msg - send a message to everyone else on channel alias d_msg { toall MSG $myuniquid $* xecho -level DCC +> $* } # do_msg - display message and pass on to rest of tree # $0 == id # $1 == NICK_TIME # $2- == content of message alias do_msg { if (rstat[$0] > 0) { xecho -level DCC +$nicks[$1]+ $2- toallbutone $0 MSG $1 $2- } } # structure co. stores and # Add a connection when someone connects to this node alias add_connection { debug ADD_CONNECTION: $* eval @ co.$0 = [$0 $1] # rstat is registered status. 0 - no members, >0 - members registered eval @ rstat.$0 = 0 update_co $0 } # update_co - update information for remote connection.. Basically # just send it everything we know. # $0 == id of link to fill in. alias update_co { smsg $0 MEMBER $myuniquid $mynick foreach nicks ii { smsg $0 MEMBER $ii $nicks[$ii] debug SENDMEMBER: $ii $nicks[$ii] } # not used yet, but for future expandability smsg $0 END MEMBER } # add_member - add a node to the database # other nodes will send MEMBER # $0 == id # $1 == NICK_TIME (nick encoded + time) unique id # $2 == nick alias add_member { if (member[$1]) { debug ADD_MEMBER Dup.. removing $* # remove connection silently # if we told the rest of the net members would be removed # accidentally.. Just pretend this connection didn't happen # ARRRRG.. can't do this.. can't remove a dcc connection from # inside an ON DCC. If I delay with timer 0 close.. then it # defeats the purpose here which was to try to head off any # already pending garbage. timer 0 ^dcc close raw $co[$0] ^assign -co.$0 } { debug ADD_MEMBER Adding: $* # needs to send MEMBER