############################################################################
####                                                                    ####
####  EZ bot link ver 1.2 Jan 1999 ^DaRk^ - EFnet                       ####
####  For Eggdrop 1.3.*                                                 ####
####  ok, the code might be sloppy since im teaching myself TCL as i go ####
####  i must have learned 30 new commands while making this script :)   ####
####  Basical its for us lazy ppl who hate linking alot of bots.        ####
####  simply put, botA and botB, BotA has the user file, BotB has just  ####
####  been started with an empty user file.                             ####
####                                                                    ####
####  In botA: .master <botB> <botB's IP> <botB's Port>                 ####
####    this replaces the .+bot BotB IP:port , .chattr botB +fox ,      ####
####    and, .botattr botB +gs (to aggressivly share userfiles)         ####
####  In botB: .slave <botA> <botA's IP> <botA's Port>                  ####
####    this replaces the .+bot,  .chattr, and .botattr functions as    ####
####    well, cept the bottr flags are +ghp (botA being a hub bot) and  ####
####    to share passively. (that was for you morons -like myself- who  ####
####    keep forgetting which flag is passive and which is aggressive:) ####
####                                                                    ####
############################################################################
############################################################################
####                                                                    ####
####  Ver 1.2 - fixed hostmask bug (getuser $hand console didnt always  ####
####            work to get the channel name)                           ####
####          - better string handling to accept botnames with -'s and  ####
####            such (-`^) and so on...                                 ####
####          - fixed bug that would leave the trailing " " at the end  ####
####            of the botnick and IP, which screwed everything up.     ####
####                                                                    ####
####  Ver 1.0 - First non puplic release, looked like it worked, but it ####
####            didnt :(                                                ####
####                                                                    ####
####                                                                    ####
####  Send coments/bug reports to: Darkbringer@rocketmail.com           ####
####  send flames/hate mail to: BillGates@MSN.com                       ####       ####
####                                                                    ####
####  Shouts to:    ReJeCt-, DarKni9hT and the crew in #Cable-Iso       ####
####  Much hate to: reddog` and the bitches who took over my channel    ####
####                #cableiso (the first one) and the IRCops who knew   ####
####                it was our chan but didnt do a damn thing to help   ####
####                                                                    ####
############################################################################
############################################################################

bind dcc m master mstr_lnk
bind dcc m slave slav_lnk
global m_bot
global chan
proc mstr_lnk {hand idx args} {
set strn [string trim $args "{"]
set arg [string trim $strn "}"]
if {$arg == ""} {
    putdcc $idx "USAGE: .master <botname> <ip> <port>"
    return 0
  }
    set m_bot [string range $arg 0 [expr [string first " " $arg] -1]]
    set astrn [string trimleft $arg $m_bot]
    set m_port [string range $astrn [string wordstart $astrn 1000] end ]
    set aarg [string trimright $astrn $m_port]
    set m_add [string trimright [string trimleft $aarg " "]]
set m_host "*!"
foreach n [channels] {
if {[getchanhost $m_bot $n] != ""} { 
set nn $n
}
}
append m_host [getchanhost $m_bot $nn]

putlog "EZ-bot add: $m_bot @ $m_add P: $m_port "
putdcc $idx "I will now send my userfile to $m_bot "
putdcc $idx "Written By ^DaRk^"
addbot $m_bot $m_add
setuser $m_bot botaddr $m_add $m_port $m_port
setuser $m_bot hosts $m_host
chattr $m_bot +fox
botattr $m_bot +gs
  return 1
}

proc slav_lnk {hand idx args} {
set strn [string trim $args "{"]
set arg [string trim $strn "}"]
if {$arg == ""} {
    putdcc $idx "USAGE: .slave <botname> <ip> <port>"
    return 0
  }

    set m_bot [string range $arg 0 [expr [string first " " $arg] -1]]
    set astrn [string trimleft $arg $m_bot]
    set m_port [string range $astrn [string wordstart $astrn 1000] end ]
    set aarg [string trimright $astrn $m_port]
    set m_add [string trimright [string trimleft $aarg " "]]
set m_host "*!"
foreach n [channels] {
if {[getchanhost $m_bot $n] != ""} { 
set nn $n
}
}

append m_host [getchanhost $m_bot $nn]

putlog "EZ-bot add: $m_bot @ $m_add P: $m_port "
putdcc $idx "I will accept userfiles from $m_bot now"
putdcc $idx "Written By ^DaRk^"
addbot $m_bot $m_add
setuser $m_bot botaddr $m_add $m_port $m_port
setuser $m_bot hosts $m_host
chattr $m_bot +fox
botattr $m_bot +ghp
  return 1
}
putlog "EZ-botlink.tcl Ver1.2 By ^DaRk^... Loaded"

