--- relay-2.1.6.tcl 2004-04-09 05:24:48.000000000 +0000 +++ relay-2.1.7.tcl 2008-11-03 01:00:10.000000000 +0000 @@ -1,11 +1,13 @@ -#// relay.tcl v2.1.6 - Send Channel Text/Acts/Join/Part/Quit/Topc/Nick/Kick/Ban +#// relay.tcl v2.1.7 - Send Channel Text/Acts/Join/Part/Quit/Topc/Nick/Kick/Ban #// Data to one or more networks #// -#// v2.1.6 By: `Kumba +#// v2.1.7 By: `Kumba #// v1.0.0 By: cl00bie #// #// TCL regsub code for mirc code stripping borrowed from mc.moretools by MC_8 +#// Version Var +set relay-version "2.1.7" #//-------------------------------------------------------------------------------------------------------------- #// --- Known Bugs/Glitches --- @@ -273,7 +275,7 @@ set thecolors(help) 1 #// Default Value: "\00312-\003\00314!\003\00312-\003 " set therelay(prefix) "\00312-\003\00314!\003\00312-\003 " -#// Name of the relay (Default is "Eggdrop") +#// Name of the relay (Default is "Eggdrop IRC Relay") set therelay(name) "Eggdrop IRC Relay" #// Enable !rehash? (Owner Only!) @@ -285,9 +287,6 @@ set theopts(enable_cmdrestart) 1 #// Enable !shutdown? (Owner Only!) set theopts(enable_cmdshutdown) 1 -#// !list Punisher (Kicks an individual who does !list || @list) -set theopts(enable_listkick) 1 - @@ -351,38 +350,22 @@ if {$theopts(allow_names) == 1 && $theop #//-------------------------------------------------------------------------------------------------------------- -#// --- Startup Code --- - - -#// Clear the Global Variables (If They Exist) -if {[info exists spltbuf] == 1} {array unset spltbuf} -if {[info exists rejnbuf] == 1} {array unset rejnbuf} -if {[info exists linkbuf] == 1} {array unset linkbuf} -if {[info exists discbuf] == 1} {array unset discbuf} -if {[info exists hurtbuf] == 1} {array unset hurtbuf} -if {[info exists replybuf] == 1} {array unset replybuf} -if {[info exists c] == 1} {array unset c} - - -#// Initialize our Global Variables -set spltbuf(init) "donotremoveme" -set rejnbuf(init) "donotremoveme" -set linkbuf(init) "donotremoveme" -set discbuf(init) "donotremoveme" -set hurtbuf(init) "donotremoveme" -set replybuf(init) "donotremoveme" - - -#// Fix our binds -set_binds +#// --- Color/Code Stripper --- -#// Configure Colors -configure_colors +#// Strips Mirc Colors/Bold/Underline/Reverse from text +proc strip_codes {text} { + global theopts + if {$theopts(strip_codes) == 1} { + regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $text "" text; #// Color + regsub -all -- "\002" $text "" text; #// Bold + regsub -all -- "\026" $text "" text; #// Reverse + regsub -all -- "\037" $text "" text; #// Underline + } -#// Some people cannot follow directions at times. This prevents such people from screwing the script up -set therelay(channels) [string tolower $therelay(channels)] + return $text +} @@ -443,7 +426,7 @@ proc configure_colors {} { #// Prefix Stripper if {$thecolors(master) != 1} { - set therelay(prefix) [stripcodes $therelay(prefix)] + set therelay(prefix) [strip_codes $therelay(prefix)] } @@ -452,11 +435,10 @@ proc configure_colors {} { set c(1brac) "\00314"; #// Dark Grey - Angle Brackets set c(1nick) ""; #// No Color - Nickname set c(1netw) ""; #// No Color - Network - set c(1atch) "\00314"; #// Dark Grey - '@' Character set c(1x) "\003"; #// Color Terminator } else { set c(1brac) ""; set c(1nick) ""; set c(1netw) ""; - set c(1atch) ""; set c(1x) ""; + set c(1x) ""; } @@ -465,24 +447,24 @@ proc configure_colors {} { set c(2star) "\00314"; #// Dark Grey - Asterisk set c(2nick) ""; #// No Color - Nickname set c(2netw) ""; #// No Color - Network - set c(2atch) "\00314"; #// Dark Grey - '@' Character set c(2x) "\003"; #// Color Terminator } else { set c(2star) ""; set c(2nick) ""; set c(2netw) ""; - set c(2atch) ""; set c(2x) ""; + set c(2x) ""; } #// Nickname Changes if {$thecolors(nick) == 1 && $thecolors(master) == 1} { + set c(3nick) "\00310"; #// Dark Cyan - "Nick" set c(3oldn) "\00310"; #// Dark Cyan - Old Nickname set c(3netw) "\00310"; #// Dark Cyan - Network set c(3newn) "\00303"; #// Dark Green - New Nickname - set c(3atch) "\00314"; #// Dark Grey - '@' Character + set c(3slsh) "\00314"; #// Dark Grey - Forward Slash set c(3x) "\003"; #// Color Terminator } else { - set c(3oldn) ""; set c(3netw) ""; set c(3newn) ""; - set c(3atch) ""; set c(3x) ""; + set c(3nick) ""; set c(3oldn) ""; set c(3netw) ""; + set c(3newn) ""; set c(3slsh) ""; set c(3x) ""; } @@ -502,44 +484,48 @@ proc configure_colors {} { #// Joins if {$thecolors(join) == 1 && $thecolors(master) == 1} { + set c(5join) "\00310"; #// Dark Cyan - "Join" set c(5chan) "\00303"; #// Dark Green - Channel set c(5host) "\00306"; #// Dark Purple - Hostmask set c(5nick) "\00310"; #// Dark Cyan - Nickname set c(5netw) "\00310"; #// Dark Cyan - Network set c(5brac) "\00314"; #// Dark Grey - Square Brackets - set c(5atch) "\00314"; #// Dark Grey - '@' Character + set c(5slsh) "\00314"; #// Dark Grey - Forward Slash set c(5x) "\003"; #// Color Terminator } else { - set c(5chan) ""; set c(5host) ""; set c(5nick) ""; - set c(5netw) ""; set c(5brac) ""; set c(5atch) ""; - set c(5x) ""; + set c(5join) ""; set c(5chan) ""; set c(5host) ""; + set c(5nick) ""; set c(5netw) ""; set c(5brac) ""; + set c(5slsh) ""; set c(5x) ""; } #// Quits/Signoffs if {$thecolors(sign) == 1 && $thecolors(master) == 1} { + set c(6sign) "\00310"; #// Dark Cyan - "Quit" set c(6chan) "\00303"; #// Dark Green - Channel set c(6nick) "\00310"; #// Dark Cyan - Nickname set c(6netw) "\00310"; #// Dark Cyan - Network set c(6brac) "\00314"; #// Dark Grey - Parenthesis - set c(6atch) "\00314"; #// Dark Grey - '@' Character + set c(6slsh) "\00314"; #// Dark Grey - Forward Slash set c(6x) "\003"; #// Color Terminator } else { - set c(6chan) ""; set c(6nick) ""; set c(6netw) ""; - set c(6brac) ""; set c(6atch) ""; set c(6x) ""; + set c(6sign) ""; set c(6chan) ""; set c(6nick) ""; + set c(6netw) ""; set c(6brac) ""; set c(6slsh) ""; + set c(6x) ""; } #// Parts if {$thecolors(part) == 1 && $thecolors(master) == 1} { + set c(7part) "\00310"; #// Dark Cyan - "Quit" set c(7chan) "\00303"; #// Dark Green - Channel set c(7nick) "\00310"; #// Dark Cyan - Nickname set c(7netw) "\00310"; #// Dark Cyan - Network - set c(7atch) "\00314"; #// Dark Grey - '@' Character + set c(7slsh) "\00314"; #// Dark Grey - Forward Slash set c(7x) "\003"; #// Color Terminator } else { - set c(7chan) ""; set c(7nick) ""; set c(7netw) ""; - set c(7atch) ""; set c(7x) ""; + set c(7part) ""; set c(7chan) ""; set c(7nick) ""; + set c(7netw) ""; set c(7slsh) ""; set c(7x) ""; } @@ -738,14 +724,14 @@ proc set_binds {} { #// Actions if {$theopts(show_act) == 1 && $theopts(master) == 1} { - bind ctcp - "ACTION" send_action - bind bot - act recv_action + bind ctcp - "ACTION" send_actn + bind bot - act recv_actn } else { set tmpbit [bind ctcp - "ACTION"] if {$tmpbit != ""} { - if {[string first "send_action" $tmpbit] > -1} { - unbind ctcp - "ACTION" send_action - unbind bot - act recv_action + if {[string first "send_actn" $tmpbit] > -1} { + unbind ctcp - "ACTION" send_actn + unbind bot - act recv_actn } } } @@ -1184,27 +1170,48 @@ proc set_binds {} { } - #// !list/@list Kicker - if {$theopts(enable_listkick) == 1 && $theopts(master) == 1} { - bind pub - !list pub_listkick - bind pub - @list pub_listkick - } else { - set tmpbit [bind pub - !list] - if {$tmpbit != ""} { - if {[string first "pub_listkick" $tmpbit] > -1} { - unbind pub - !list pub_listkick - unbind pub - @list pub_listkick - } - } - } - - return 0 } #//-------------------------------------------------------------------------------------------------------------- +#// --- Startup Code --- + + +#// Clear the Global Variables (If They Exist) +if {[info exists spltbuf] == 1} {array unset spltbuf} +if {[info exists rejnbuf] == 1} {array unset rejnbuf} +if {[info exists linkbuf] == 1} {array unset linkbuf} +if {[info exists discbuf] == 1} {array unset discbuf} +if {[info exists hurtbuf] == 1} {array unset hurtbuf} +if {[info exists replybuf] == 1} {array unset replybuf} +if {[info exists c] == 1} {array unset c} + + +#// Initialize our Global Variables +set spltbuf(init) "donotremoveme" +set rejnbuf(init) "donotremoveme" +set linkbuf(init) "donotremoveme" +set discbuf(init) "donotremoveme" +set hurtbuf(init) "donotremoveme" +set replybuf(init) "donotremoveme" + + +#// Fix our binds +set_binds + + +#// Configure Colors +configure_colors + + +#// Some people cannot follow directions at times. This prevents such people from screwing the script up +set therelay(channels) [string tolower $therelay(channels)] + + + +#//-------------------------------------------------------------------------------------------------------------- #// --- Message Handler --- @@ -1249,37 +1256,35 @@ proc is_hurt {uhost} { #//-------------------------------------------------------------------------------------------------------------- -#// --- Color/Code Stripper --- - - -#// Strips Mirc Colors/Bold/Underline/Reverse from text -proc stripcodes {text} { - global theopts - - if {$theopts(strip_codes) == 1} { - regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $text "" text; #// Color - regsub -all -- "\002" $text "" text; #// Bold - regsub -all -- "\026" $text "" text; #// Reverse - regsub -all -- "\037" $text "" text; #// Underline - } - - return $text -} - - - -#//-------------------------------------------------------------------------------------------------------------- #// --- Public Chatter --- #// Send all normal chatroom talk ("pubm" event) proc send_pubm {nick uhost hand chan text} { + global theopts + #// See if a user is "Hurt" if {[is_hurt $uhost] == 1} { putquick "NOTICE $nick :You have been silenced on the relay. Please talk to an Operator for further information." return 0 } + #// If the first character is a !, and theopts(enable_echocmd) is no, then block our command binds + if {([string index $text 0] == "!") && ($theopts(enable_echocmd) == 0)} { + switch -exact -- [lindex [split $text] 0] { + !names - !gettopic - + !kick - !kickban - + !op - !deop - + !voice - !devoice - + !halfop - !dehalfop - + !mode - !topic - + !help - + !hurt - !heal - + !rehash - !restart - !shutdown + { return 0 } + } + } + #// Send the Chatter send_across "pubm" $chan $nick $text return 0 @@ -1293,9 +1298,9 @@ proc recv_pubm {frm_bot command arg} { set thechan [lindex $arg 0] set thenetw "$c(1netw)[lindex $arg 1]$c(1x)" set thenick "$c(1nick)[lindex $arg 2]$c(1x)" - set thetext [stripcodes [join [lrange $arg 3 end]]] + set thetext [strip_codes [join [lrange $arg 3 end]]] - putquick "PRIVMSG $thechan :$c(1brac)\<$c(1x)$thenick$c(1atch)\@$c(1x)$thenetw$c(1brac)\>$c(1x) $thetext" + putquick "PRIVMSG $thechan :$thenetw: $c(1brac)\<$c(1x)$thenick$c(1brac)\>$c(1x) $thetext" return 0 } @@ -1306,7 +1311,7 @@ proc recv_pubm {frm_bot command arg} { #// Send all Actions ("act" event) -proc send_action {nick uhost hand chan keyw text} { +proc send_actn {nick uhost hand chan keyw text} { #// See if a user is "Hurt" if {[is_hurt $uhost] == 1} { putquick "NOTICE $nick :You have been silenced on the relay. Please talk to an Operator for further information." @@ -1320,15 +1325,15 @@ proc send_action {nick uhost hand chan k #// Process and display all Actions ("act" event) -proc recv_action {frm_bot command arg} { +proc recv_actn {frm_bot command arg} { global theopts c set arg [split $arg] set thechan [lindex $arg 0] set thenetw "$c(2netw)[lindex $arg 1]$c(2x)" set thenick "$c(2nick)[lindex $arg 2]$c(2x)" - set theactn [stripcodes [join [lrange $arg 3 end]]] + set theactn [strip_codes [join [lrange $arg 3 end]]] - putquick "PRIVMSG $thechan :$c(2star)\*$c(2x) $thenick$c(2atch)\@$c(2x)$thenetw $theactn" + putquick "PRIVMSG $thechan :$thenetw: $c(2star)\*$c(2x) $thenick $theactn" return 0 } @@ -1365,7 +1370,7 @@ proc recv_nick {frm_bot command arg} { set thenick [lindex $arg 2] set newnick [join [lrange $arg 3 end]] - putquick "PRIVMSG $thechan :$therelay(prefix)$c(3oldn)$thenick$c(3x)$c(3atch)\@$c(3x)$c(3netw)$thenetw$c(3x) is now known as $c(3newn)$newnick$c(3x)" + putquick "PRIVMSG $thechan :$therelay(prefix)$c(3nick)Nick$c(3x)$c(3slsh)\/$c(3x)$c(3netw)$thenetw$c(3x): $c(3oldn)$thenick$c(3x) is now known as $c(3newn)$newnick$c(3x)" #// Update the reply buffer (if one exists) to reflect the new user's nickname (PrivMsg Feature) set tmplist [split [array get replybuf]] @@ -1428,7 +1433,8 @@ proc recv_statchg {frm_bot command arg} set themode "$c(4brac)\[$c(4x)[lindex $arg 3]" set victims "[join [lrange $arg 4 end]]$c(4brac)\]$c(4x)" - putquick "PRIVMSG $thechan :${therelay(prefix)}$c(4mode)Mode$c(4x)$c(4slsh)\/$c(4x)$thenetw: $themode $victims by $bywhom" + putquick "PRIVMSG $thechan :$therelay(prefix)$c(4mode)Mode$c(4x)$c(4slsh)\/$c(4x)$thenetw: $themode $victims by $bywhom" + return 0 } #//-------------------------------------------------------------------------------------------------------------- @@ -1451,7 +1457,7 @@ proc recv_join {frm_bot command arg} { set thenick "$c(5nick)[lindex $arg 2]$c(5x)" set thehost "$c(5brac)\[$c(5x)$c(5host)[lindex $arg 3]$c(5x)$c(5brac)\]$c(5x)" - putquick "PRIVMSG $thechan :$therelay(prefix)$thenick$c(5atch)\@$c(5x)$thenetw $thehost has joined $c(5chan)$thechan$c(5x)" + putquick "PRIVMSG $thechan :$therelay(prefix)$c(5join)Join$c(5x)$c(5slsh)\/$c(5x)$c(5netw)$thenetw$c(5x): $c(5nick)$thenick$c(5x) $thehost has joined the channel" return 0 } @@ -1463,7 +1469,7 @@ proc recv_join {frm_bot command arg} { #// Send a "sign" event (a quit) proc send_sign {nick uhost hand chan reason} { - global replybuf + global theopts replybuf #// See if a user is "Hurt" (Masks Quit Message with canned message) if {[is_hurt $uhost] == 1} { @@ -1494,15 +1500,15 @@ proc recv_sign {frm_bot command arg} { set thechan [lindex $arg 0] set thenetw [lindex $arg 1] set thenick [lindex $arg 2] - set thereason "$c(6brac)\($c(6x)[stripcodes [join [lrange $arg 3 end]]]$c(6brac)\)$c(6x)" + set thereason "$c(6brac)\($c(6x)[strip_codes [join [lrange $arg 3 end]]]$c(6brac)\)$c(6x)" - #// Check quit message length + #// Check quit message length - don't print anything if 0 if {[string length $thereason] == 0} { set thereason "" } #// Send to IRC - putquick "PRIVMSG $thechan :$therelay(prefix)$c(6nick)$thenick$c(6x)$c(6atch)\@$c(6x)$c(6netw)$thenetw$c(6x) has quit $thereason" + putquick "PRIVMSG $thechan :$therelay(prefix)$c(6sign)Quit$c(6x)$c(6slsh)\/$c(6x)$c(6netw)$thenetw$c(6x): $c(6nick)$thenick$c(6x) $thereason" #// If any values in the reply buffer match the nickname that quit, remove them set tmpnames [array names replybuf] @@ -1543,11 +1549,11 @@ proc send_part {nick uhost hand chan arg proc recv_part {frm_bot command arg} { global therelay c set arg [split $arg] - set thechan "[lindex $arg 0]" - set thenetw "$c(7netw)[lindex $arg 1]$c(7x)" - set thenick "$c(7nick)[lindex $arg 2]$c(7x)" + set thechan [lindex $arg 0] + set thenetw [lindex $arg 1] + set thenick [lindex $arg 2] - putquick "PRIVMSG $thechan :$therelay(prefix)$thenick$c(7atch)\@$c(7x)$thenetw has left $c(7chan)$thechan$c(7x)" + putquick "PRIVMSG $thechan :$therelay(prefix)$c(7part)Part$c(7x)$c(7slsh)\/$c(7x)$c(7netw)$thenetw$c(7x): $c(7nick)$thenick$c(7x) has left the channel" return 0 } @@ -1568,7 +1574,7 @@ proc send_topc {nick uhost hand chan top proc recv_topc {frm_bot command arg} { global therelay c set arg [split $arg] - set thechan [lindex arg 0] + set thechan [lindex $arg 0] set thenetw "$c(8netw)[lindex $arg 1]$c(8x)" set thenick [lindex $arg 2] set thetopc [join [lrange $arg 3 end]] @@ -1605,7 +1611,7 @@ proc recv_kick {frm_bot command arg} { set thenetw "$c(9netw)[lindex $arg 1]$c(9x)" set thenick "$c(9nick)[lindex $arg 2]$c(9x)" set thevictim "$c(9vict)[lindex $arg 3]$c(9x)" - set thereason "$c(9brac)\[$c(9x)[stripcodes [join [lrange $arg 4 end]]]$c(9brac)\]$c(9x)" + set thereason "$c(9brac)\[$c(9x)[strip_codes [join [lrange $arg 4 end]]]$c(9brac)\]$c(9x)" #// Show the Kick putquick "PRIVMSG $thechan :$therelay(prefix)$c(9kick)Kick$c(9x)$c(9slsh)\/$c(9x)$thenetw: $thevictim by $thenick $thereason" @@ -1620,7 +1626,7 @@ proc recv_kick {frm_bot command arg} { #// Process a "ban" event proc recv_ban {frm_bot command arg} { - global therelay c + global therelay theopts c set arg [split $arg] set thechan [lindex $arg 0] set thenetw "$c(10netw)[lindex $arg 1]$c(10x)" @@ -1639,8 +1645,8 @@ proc recv_ban {frm_bot command arg} { b { #// Is the Ban New, or being Removed? switch -exact -- $bit { - + {putquick "PRIVMSG $thechan :$newheader\Ban$thefsash$thenetw: $themask"} - - {putquick "PRIVMSG $thechan :$remheader\Ban$thefsash$thenetw: $themask"} + + {putquick "PRIVMSG $thechan :$newheader\Ban$theslash$thenetw: $themask"} + - {putquick "PRIVMSG $thechan :$remheader\Ban$theslash$thenetw: $themask"} } return 0 } @@ -1675,76 +1681,21 @@ proc recv_ban {frm_bot command arg} { #// --- Netsplits/Netmerges --- -#// Send a "splt" event (Netsplit) -proc send_splt {nick uhost hand chan} { - send_across "splt" $chan $nick "dummy" - return 0 -} - - -#// Process a "splt" event (Netsplit) -proc recv_splt {frm_bot command arg} { - set arg [split $arg] - set thechan [lindex $arg 0] - set thenetw [lindex $arg 1] - set thenick [lindex $arg 2] - - splt-rejn_record "$thenetw\@$thechan" $thenick "splt" "$c(11splt)" "$c(11slsh)" "$c(11netw)" "$c(11nick)" "$c(11x)" - return 0 -} - - - -#// Send a "rejn" event (Netmerge) -proc send_rejn {nick uhost hand chan} { - send_across "rejn" $chan $nick "dummy" - return 0 -} - - -#// Process a "rejn" event (Netmerge) -proc recv_rejn {frm_bot command arg} { - set arg [split $arg] - set thechan [lindex $arg 0] - set thenetw [lindex $arg 1] - set thenick [lindex $arg 2] - - splt-rejn_record "$thenetw\@$thechan" $thenick "rejn" "$c(12rejn)" "$c(12slsh)" "$c(12netw)" "$c(12nick)" "$c(12x)" - return 0 -} - - - -#// Take the given where/who && type, and record it to the appropriate global array -proc splt-rejn_record {where who type c1 c2 c3 c4 cx} { - global ${type}buf - - #// If the size of the array is < 1, do nothing (Shouldn't happen, but....) - #// If the size of the array == 1, then record the event, and start a timer (15 Seconds) - #// if the size of the array is > 1, then just record the event, as the timer is already started - if {[array size ${type}buf] < 1} { - return 0 - } elseif {[array size ${type}buf] == 1} { - set thechan [lindex [split $where @] 1] - set ${type}buf($where) $who - utimer 15 "splt-rejn_report $type $c1 $c2 $c3 $c4 $cx" - } elseif {[array size ${type}buf] > 1} { - set ${type}buf($where) [concat [set ${type}buf($where)] $who] - } - - return 0 -} - - - #// Report Netsplit/Netmerges -proc splt-rejn_report {type c1 c2 c3 c4 cx} { - global therelay theopts ${type}buf +proc splt-rejn_report {type cnum} { + global c therelay theopts ${type}buf + + #// Prep Colors + set clr(1) $c(${cnum}${type}) + set clr(2) $c(${cnum}slsh) + set clr(3) $c(${cnum}netw) + set clr(4) $c(${cnum}nick) + set clr(x) $c(${cnum}x) #// What Array are we using? switch -exact -- $type { - splt {set chantxt "$therelay(prefix)$c1Netsplit$cx$c2\/$cx$c3"} - rejn {set chantxt "$therelay(prefix)$c1Netmerge$cx$c2\/$cx$c3"} + splt {set chantxt "$therelay(prefix)$clr(1)Netsplit$clr(x)$clr(2)\/$clr(x)"} + rejn {set chantxt "$therelay(prefix)$clr(1)Netmerge$clr(x)$clr(2)\/$clr(x)"} } set tmpnames [array names ${type}buf] set tmplen [llength $tmpnames] @@ -1770,10 +1721,10 @@ proc splt-rejn_report {type c1 c2 c3 c4 set xEnd [expr $xStart + $theopts(max_spltrejn)] set tmplist [join [lrange $thedata $xStart [expr $xEnd - 1]]] if {$xEnd > $datalen} {set xEnd $datalen} - putquick "PRIVMSG $thechan :$chantxt$thenetw$cx: $c4$tmplist$cx" + putquick "PRIVMSG $thechan :$chantxt$clr(3)$thenetw$clr(x): $clr(4)$tmplist$clr(x)" } } else { - putquick "PRIVMSG $thechan :$chantxt$thenetw$cx: $c4$thedata$cx" + putquick "PRIVMSG $thechan :$chantxt$clr(3)$thenetw$clr(x): $clr(4)$thedata$clr(x)" } } } @@ -1789,6 +1740,67 @@ proc splt-rejn_report {type c1 c2 c3 c4 } +#// Take the given where/who && type, and record it to the appropriate global array +proc splt-rejn_record {where who type cnum} { + global ${type}buf + + #// If the size of the array is < 1, do nothing (Shouldn't happen, but....) + #// If the size of the array == 1, then record the event, and start a timer (15 Seconds) + #// if the size of the array is > 1, then just record the event, as the timer is already started + if {[array size ${type}buf] < 1} { + return 0 + } elseif {[array size ${type}buf] == 1} { + set thechan [lindex [split $where @] 1] + set ${type}buf($where) $who + utimer 10 [split "splt-rejn_report $type $cnum"] + } elseif {[array size ${type}buf] > 1} { + set ${type}buf($where) [concat [set ${type}buf($where)] $who] + } + + return 0 +} + + +#// Send a "splt" event (Netsplit) +proc send_splt {nick uhost hand chan} { + send_across "splt" $chan $nick "dummy" + return 0 +} + + +#// Process a "splt" event (Netsplit) +proc recv_splt {frm_bot command arg} { + global c + set arg [split $arg] + set thechan [lindex $arg 0] + set thenetw [lindex $arg 1] + set thenick [lindex $arg 2] + + splt-rejn_record "$thenetw\@$thechan" $thenick "splt" "11" + return 0 +} + + +#// Send a "rejn" event (Netmerge) +proc send_rejn {nick uhost hand chan} { + send_across "rejn" $chan $nick "dummy" + return 0 +} + + +#// Process a "rejn" event (Netmerge) +proc recv_rejn {frm_bot command arg} { + global c + set arg [split $arg] + set thechan [lindex $arg 0] + set thenetw [lindex $arg 1] + set thenick [lindex $arg 2] + + splt-rejn_record "$thenetw\@$thechan" $thenick "rejn" "12" + return 0 +} + + #//-------------------------------------------------------------------------------------------------------------- #// --- Botnet Links/Disconnects --- @@ -2020,6 +2032,7 @@ proc send_msg {nick uhost hand text} { #// Incase we intercept another msg command switch -exact -- [lindex $text 0] { + !gettopic - !op - !deop - !halfop - !dehalfop - !voice - !devoice - !topic - !kick - !kickban - !mode - !hurt - !heal { return 0 } } @@ -2087,7 +2100,7 @@ proc recv_msg {frm_bot command arg} { set sender [lindex $arg 0] set sendnet [lindex $arg 1] set thenick [lindex $arg 2] - set themsgm [stripcodes [join [lrange $arg 3 end]]] + set themsgm [strip_codes [join [lrange $arg 3 end]]] #// Output the message @@ -2221,21 +2234,206 @@ proc recv_gettopic {frm_bot command arg} #//-------------------------------------------------------------------------------------------------------------- -#// --- !op/!deop --- +#// --- Command Handler --- -#// /msg !op @ -proc send_msgop {nick uhost hand text} { +proc send_cmd {nick chan text} { + global therelay botnet-nick set text [split $text] - set victim [lindex $text 0] - set thechan [lindex $text 1] + set thecmd [lindex $text 0] + set thevictim [lindex [split [split [lindex $text 1] @]] 0] + set thenetwrk [lindex [split [split [lindex $text 1] @]] 1] - send_cmd $nick $thechan [concat "!op" $victim] - return 0 -} + #// Valid Channel Type? + switch -exact -- [string range $chan 0 0] { + # - & - ! {} + + { + putserv "NOTICE $nick :Sorry, channels prefixed with a \'\+\' character do not support channel modes." + return 0 + } + default { + putserv "NOTICE $nick :Invalid Channel. Use one of the following: $therelay(channels)" + return 0 + } + } -#// /msg !deop @ + + #// Valid Channel listed in $therelay(channels)? + if {[lsearch -exact $therelay(channels) [string tolower $chan]] == -1} { + putserv "NOTICE $nick :Invalid Channel. Use one of the following: $therelay(channels)" + return 0 + } + + + #// Make sure the user is an Operator (Halfops shouldn't need this level of access) + if {[isop $nick $chan] == 0} { + putserv "NOTICE $nick :Sorry, that command is reserved for operators only." + return 0 + } + + + #// Figure out the bot on the target network (if network == "all", then skip) + if {$thenetwrk != "all"} { + set netpos [lsearch -exact $therelay(netwrk) $thenetwrk] + if {$netpos != -1} { + set thebot(net) [lindex [split $therelay(botnet)] $netpos] + if {$thebot(net) != ${botnet-nick}} { + if {[islinked $thebot(net)] == 0} { + putserv "NOTICE $nick :Network $thenetw is not online/linked." + return 0 + } + set isLocal 0 + } else { + set isLocal 1 + } + } else { + putserv "NOTICE $nick :Invalid Network. Use one of the following: $therelay(netwrk) all" + return 0 + } + } else { + set isLocal 1 + } + + + #// Make sure we are not attempting to execute commands on the relay bots + set tmppos1 [lsearch -exact $therelay(botirc) $thevictim] + set tmppos2 [lsearch -exact $therelay(netwrk) $thenetwrk] + if {($tmppos1 > -1 && $tmppos2 > -1) && ($tmppos1 == $tmppos2)} { + putserv "NOTICE $nick :Invalid Nickname." + return 0 + } + + + #// What are we doing? + switch -exact -- $thecmd { + !kick - + !kickban { + set thereason [join [lrange [split $text] 1 end]] + set botMsg [concat "rlycmd" $nick $chan $therelay(ournet) $thecmd $thevictim $thereason] + } + + !mode - + !topic { + set themode [join [lrange [split $text] 2 end]] + set botMsg [concat "rlycmd" $nick $chan $therelay(ournet) $thecmd $themode] + } + + default {set botMsg [concat "rlycmd" $nick $chan $therelay(ournet) $thecmd $thevictim]} + } + + + #// if $thenetwrk == "all, send it to all bots/networks, otherwise... + if {$thenetwrk != "all"} { + if {$isLocal == 0} { + putbot $thebot(net) $botMsg + } + } elseif {$thenetwrk == "all"} { + putallbots $botMsg + } + + + #// If $isLocal == 1, execute a local version of the command as well + if {$isLocal == 1} { + recv_cmd "null" "rlycmd" [lrange $botMsg 1 end] + } + + return 0 +} + + +proc recv_cmd {frm_bot command arg} { + global theopts + set arg [split $arg] + set thenick [lindex $arg 0] + set thechan [lindex $arg 1] + set thenetw [lindex $arg 2] + set thecmnd [lindex $arg 3] + + + #// Perform the requested Action + if {[botisop $thechan] == 1} { + + #// Channel Modes/Multiple Modes _OR_ Topics + switch -exact -- $thecmnd { + !mode { + set themodes [join [lrange $arg 4 end]] + putserv "MODE $thechan $themodes" + return 0 + } + + !topic { + set thetopc [join [lrange $arg 4 end]] + putserv "TOPIC $thechan :$thetopc" + return 0 + } + } + + + set victim [join [lindex $arg 4]] + if {[onchan $victim $thechan] == 1} { + switch -exact -- $thecmnd { + + !kick { + #// Kick + set reason [join [lrange $arg 6 end]] + putserv "KICK $thechan $victim :$reason \($thenick\@$thenetw\)" + return 0 + } + + + !kickban { + #// Kickban + set reason [join [lrange $arg 6 end]] + set theban "*![getchanhost $victim $thechan]" + putquick "MODE $thechan +b $theban" + putserv "KICK $thechan $victim :$reason \($thenick\@$thenetw\)" + timer $theopts(cmdkickban_len) "putquick \"MODE $thechan -b $theban\"" + return 0 + } + + + default { + + #// What mode are we doing? + switch -exact -- $thecmnd { + !op {set themode "+o"} + !deop {set themode "-o"} + !voice {set themode "+v"} + !devoice {set themode "-v"} + !halfop {set themode "+h"} + !dehalfop {set themode "-h"} + } + + putserv "MODE $thechan $themode $victim" + return 0 + } + + } + } + } + + return 0 +} + + + +#//-------------------------------------------------------------------------------------------------------------- +#// --- !op/!deop --- + + +#// /msg !op @ +proc send_msgop {nick uhost hand text} { + set text [split $text] + set victim [lindex $text 0] + set thechan [lindex $text 1] + + send_cmd $nick $thechan [concat "!op" $victim] + return 0 +} + + +#// /msg !deop @ proc send_msgdeop {nick uhost hand text} { set text [split $text] set victim [lindex $text 0] @@ -2462,190 +2660,6 @@ proc send_pubmode {nick uhost hand chan -#//-------------------------------------------------------------------------------------------------------------- -#// --- Command Handler --- - - -proc send_cmd {nick chan text} { - global therelay botnet-nick - set text [split $text] - set thecmd [lindex $text 0] - set thevictim [lindex [split [split [lindex $text 1] @]] 0] - set thenetwrk [lindex [split [split [lindex $text 1] @]] 1] - - - #// Valid Channel Type? - switch -exact -- [string range $chan 0 0] { - # - & - ! {} - + { - putserv "NOTICE $nick :Sorry, channels prefixed with a \'\+\' character do not support channel modes." - return 0 - } - default { - putserv "NOTICE $nick :Invalid Channel. Use one of the following: $therelay(channels)" - return 0 - } - } - - - #// Valid Channel listed in $therelay(channels)? - if {[lsearch -exact $therelay(channels) [string tolower $chan]] == -1} { - putserv "NOTICE $nick :Invalid Channel. Use one of the following: $therelay(channels)" - return 0 - } - - - #// Make sure the user is an Operator (Halfops shouldn't need this level of access) - if {[isop $nick $chan] == 0} { - putserv "NOTICE $nick :Sorry, that command is reserved for operators only." - return 0 - } - - - #// Figure out the bot on the target network (if network == "all", then skip) - if {$thenetwrk != "all"} { - set netpos [lsearch -exact $therelay(netwrk) $thenetwrk] - if {$netpos != -1} { - set thebot(net) [lindex [split $therelay(botnet)] $netpos] - if {$thebot(net) != ${botnet-nick}} { - if {[islinked $thebot(net)] == 0} { - putserv "NOTICE $nick :Network $thenetw is not online/linked." - return 0 - } - set isLocal 0 - } else { - set isLocal 1 - } - } else { - putserv "NOTICE $nick :Invalid Network. Use one of the following: $therelay(netwrk) all" - return 0 - } - } else { - set isLocal 1 - } - - - #// Make sure we are not attempting to execute commands on the relay bots - set tmppos1 [lsearch -exact $therelay(botirc) $thevictim] - set tmppos2 [lsearch -exact $therelay(netwrk) $thenetwrk] - if {($tmppos1 > -1 && $tmppos2 > -1) && ($tmppos1 == $tmppos2)} { - putserv "NOTICE $nick :Invalid Nickname." - return 0 - } - - - #// What are we doing? - switch -exact -- $thecmd { - !kick - - !kickban { - set thereason [join [lrange [split $text] 1 end]] - set botMsg [concat "rlycmd" $nick $chan $therelay(ournet) $thecmd $thevictim $thereason] - } - - !mode - - !topic { - set themode [join [lrange [split $text] 2 end]] - set botMsg [concat "rlycmd" $nick $chan $therelay(ournet) $thecmd $themode] - } - - default {set botMsg [concat "rlycmd" $nick $chan $therelay(ournet) $thecmd $thevictim]} - } - - - #// if $thenetwrk == "all, send it to all bots/networks, otherwise... - if {$thenetwrk != "all"} { - if {$isLocal == 0} { - putbot $thebot(net) $botMsg - } - } elseif {$thenetwrk == "all"} { - putallbots $botMsg - } - - - #// If $isLocal == 1, execute a local version of the command as well - if {$isLocal == 1} { - recv_cmd "null" "rlycmd" [lrange $botMsg 1 end] - } - - return 0 -} - - -proc recv_cmd {frm_bot command arg} { - global theopts - set arg [split $arg] - set thenick [lindex $arg 0] - set thechan [lindex $arg 1] - set thenetw [lindex $arg 2] - set thecmnd [lindex $arg 3] - - - #// Perform the requested Action - if {[botisop $thechan] == 1} { - - #// Channel Modes/Multiple Modes _OR_ Topics - switch -exact -- $thecmnd { - !mode { - set themodes [join [lrange $arg 4 end]] - putserv "MODE $thechan $themodes" - return 0 - } - - !topic { - set thetopc [join [lrange $arg 4 end]] - putserv "TOPIC $thechan :$thetopc" - return 0 - } - } - - - set victim [join [lindex $arg 4]] - if {[onchan $victim $thechan] == 1} { - switch -exact -- $thecmnd { - - !kick { - #// Kick - set reason [join [lrange $arg 6 end]] - putserv "KICK $thechan $victim :$reason \($thenick\@$thenetw\)" - return 0 - } - - - !kickban { - #// Kickban - set reason [join [lrange $arg 6 end]] - set theban "*![getchanhost $victim $thechan]" - putquick "MODE $thechan +b $theban" - puthelp "KICK $thechan $victim :$reason \($thenick\@$thenetw\)" - timer $theopts(cmdkickban_len) "putquick \"MODE $thechan -b $theban\"" - return 0 - } - - - default { - - #// What mode are we doing? - switch -exact -- $thecmnd { - !op {set themode "+o"} - !deop {set themode "-o"} - !voice {set themode "+v"} - !devoice {set themode "-v"} - !halfop {set themode "+h"} - !dehalfop {set themode "-h"} - } - - putserv "MODE $thechan $themode $victim" - return 0 - } - - } - } - } - - return 0 -} - - #//-------------------------------------------------------------------------------------------------------------- #// --- !help --- @@ -3187,52 +3201,6 @@ proc recv_shutdown {frm_bot command arg} -#//------------------------------------------------------------------------------------------------$ -#// --- !list/@list Kicker --- - - -proc pub_listkick {nick uhost hand chan text} { - set thehost [getchanhost $nick] - set theisp [lindex [split $thehost @] 1] - set theban "\*\@$theisp" - set thefile "listkickcounter.txt" - set iCtr 0 - - #// Look for our counter file - if {[file exists $thefile] == 1} { - - #// Get the value from the file - set f [open $thefile r] - set iCtr [gets $f] - set iCtr [incr iCtr] - close $f - - #// Write it back - set f [open $thefile w] - puts $f $iCtr - close $f - } else { - - #// It wasn't found, start a new count - set iCtr [incr iCtr] - set f [open $thefile w] - - #// Write back the value to the file - puts $f $iCtr - close $f - } - - - #// Ban, Kick, and after a minute, remove the ban - putquick "MODE $chan +b $theban" -next - putserv "KICK $chan $nick :This Command isn't supported here. Go Away. \(\#$iCtr\)" - timer 2 "putquick \"MODE ${chan} -b $theban\"" - - return 0 -} - - - #//-------------------------------------------------------------------------------------------------------------- #// --- Our Tagline --- -putlog "$therelay(name) \[relay v2.1.6 by: `Kumba \]" +putlog "$therelay(name) \[relay v${relay-version} by: `Kumba \]"