# first edit: 29.Jan.2004 # last edit: 15.Mar.2004 namespace eval LinkChan { set Init 1 # On This Bot, send to user set Welcome ""; set SendWelcome 1; # welcome message on join set SendChannel 1; # show remote channel list (nick-list) set SendChannelPub 0; # set SendChannelBots 0; # show remote channel bots set SendChannelDouble 0; # show remote channel double (multinetwork) user set SendChannelMax 25; # show remote channel list (nick-list) set SendTopic 1; # show remote topic # Send to other bot set SendJoin 1; # Send joins set SendPart 1; # Send parts set SendSign 1; # Send signs set SendNick 1; # Send nick changes set SendMode 1; # Send mode changes set SendUser 1; # send userlist set SendTopc 1; # send topic set FromChan "#cybex.test"; # sender channel set FromBot ${::botnet-nick}; # sender botnet-nick set ToChan ""; # receiver channel set ToBot ""; # receiver botnet-nick if {${::botnet-nick}=="Devel2"} { set SendWelcome 0; set SendJoin 0; set SendPart 0; set SendSign 0; set SendNick 0; set SendMode 0; set FromBot ${::botnet-nick}; set FromChan "#TCL" #set FromBot ${::botnet-nick}; set FromChan "#cybex.test" set ToBot "Devel3"; set ToChan "#TCL.QuakeNet" } if {${::botnet-nick}=="Devel3"} { set Welcome "Welcome in #TCL.QuakeNet / Please dont spam, repeat, ask for someone here / Ask a question and wait a moment"; set SendWelcome 1; set SendJoin 1; set SendPart 1; set SendSign 1; set SendNick 1; set SendMode 0; set SendUser 1; set SendTopc 1; set FromBot ${::botnet-nick}; set FromChan "#TCL.QuakeNet" set ToBot "Devel2"; set ToChan "#TCL" #set ToBot "Devel2"; set ToChan "#cybex.test" } if {${::botnet-nick}=="GPL"} { set SendJoin 1; set SendPart 1; set SendSign 1; set SendNick 1; set SendMode 0; set SendUser 1; set SendTopc 0; set FromBot ${::botnet-nick}; set FromChan "#berlin" #set FromBot ${::botnet-nick}; set FromChan "#gplracer" set ToBot "20mark"; set ToChan "#grandprixlegends" #set ToBot "20mark"; set ToChan "#cybex.test" } if {${::botnet-nick}=="20mark"} { set SendJoin 1; set SendPart 1; set SendSign 1; set SendNick 1; set SendMode 0; set SendUser 1; set SendTopc 0; set FromBot ${::botnet-nick}; set FromChan "#grandprixlegends" #set FromBot ${::botnet-nick}; set FromChan "#cybex.test" set ToBot "GPL"; set ToChan "#berlin" #set ToBot "GPL"; set ToChan "#gplracer" } # advanced mode # chan botnet-nick chan botnet-nick ?chan botnet-nick ..? # only required, when link more then 2 bots like: # set Links [list [list SenderChan SenderBot] [list ReceiverChan1 ReceiverBot1] [list ReceiverChan2 ReceiverBot2] [list ReceiverChan3 ReceiverBot3]] set Links [list [list $FromChan $FromBot] [list $ToChan $ToBot]] #### its not required, edit blow here #### #if {${::botnet-nick}=="GPL" || ${::botnet-nick}=="20mark"} {set Links [list [list GPL #berlin] [list GPL #gplracer2] [list 20mark #grandprixlegends]]} if ![info exist LastTopic] {set LastTopic ""} if ![info exist ChannelList] {set ChannelList ""} if ![info exist ChannelFullList] {set ChannelFullList ""} if ![info exist ChannelTime] {set ChannelTime 0} if ![info exist ChannelNum] {set ChannelNum 0} proc c_setclist args { if $LinkChan::SendUser { #putcmdlog "sendclist to bot [llength [chanlist $LinkChan::FromChan]] [chanlist $LinkChan::FromChan]" set ctime [clock seconds] set cnum [llength [chanlist $LinkChan::FromChan]] set clist [chanlist $LinkChan::FromChan] #if {[llength $clist]>25} {set clist [lrange $clist 0 24]; lappend clist ".."} #putbot $LinkChan::ToBot "cylinkclist $ctime $cnum $clist" set i 0; set max 5; while {[llength $clist]>0} { if {[llength $clist]>$max} {set nlist [lrange $clist 0 [expr $max-1]]} {set nlist $clist} set blist [list]; foreach user $nlist {if {[matchattr [nick2hand $user] b] || [isbotnick $user]} {lappend blist 1} {lappend blist 0} } putcmdlog "c_setclist: send [expr $max*$i] to [expr $max*($i+1)-1] $ctime $cnum $nlist $blist " putbot $LinkChan::ToBot "cylinkclist $ctime $cnum $nlist $blist" set clist [lrange $clist $max end]; incr i } } } proc c_getclist args { putcmdlog "c_getclist: args $args" set temp [lindex $args 2] set ctime [lindex $temp 0] if {$ctime!=$LinkChan::ChannelTime} { set LinkChan::ChannelTime $ctime set LinkChan::ChannelNum [lindex $temp 1] set LinkChan::ChannelList [list] set LinkChan::ChannelFullList [list] set clist [lrange $temp 2 end] set blist [lrange $clist [expr [llength $clist]/2] end] set clist [lrange $clist 0 [expr [llength $clist]/2-1]] #putcmdlog "c_getclist: New channel clist $clist [llength $clist] - blist $blist [llength $blist]- temp $temp" set i 0; foreach user $clist { lappend LinkChan::ChannelFullList $user if {[onchan $user] && !$LinkChan::SendChannelDouble} { #putcmdlog "c_getclist: ignore user $user -" } { if {[lindex $blist $i] && !$LinkChan::SendChannelBots} { #putcmdlog "c_getclist: ignore bot $user -" } { if {[llength $LinkChan::ChannelList]<$LinkChan::SendChannelMax} { #putcmdlog "c_getclist: append user $user -" lappend LinkChan::ChannelList $user } { if {[llength $LinkChan::ChannelList]==$LinkChan::SendChannelMax} { #putcmdlog "c_getclist: max user reached -" lappend LinkChan::ChannelList ".." } { #putcmdlog "c_getclist: list is full" } } } } incr i } } { if {[llength $LinkChan::ChannelList]>$LinkChan::SendChannelMax} { #putcmdlog "c_getclist: append max user reached -" #return } #set clist [lrange $temp 2 end] set clist [lrange $temp 2 end] #putcmdlog "expr [expr [llength $clist]/2] - len [llength $clist]" set blist [lrange $clist [expr [llength $clist]/2] end] set clist [lrange $clist 0 [expr [llength $clist]/2-1]] #putcmdlog "c_getclist: Append channel clist $clist / [llength $clist] - blist $blist / [llength $blist] - temp $temp" set i 0; foreach user $clist { lappend LinkChan::ChannelFullList $user if {[onchan $user] && !$LinkChan::SendChannelDouble} { #putcmdlog "c_getclist: ignore user $user -" } { if {[lindex $blist $i] && !$LinkChan::SendChannelBots} { #putcmdlog "c_getclist: ignore bot $user -" } { if {[llength $LinkChan::ChannelList]<$LinkChan::SendChannelMax} { #putcmdlog "c_getclist: append user $user -" lappend LinkChan::ChannelList $user } { if {[llength $LinkChan::ChannelList]==$LinkChan::SendChannelMax} { #putcmdlog "c_getclist: max user reached -" lappend LinkChan::ChannelList ".." } { #putcmdlog "c_getclist: list is full" } } } } incr i } } } proc c_settopic args { if $LinkChan::SendTopic { #putcmdlog "sendtopic [topic $LinkChan::FromChan] to bot $LinkChan::ToBot" putbot $LinkChan::ToBot "cylinktopic [topic $LinkChan::FromChan]" } } proc c_gettopic args { #putcmdlog "set LinkChan::LastTopic [lindex $args 2]" set LinkChan::LastTopic [lindex $args 2] } proc stripcc {string} { regsub -all {\002|\037|\017|\026|\003[0-9]{0,2}(,[0-9]{1,2})?} $string {} string return $string } proc sendlink { nick uhost handle channel {arg1 ""} {arg2 ""} {arg3 ""} } { set found 0 set msg "" foreach Link $LinkChan::Links { foreach { chan bot } $Link { if {[string match -nocase ${::botnet-nick} $bot] && [string match -nocase $chan $channel]} { set found 1 } } } if {$found=="1"} { if [isop $nick $channel] { set msg \@ } elseif [isvoice $nick $channel] { set msg \+ } { set msg \- } #putcmdlog "foreach" #putcmdlog "cylinkmsg $chan $nick $uhost $handle $channel $msg $arg1 $arg2 $arg3" foreach Link $LinkChan::Links { foreach { chan bot } $Link { if {![string match -nocase ${::botnet-nick} $bot] || ![string match -nocase $channel $chan]} { #putcmdlog "$bot ..." putbot $bot [subst -nocommands {cylinkmsg $chan $nick $uhost $handle $channel $msg $arg1 $arg2 $arg3}] } } } #putcmdlog "before found" } #putcmdlog "after found" return $msg } proc c_names {text} { ##bots #GPL regsub -all Grand-Prix-Legends $text "GPL" text; #regsub -all {[-20-Mark-]} $text "20Mark" text; #regsub -all {|--Fiese--|} $text "Fiese" text; #regsub -all {|-FLusche-|} $text "Flusche" text; #regsub -all b0rk $text "b\*rk" text; ##kern #badbull #regsub -all badbull $text "b*dbull" text; #regsub -all Badbull $text "B*dbull" text; #regsub -all BadBull $text "B*dBull" text; #cybex regsub -all cybex $text "c*bex" text; regsub -all CyBex $text "C*Bex" text; #regsub -all Thomas $text "T*omas" text; #regsub -all Hagen $text "H*gen" text; #damis #regsub -all Damis $text "Damis" text; #fabskimo #regsub -all fabskimo $text "f*bskimo" text; #regsub -all Fabskimo $text "F*bskimo" text; #gecco #regsub -all Gecco $text "G*cco" text; #giant #regsub -all Giant $text "G*ant" text; #hypa #regsub -all HYPA $text "H*PA" text; #regsub -all hypa $text "h*pa" text; #miele #regsub -all Miele $text "M*ele" text; #massa #regsub -all Massa $text "M*ssa" text; #regsub -all massa $text "m*ssa" text; #mcfly #regsub -all McFly $text "M*Fly" text; #regsub -all Mcfly $text "M*fly" text; #regsub -all mcfly $text "m*fly" text; #temmink #regsub -all Temmink $text "T*mmink" text; #vedder #regsub -all vedder $text "v*dder" text; ##gaeste #HamerFowl #regsub -all Hamer $text "H*mer" text; #regsub -all Hammer $text "H*mmer" text; #Roady #regsub -all Roady $text "R*ady" text; #regsub -all Pfotenpuff $text "P*otenpuff" text; #Sputnik #regsub -all Sputnik $text "S*utnik" text; #regsub -all sputnik $text "s*utnik" text; return $text } proc c_statsmod {} { if {[lsearch [modules] stat*]!=-1} { if [info exist ::statsfile] {return 1} } return 0 } proc c_mel {} { if [info exist ::mel_chanid] { if [info exist ::melinitfile] {return 1} } return 0 } proc c_stats { type nick host hand chan {arg1 ""} {arg2 ""} } { #putcmdlog "c_stats: 1:$arg1 2:$arg2" set onick [nick2hand $hand] if {$onick=="" || $onick=="*"} { #putcmdlog "c_stats: no destination nick found for $nick" } { #putcmdlog "c_stats: use for $nick the remote name $onick" set snick $nick; set nick $onick; } set arg [string trim "$arg1 $arg2"] if [c_mel] { switch $type { pubm { mel_chatter $nick $host $hand $chan $arg } back { mel_enter $nick $host $hand $chan } join { mel_enter $nick $host $hand $chan } part { mel_partinga $nick $host $hand $chan $arg } sign { #putcmdlog "mel_signoff $nick $host $hand $chan $arg" mel_signoff $nick $host $hand $chan $arg } gjoin { mel_signoff $nick $host $hand $chan $arg } glist { mel_signoff $nick $host $hand $chan $arg } gded { mel_signoff $nick $host $hand $chan $arg } topc { mel_ctopic $nick $host $hand $chan $arg } kick { mel_kicked $nick $host $hand $chan $arg1 $arg2 } nick { mel_nickchange $nick $host $hand $chan $arg } mode { mel_cmode $nick $host $hand $chan $arg1 $arg2 } ctcp { mel_caction $nick $host $hand $chan $arg1 $arg2 } default { putcmdlog "c_mel $type" } } } if [c_statsmod] { switch $type { pubm { *pubm:stat $nick $host $hand $chan $arg } back { *join:stat $nick $host $hand $chan } join { *join:stat $nick $host $hand $chan } part { *part:stat $nick $host $hand $chan $arg } gjoin { *sign:stat $nick $host $hand $chan $arg } gded { *sign:stat $nick $host $hand $chan $arg } glist { *sign:stat $nick $host $hand $chan $arg } sign { *sign:stat $nick $host $hand $chan $arg } topc { *topc:stat $nick $host $hand $chan $arg } kick { *kick:stat $nick $host $hand $chan $arg1 $arg2 } nick { *nick:stat $nick $host $hand $chan $arg } mode { *mode:stat $nick $host $hand $chan $arg1 $arg2 } ctcp { *ctcp:stat $nick $host $hand $chan $arg1 $arg2 } default { putcmdlog "c_statsmod $type" } } } } proc c_botmsg { from trigger arg } { #putcmdlog "from $from - trigger $trigger - args $arg" set list [split $arg] #putcmdlog "1.1" set tochan [lindex $list 0] set nick [lindex $list 1] set uhost [lindex $list 2] set handle [lindex $list 3] set fromchan [lindex $list 4] set status [lindex $list 5] if {[lindex $list 6]==""} { #putcmdlog "$fromchan all clear" set type "" set arg2 "" set arg3 "" } elseif {[lindex $list 7]==""} { #putcmdlog "$fromchan one arg [lindex $list 6]" set type [lindex $list 6] set arg2 "" set arg3 "" } elseif {[lindex $list 8]==""} { #putcmdlog "$fromchan two args" set type [lindex $list 6] set arg2 [lindex $list 7] set arg3 "" } { #putcmdlog "$fromchan more args" set type [lindex $list 6] set arg2 [lindex $list 7] set arg3 [join [lrange $list 8 end]] } set onick $nick; set oarg2 $arg2; set oarg3 $arg3; c_stats $type $nick $uhost $handle $tochan $arg2 $arg3 set nick [c_names $nick] set fromchan [c_names $fromchan] set arg1 [string trim [c_names "$arg2 $arg3"]] set arg2 [c_names $arg2] set arg3 [c_names $arg3] if {$status=="-"} {set status ""} set nick [c_names $nick] if {[onchan $nick] || [onchan $onick]} { set nick [string replace $nick 1 1 *] } # #putcmdlog "onchan $onick [onchan $onick] - type $type" if {[onchan $onick]} { switch -exact -- $type { join - nick - mode - sign { putcmdlog "don't send $type - nick $nick is in both" return } } } if {![onchan $onick]} { switch -exact -- $type { gjoin - gded - glist - back { putcmdlog "dont send $type - nick $nick is not in both, but do" #return } default { #putcmdlog "send $type - nick $nick is not in both" } } } #putcmdlog "new send type to $tochan - nick $nick - from $fromchan - args t:'$type' 2:'$arg2' 3:'$arg3'" switch -exact -- $type { gjoin { putmsg $tochan "* $status$nick joins GPL race hostet by $arg1" } gded { putmsg $tochan "* $status$nick host a dedicated server" } glist { putmsg $tochan "* $status$nick host a listen server" } back { putmsg $tochan "* Back from game: $status$nick" } pubm { putmsg $tochan "\<$status$nick\> $arg1" } join { putmsg $tochan "* Joins $fromchan: $status$nick" } part { putmsg $tochan "* Parts $fromchan: $status$nick ($arg1)" } sign { putmsg $tochan "* Quits $fromchan: $status$nick ($arg1)" } topc { putmsg $tochan "* $status$nick changes topic to '$arg1'" } kick { putmsg $tochan "* $arg2 was kicked by $nick ($arg3)" } nick { putmsg $tochan "* $nick is now known as $arg2" } mode { putmsg $tochan "* $nick sets mode: $arg1" } ctcp { putmsg $tochan "* $nick $arg3" } default { putcmdlog "new send type to $tochan - nick $nick - from $fromchan - args t:'$type' 2:'$arg2' 3:'$arg3'" } } } proc c_dcc { { args "" } } { putcmdlog "c_dcc: $args" } proc c_pubm { nick uhost handle channel text } { #putcmdlog "n:$nick [string match -nocase $LinkChan::FromChan $channel] $LinkChan::FromChan $channel" if ![string match -nocase $LinkChan::FromChan $channel] return #putcmdlog "sendlink $nick $uhost $handle $channel pubm $text " sendlink $nick $uhost $handle $channel pubm [stripcc $text] } proc c_join { nick uhost handle channel } { if ![string match -nocase $LinkChan::FromChan $channel] return utimer 3 [namespace current]::c_setclist if $LinkChan::SendJoin { sendlink $nick $uhost $handle $channel join } if $LinkChan::SendWelcome { putlog "send welcome to $nick!$uhost ($handle) $channel" set i 2; if {$LinkChan::Welcome!=""} {utimer $i [list putnotc $nick $LinkChan::Welcome]; incr i 2} if {$LinkChan::SendTopic && $LinkChan::LastTopic!=""} {utimer $i [list putnotc $nick "Topic in $LinkChan::ToChan is: $LinkChan::LastTopic"]; incr i 2} if {$LinkChan::SendChannel && [join $LinkChan::ChannelList ", "]!=""} {utimer $i [list putnotc $nick "$LinkChan::ChannelNum Users online: [join $LinkChan::ChannelList ", "]"]; incr i 2} } } proc c_part { nick uhost handle channel text } { if ![string match -nocase $LinkChan::FromChan $channel] return #if {[string match -nocase *cybex* $nick] || [string match -nocase *thommey* $nick]} return utimer 3 [namespace current]::c_setclist if $LinkChan::SendPart { sendlink $nick $uhost $handle $channel part [stripcc $text] } } proc c_sign { nick uhost handle channel text } { if ![string match -nocase $LinkChan::FromChan $channel] return #if {[string match -nocase *cybex* $nick] || [string match -nocase *thommey* $nick]} return utimer 3 [namespace current]::c_setclist if $LinkChan::SendSign { sendlink $nick $uhost $handle $channel sign [stripcc $text] } } proc c_topc { nick uhost handle channel text } { if ![string match -nocase $LinkChan::FromChan $channel] return c_settopic if $LinkChan::SendTopc { sendlink $nick $uhost $handle $channel topc [stripcc $text] } } proc c_kick { nick uhost handle channel knick {text "" } } { if ![string match -nocase $LinkChan::FromChan $channel] return utimer 3 [namespace current]::c_setclist sendlink $nick $uhost $handle $channel kick $knick [stripcc $text] } proc c_nick { nick uhost handle channel text } { if ![string match -nocase $LinkChan::FromChan $channel] return utimer 3 [namespace current]::c_setclist if $LinkChan::SendNick { sendlink $nick $uhost $handle $channel nick [stripcc $text] } } proc c_mode { nick uhost handle channel mc { text "" } } { if ![string match -nocase $LinkChan::FromChan $channel] return if $LinkChan::SendMode { sendlink $nick $uhost $handle $channel mode $mc [stripcc $text] } } proc c_ctcp { nick uhost handle channel key { text "" } } { if ![string match -nocase $LinkChan::FromChan $channel] return sendlink $nick $uhost $handle $channel ctcp $key [stripcc $text] } bind bot - cylinkclist LinkChan::c_getclist bind bot - cylinktopic LinkChan::c_gettopic bind bot - cylinkmsg LinkChan::c_botmsg bind dcc * chat LinkChan::c_dcc bind pubm - * LinkChan::c_pubm bind join - * LinkChan::c_join bind sign - * LinkChan::c_sign bind topc - * LinkChan::c_topc bind kick - * LinkChan::c_kick bind nick - * LinkChan::c_nick bind mode - * LinkChan::c_mode bind part - * LinkChan::c_part bind ctcp - "ACTION" LinkChan::c_ctcp #bind pub - !link LinkChan::c_link bind bot - cylinkupdate LinkChan::c_linkupdate proc c_link {n u h c t} { putcmdlog "c_link n:$n c:$c t:$t u:$::username" if {$::username!="gpl" && $::username!="20mark"} { putcmdlog "link: wrong bot: $::username" return } if {$::username=="gpl"} { if {[lsearch -exact [list #gplracer #berlin] [string tolower $c]]==-1} { putcmdlog "link: wrong chan: $c ($::username)" return } } if {$::username=="20mark"} { if {[lsearch -exact [list #grandprixlegends #gpl] [string tolower $c]]==-1} { putcmdlog "link: wrong chan: $c ($::username)" return } } putcmdlog "switch FromChan:$LinkChan::FromChan or ToChan:$LinkChan::ToChan" putbot $LinkChan::ToBot cylinkupdate if {${::username}=="gpl"} { putmsg $LinkChan::FromChan "Link zu $LinkChan::ToChan deaktiviert.." if {[string mat -noc "#gplracer*" $LinkChan::FromChan]} { set LinkChan::FromChan "#berlin" } { set LinkChan::FromChan "#gplracer" } putmsg $LinkChan::FromChan "Link zu $LinkChan::ToChan aktiviert.." } if {${::username}=="20mark"} { if {[string mat -noc "#gplracer*" $LinkChan::ToChan]} { set LinkChan::ToChan "#berlin" } { set LinkChan::ToChan "#gplracer" } putmsg $LinkChan::FromChan "Link zu $::LinkChan::ToChan aktiviert.." } set LinkChan::Links [list [list $LinkChan::FromChan $LinkChan::FromBot] [list $LinkChan::ToChan $LinkChan::ToBot]] putcmdlog " done FromChan:$LinkChan::FromChan or ToChan:$LinkChan::ToChan" } proc c_linkupdate {f k t} { putcmdlog "switch FromChan:$LinkChan::FromChan or ToChan:$LinkChan::ToChan" if {${::username}=="gpl"} { putmsg $LinkChan::FromChan "Link zu $LinkChan::ToChan deaktiviert.." if {[string mat -noc "#gplracer*" $LinkChan::FromChan]} { set LinkChan::FromChan "#berlin" } { set LinkChan::FromChan "#gplracer" } putmsg $LinkChan::FromChan "Link zu $LinkChan::ToChan aktiviert.." } if {${::username}=="20mark"} { if {[string mat -noc "#gplracer*" $LinkChan::ToChan]} { set LinkChan::ToChan "#berlin" } { set LinkChan::ToChan "#gplracer" } putmsg $LinkChan::FromChan "Link zu $::LinkChan::ToChan aktiviert.." } set LinkChan::Links [list [list $LinkChan::FromChan $LinkChan::FromBot] [list $LinkChan::ToChan $LinkChan::ToBot]] putcmdlog " done FromChan:$LinkChan::FromChan or ToChan:$LinkChan::ToChan" } } #LinkChan::c_settopic #LinkChan::c_setclist #LinkChan::c_setclist return [split "LinkChan 0.4 / ${::botnet-nick}"]