All pastes #509132 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-05-25 09:42 UTC
rendered paste body
#!/usr/bin/tclsh
############################################################################
# Title: FSERV script
# HomePage: http://www.ofloo.net/
# Mail: support[at]ofloo.net
############################################################################
# Description: 
#   - Mirc like fserv script with most of the mirc features included still
#     working on some of the features.
#   - Current command list "pwd, whoami, get, ls, list, dir, help, credit,
#     cd, cd .."
#   - Channel commands !list, !who (owner command), and your fserv triggers.
# Notes: 
#   - This is a pre release.
#   - Known bug if the users 2 users or more start a dcc chat instantly 
#     one after an ohter the first user could have the same nick, on whoami
#     this also affects dccsend so if they leave like 1 second or more 
#     between a channel trigger then all works just fine
# ToDo:
#   - Create queue system.
#   - Fix the nick bug witch is minimal but still.
#   - Create expanded timers and settings.
#   - Create more commands.
# Install:
#   - source scripts/fserv.tcl > eggdrop.conf
#   - set the settings below
############################################################################

############################################################################
# SETTINGS

##### Transfer module this module is standart and can be set in your eggdrop.conf as well

loadmodule transfer

# Max downloads for each user
set max-dloads 1

# Dcc blocksize set to 0 for turbo dcc 
set dcc-block 0

# Disable this if your using this script i don't recommend it precaching files 
set copy-to-tmp 0

# Xfer time out inseconds
set xfer-timeout 30

# Script settings 

# Set dcc port
set fserv(port) "5000"

# Set serv channel, this channel can not be a dynamic channel.
set fserv(serv) "#ourhut"

# Bind triggers chan, ctcp, query, list cmd
set fserv(chan) "!fserv"
set fserv(ctcp) "!what"
set fserv(msg) ".fserv"
set fserv(list) "!list"

# Set what sort of trigger you will be using choose: 0=chan, 1=ctcp, 2=query
set status(type) "0"

# Enable/disable logon msg
set fserv(logon) "1"

# Enable channel timer
set fserv(timer) "1"

# Enable list command
set fserv(lists) "1"

# Fserv directory do not use \\ and end always with /
set homepath "/home/trouble/Desktop/eggdrop/filesys/testing/"

##### Colors

# Color channel and query colors
set colors(0) "\00314"
set colors(1) "\0034"

# Color: dir, file
set colors(2) "\00312"
set colors(3) "\00315"

# Color: <sepe>, <titl>, <body>
set colors(4) "\00314"
set colors(5) "\0034"
set colors(6) "\00315"

# Color: commen errors
set colors(7) "\0034"

# Color: timer
set colors(8) "\00314"
set colors(9) "\0034"

##### Messages

# Dcc error msg
set ::dccreturnmsg(0) "Sending file.."
set ::dccreturnmsg(1) "To many connections at the moment."
set ::dccreturnmsg(2) "Can't open socket for transfer."
set ::dccreturnmsg(3) "The requested file does not exist."
set ::dccreturnmsg(4) "File was put in queue."
set ::dccreturnmsg(5) "Error file allready precached. Report this to owner tnx."

set fserv(idle) "You have been idle for 50 seconds dcc will close in 10 seconds.."

set fserv(invalddir) "- Error invalid directory."

set fserv(desc) "porno"

# Welcome msg edit to ur preference. I created different tags so u can color the logonmsg
# Plz note that u always need to use the first tags .. or it won't show all the text on logon
# <sepe>: Seperator
# <titl>: Title line
# <body>: Body line
set ::fserv(welcome) {
  <sepe>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  <titl>  ** Welcome to my Fserv file server this is not a public file server **
  <sepe>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  <body>- October 03, 2003] If you are affiliated with any government, police.
  <body>  ANTI-Piracy Group, RIAA, MPAA, FBI, movie production
  <body>  company / distribution company or group, or any other related group you
  <body>  are violating code 431.322.12 of the Internet Privacy Act signed by
  <body>  Bill Clinton in 1995. So you have to leave this server..
  <body>- This is a private server. Stay in channel while leeching it or be kicked.
  <sepe>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}

# Do not edit below unless u know what ur doing :p
# Advertice timer is set to 10 minutes

set vrs "0.1"

############################################################################
# BINDS

bind pub - $fserv(chan) fserv:pub
bind pub - $fserv(list) list:pub
bind pub n !who who:pub
bind msg - $fserv(msg) fserv:msg
bind ctcp - $fserv(ctcp) fserv:ctcp
bind time - "?0 * * * *"  fserv:timer

############################################################################
# PROCS

listen $fserv(port) script listen:start

proc fserv:pub {nick uhost hand chan arg} {
  if {![isdynamic $::fserv(serv)]} {
    if {$::status(chan) == 0 && [onchan $nick $::fserv(serv)]} {
      set identcheck "0"
      foreach line [dcclist] {
        if {[string match -nocase $line ident]} {
          set identcheck "1"
	}
      }
      if {$identcheck == 1} {
        after 5000
        putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $::fserv(port)\001"
        set ::dccnick $nick
      } elseif {$identcheck == 0} {
      	putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $::fserv(port)\001"
        set ::dccnick $nick
      }
    }
  }
}

proc fserv:ctcp {nick uhost hand dest keyword arg} {
  if {![isdynamic $::fserv(serv)]} {
    if {$::status(type) == 1 && [onchan $nick $::fserv(serv)]} {
      set identcheck "0"
      foreach line [dcclist] {
        if {[string match -nocase $line ident]} {
          set identcheck "1"
	}
      }
      if {$identcheck == 1} {
        after 5000
        putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $::fserv(port)\001"
        set ::dccnick $nick
      } elseif {$identcheck == 0} {
      	putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $::fserv(port)\001"
        set ::dccnick $nick
      }
    }
  }
}

proc fserv:msg {nick uhost hand arg} {
  if {![isdynamic $::fserv(serv)]} {
    if {$::status(msg) == 2 && [onchan $nick $::fserv(serv)]} {
      set identcheck "0"
      foreach line [dcclist] {
        if {[string match -nocase $line ident]} {
          set identcheck "1"
	}
      }
      if {$identcheck == 1} {
        after 5000
        putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $::fserv(port)\001"
        set ::dccnick $nick
      } elseif {$identcheck == 0} {
      	putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $::fserv(port)\001"
        set ::dccnick $nick
      }
    }
  }
}

# Pre control proc
proc listen:start {idx} {
  set dccnick($idx) $::dccnick
  control $idx [list listen:control $dccnick($idx)]
  if {[info exists ::dccpwd($idx)] == 1} {
    unset ::dccpwd($idx)
  }
  if {[info exists ::prompt($idx)] == 1} {
    unset ::prompt($idx)
  }
  if {[info exists ::timedcc($idx)] == 1} {
    catch {killutimer $::timedcc($idx)}
    catch {unset ::timedcc($idx)}
  }
  if {[info exists ::timemsg($idx)] == 1} {
    catch {killutimer $::timemsg($idx)}
    catch {unset ::timemsg($idx)}
  }
  if {$::fserv(logon) == 1} {
    foreach line [split $::fserv(welcome) \n] {
      set type [lindex [split [lindex [split $line \x3C] 1] \x3E] 0]
      set text [lindex [split $line \x3E] 1]
      if {[string match -nocase $type sepe]} {
        putdcc $idx "$::colors(0)-$::colors(4) $text"
      }
      if {[string match -nocase $type titl]} {
        putdcc $idx "$::colors(0)-$::colors(5) $text"
      }
      if {[string match -nocase $type body]} {
        putdcc $idx "$::colors(0)-$::colors(6) $text"
      }
    }
  }
  catch {set ::timedcc($idx) [utimer 60 [list catch [list killdcc $idx]]]}
  catch {set ::timemsg($idx) [utimer 50 [list catch [list putdcc $idx "$::colors(0)$::fserv(idle)"]]]}
}

# Control proc 
proc listen:control {nick fidx arg} {
  global vrs homepath
  if {[valididx $fidx]} {
    if {[info exists ::timedcc($fidx)] == 1} {
      catch {killutimer $::timedcc($fidx)}
    }
    if {[info exists ::timemsg($fidx)] == 1} {
      catch {killutimer $::timemsg($fidx)}
    }
    set fserv(cmd) [lindex [string map {\[ \\\[ \] \\\] \{ \\\{ \} \\\}} $arg] 0]
    set fserv(arg) [join [lrange [string map {\[ \\\[ \] \\\] \{ \\\{ \} \\\}} $arg] 1 end]]
    catch {set ::timemsg($fidx) [utimer 50 [list catch [list putdcc $fidx "$::colors(0)$::fserv(idle)"]]]}
    catch {set ::timedcc($fidx) [utimer 60 [list catch [list killdcc $fidx]]]}
    if {[info exists ::dccpwd($fidx)] == 0} {
      set ::dccpwd($fidx) $homepath
      set ::prompt($fidx) "/"
    }
    if {"[string tolower $fserv(cmd)]" == "ls" || "[string tolower $fserv(cmd)]" == "list" || "[string tolower $fserv(cmd)]" == "dir"} {  
      putdcc $fidx "$::colors(0)-$::colors(2) .."
      foreach line [glob -nocomplain -type d $::dccpwd($fidx)*] { 
        putdcc $fidx "$::colors(0)-$::colors(2) [file tail [file nativename $line]]"
      }
      foreach line [glob -nocomplain -type f $::dccpwd($fidx)*] { 
        putdcc $fidx "$::colors(0)-$::colors(3) [file tail [file nativename $line]] $::colors(0) [format %.2f [expr [file size $line] / 1024.0]] kb"
      }
      putdcc $fidx "$::colors(0)$::prompt($fidx)"
    }
    if {"[string tolower $fserv(cmd)]" == "cd" && "[string tolower $fserv(arg)]" != ".." && "[string tolower $fserv(cmd)]" != {}} {
      set fserv(check) "0"
      foreach line [glob -nocomplain -type d $::dccpwd($fidx)*] { 
        if {[string match -nocase $fserv(arg) [file tail [file nativename $line]]]} {
          set ::dccpwd($fidx) "$::dccpwd($fidx)$fserv(arg)/"
          set ::prompt($fidx) "$::prompt($fidx)$fserv(arg)/"
	  set fserv(check) "[expr $fserv(check)+1]"
          putdcc $fidx "$::colors(0)$::prompt($fidx)"
        }
      }
      if {$fserv(check) == 0} {
        putdcc $fidx "$::colors(7)$::fserv(invalddir)"
      }
    }
    if {"[string tolower $fserv(cmd)]" == "get"} {
      if {[onchan $nick $::fserv(serv)]} {
        set ::dccretrun($fidx) [dccsend "$::dccpwd($fidx)$fserv(arg)" $nick]
        if {$::dccretrun($fidx) == 0} {
          putdcc $fidx "$::colors(0)- $::dccreturnmsg(0)"
        }
        if {$::dccretrun($fidx) == 1} {
          putdcc $fidx "$::colors(0)- $::dccreturnmsg(1)"
        }
        if {$::dccretrun($fidx) == 2} {
          putdcc $fidx "$::colors(0)- $::dccreturnmsg(2)"
        }
        if {$::dccretrun($fidx) == 3} {
          putdcc $fidx "$::colors(0)- $::dccreturnmsg(3)"
        }
        if {$::dccretrun($fidx) == 4} {
          putdcc $fidx "$::colors(0)- $::dccreturnmsg(4)"
        }
        if {$::dccretrun($fidx) == 5} {
          putdcc $fidx "$::colors(0)- $::dccreturnmsg(5)"
        }
      }
    }
    if {"[string tolower $fserv(cmd)]" == "whoami"} {
      putdcc $fidx "$nick"
    }
    if {"[string tolower $fserv(cmd)]" == "cd" && "[string tolower $fserv(arg)]" == ".."} {
      if {$::dccpwd($fidx) != $homepath || $::prompt($fidx) != "\x2F"} {
        set ::dccpwd($fidx) [string trimright "$::dccpwd($fidx)" "[file tail $::dccpwd($fidx)]\x2F"]\x2F
        set ::prompt($fidx) [string trimright "$::prompt($fidx)" "[file tail $::prompt($fidx)]\x2F"]\x2F
        putdcc $fidx "$::colors(0)$::prompt($fidx)"
      }
    }
    if {"[string tolower $fserv(cmd)]" == "pwd"} { 
      putdcc $fidx "$::colors(0)$::prompt($fidx)"
    }
    if {"[string tolower $fserv(cmd)]" == "help"} {
      if {"[string tolower $fserv(arg)]" == ""} {
        putdcc $fidx "$::colors(0)--------------------------------------------------------------------------------"
        putdcc $fidx "$::colors(0)*** Use help <cmd> for more info on the command."
        putdcc $fidx "$::colors(0)*** Command list:"
        putdcc $fidx "$::colors(0)- Ls, dir, list:$::colors(1) Dirlist commands"
        putdcc $fidx "$::colors(0)- Cd , cd ..:$::colors(1) Change dirs"
        putdcc $fidx "$::colors(0)- Pwd:$::colors(1) Show current path."
        putdcc $fidx "$::colors(0)- Get:$::colors(1) Download file."
        putdcc $fidx "$::colors(0)- whoami:$::colors(1) Shows ur current logon nick."
        putdcc $fidx "$::colors(0)- Help:$::colors(1) Shows this menu."
        putdcc $fidx "$::colors(0)- Credit:$::colors(1) Where to get this script and who made this."
        putdcc $fidx "$::colors(0)--------------------------------------------------------------------------------"
      }
      if {"[string tolower $fserv(arg)]" == "get"} {
        putdcc $fidx "$::colors(0)*** This command provides you the ability to download a file from fserv."
        putdcc $fidx "$::colors(0)- Usage: get <filename>"
      }
      if {"[string tolower $fserv(arg)]" == "list" || "[string tolower $fserv(arg)]" == "dir" || "[string tolower $fserv(arg)]" == "ls"} {
        putdcc $fidx "$::colors(0)***This command provides you with the ability to list dirs and files."
        putdcc $fidx "$::colors(0)- Usage: [string tolower $fserv(arg)]"
      }
      if {"[string tolower $fserv(arg)]" == "cd"} {
        putdcc $fidx "$::colors(0)***This command provides you with the ability to brouse directorys."
        putdcc $fidx "$::colors(0)- Usage: cd <dirname>"
      }
      if {"[string tolower $fserv(arg)]" == "whoami"} {
        putdcc $fidx "$::colors(0)*** Returns your current nick name."
        putdcc $fidx "$::colors(0)Usage: whoami"
      }
      if {"[string tolower $fserv(arg)]" == "pwd"} {
        putdcc $fidx "$::colors(0)*** This command shows the current path."
        putdcc $fidx "$::colors(0)- Usage: pwd"
      }
    }
    if {"[string tolower $fserv(cmd)]" == "credit"} {
      putdcc $fidx "$::colors(0)--------------------------------------------------------------------------------"
      putdcc $fidx "$::colors(0)- Fserv Script $vrs help section"
      putdcc $fidx "$::colors(0)- This script is made by Ofloo"
      putdcc $fidx "$::colors(0)- HomePage: http://www.ofloo.net/"
      putdcc $fidx "$::colors(0)- Email: support\[at\]ofloo.net"
      putdcc $fidx "$::colors(0)- Special tnx to the people who help the people on users"
      putdcc $fidx "$::colors(0)\x20 forum at http://www.egghelp.org/"
      putdcc $fidx "$::colors(0)--------------------------------------------------------------------------------"
    }
    if {"[string tolower $fserv(cmd)]" != "credit" && "[string tolower $fserv(cmd)]" != "get" && "[string tolower $fserv(cmd)]" != "cd" && "[string tolower $fserv(cmd)]" != "list" && "[string tolower $fserv(cmd)]" != "dir" && "[string tolower $fserv(cmd)]" != "ls" && "[string tolower $fserv(cmd)]" != "help" && "[string tolower $fserv(cmd)]" != "whoami" && "[string tolower $fserv(cmd)]" != "pwd"} {
      putdcc $fidx "$::colors(0)*** For help type help <cmd> or just help to get a list of commands"
    }
  }
}

proc fserv:timer {min hour day month year} {
  global botnick
  if {$::fserv(timer) == 1} {
    if {$::status(type) == 0} {
      set trigger "$::fserv(chan)"
    } elseif {$::status(type) == 1} {
      set trigger "/ctcp $botnick $::fserv(ctcp)"
    } elseif {$::status(type) == 2} {
      set trigger "/msg $botnick $::fserv(msg)"
    }
    putserv "PRIVMSG $::fserv(serv) :$::colors(8)Fserv trigger:$::colors(9) $trigger$::colors(8) Description:$::colors(9) $::fserv(desc)"
  }
}

proc list:pub {nick uhost hand chan arg} {
  global botnick
  if {[onchan $nick $::fserv(serv)]} {
    if {$::fserv(lists) == 1} {
      if {$::status(type) == 0} {
        set trigger "$::fserv(chan)"
      } elseif {$::status(type) == 1} {
        set trigger "/ctcp $botnick $::fserv(ctcp)"
      } elseif {$::status(type) == 2} {
        set trigger "/msg $botnick $::fserv(msg)"
      }
      putserv "PRIVMSG $::fserv(serv) :$::colors(8)Fserv trigger:$::colors(9) $trigger$::colors(8) Description:$::colors(9) $::fserv(desc)"
    }
  }
}

proc who:pub {nick uhost hand chan arg} {
  foreach line [dcclist] {
    if {[string tolower [lindex $line 3]] == "script"} {
      putserv "NOTICE $nick :$::colors(0)User:$::colors(1) [lindex [split [lindex $line 4] \x20] 3] $::colors(0)UserHost:$::colors(1) [lindex [split [lindex $line 2] \x40] 1]"
    }
    if {[string tolower [lindex $line 3]] == "get"} {
      putserv "NOTICE $nick :$::colors(0)Sending file to: [lindex $line 1]"
    }
  }
}

#####################################################################################
putlog "\002Fserv\002 script version \002$vrs\002 by Ofloo loaded."