egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

get.tcl dcc send

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Thunderdome
Op


Joined: 15 Mar 2005
Posts: 187

PostPosted: Sun Apr 24, 2005 12:28 am    Post subject: get.tcl dcc send Reply with quote

Code:
#####################################
# Get.tcl by KuNgFo0 (www.eggfaq.com)

#VERSION 0.3
#DESCRIPTION Lets people access a specific directory and all its subdirectories to download files from.

# Set the next line as the channels you want to run in
set get(chans) "#channel"
# Set the next line as the directory to allow access to
set get(dir) "/home/blabla/public_html/stuff"
# Set the next line as the command you want
set get(command) "!get"
# Set the next line as the temp file to use to send the dir listing
set get(file) "dirlisting.txt"

proc xrange {xr xr1 xr2} {
 return [join [lrange [split $xr] $xr1 $xr2]]
}

proc xindex {xr xr1} {
 return [join [lrange [split $xr] $xr1 $xr1]]
}

proc pub_get {nick uhost hand chan arg} {
 global get botnick
 if {(([lsearch -exact [string tolower $get(chans)] [string tolower $chan]] != -1) || ($get(chans) == "*")) && (![matchattr $hand b]) && ($nick != $botnick)} {
  msg_get $nick $uhost $hand $arg
 }
}

proc msg_get {nick uhost hand arg} {
 global get
 switch -exact -- [set command [string tolower [xindex $arg 0]]] {
  "find" - "search" {
   if {[set str [xrange $arg 1 end]] == ""} { puthelp "NOTICE $nick :Usage: $get(command) find <file>" } \
   elseif {![get_valid $str]} { puthelp "NOTICE $nick :Error: Invalid filename" } \
   else {
    if {[file isdirectory [set tmp [file join $get(dir) $str]]]} {
     set get(tdir) $tmp
     set file "*"
    } elseif {([string match */* $str]) && ([file isdirectory [set tmp2 [file dirname $tmp]]])} {
     set get(tdir) $tmp2
     set file [file tail $tmp]
    } else {
     set get(tdir) $get(dir)
     set file $str
    }
    set filelist ""
    foreach {file1 file2} [get_list $get(tdir)] {
     if {([string match *[string tolower $file]* [string tolower [file tail $file2]]])} {
      if {[file isdirectory $file1]} { lappend filelist \002$file2/\002 } \
      else { lappend filelist $file2 }
     }
    }
    if {$filelist == ""} { set filelist "None" }
    while {$filelist != ""} {
     puthelp "NOTICE $nick :Matches found (\002$str\002) - [join [lrange $filelist 0 19] ", "]"
     set filelist [lreplace $filelist 0 19]
    }
   }
  }
  "list" {
   if {[catch {open $get(file) w} fileid]} { puthelp "NOTICE $nick :Error: Could not open temp file" } \
   else {
    fconfigure $fileid -translation "crlf" ; # Most people are probably using windows
    puts $fileid "*** Listing contents of $get(dir) (* = new in last day)"
    foreach i "dirs links files bytes" { set get($i) 0 }
    get_write $fileid $get(dir)
    puts $fileid "*** $get(dirs) dirs, $get(links) links, $get(files) files, $get(bytes) bytes"
    close $fileid
    get_send $nick $get(file)
   }
  }
  "help" - "" {
   puthelp "NOTICE $nick :Available commands:"
   puthelp "NOTICE $nick :$get(command) find <file>"
   puthelp "NOTICE $nick :$get(command) <file>"
   puthelp "NOTICE $nick :$get(command) list"
  }
  default {
   if {![get_valid [set file $arg]]} { puthelp "NOTICE $nick :Error: Invalid filename" } \
   elseif {![file exists [set tmp [file join $get(dir) $file]]]} { puthelp "NOTICE $nick :Error: File '$tmp' does not exist" } \
   else { get_send $nick $tmp }
  }
 }
}

proc get_valid {file} {
 return [expr {(![string match *..* $file]) && (![string equal [string index $file 0] "/"])}]
}

proc get_send {nick file} {
 switch -exact -- [dccsend $file $nick] {
  0 { puthelp "NOTICE $nick :Sending [file tail $file]." }
  1 { puthelp "NOTICE $nick :Error: Too many pending file requests. Try again later, thank you." }
  2 { puthelp "NOTICE $nick :Error: Could not open socket. Please notify my admin, thank you." }
  3 { puthelp "NOTICE $nick :Error: File does not exist. Please notify my admin, thank you." }
  4 { puthelp "NOTICE $nick :Error: Too many file sends already in progress. Your request has been added to the queue, please wait." }
  5 { puthelp "NOTICE $nick :Error: Could not move file to temporary directory. Please notify my admin, thank you." }
 }
}

proc get_list {what {pre ""}} {
 if {$pre == ""} { set pre $what }
 set files ""
 foreach file [lsort [glob -nocomplain [file join $what *]]] {
  set file2 [string trimleft [string range $file [string length $pre] end] "./\\"] ; # the filename we actually show to the user
  if {![file readable $file]} {
   continue ; # ignore unreadable files
  } elseif {[file isdirectory $file]} {
   set files [concat $files $file $file2 [join [get_list $file $pre]]]
  } else {
   lappend files $file $file2
  }
 }
 return $files
}

proc get_write {fileid what} {
 global get
 puts $fileid "/"
 foreach {file1 file2} [get_list $what] {
  if {![catch {file type $file1} type]} {
   switch -exact -- $type {
    directory {
     incr get(dirs)
     set temp $file2/
    }
    link {
     incr get(links)
     if {[catch {file readlink $file1} temp]} { set temp "Could not eval symlink" }
     set temp [format "%-60s %s" $file2 "--> $temp"]
    }
    file {
     incr get(files)
     incr get(bytes) [set size [file size $file1]]
     set temp [format "%-50s %10s" $file2 $size]
    }
    default {
     incr get(files)
     set temp $file2
    }
   }
   if {[expr [clock seconds] - [file mtime $file1]] < 86400} {
    puts $fileid  "* $temp"
   } else {
    puts $fileid  "  $temp"
   }
  }
 }
}

set copy-to-tmp 1

bind pub - $get(command) pub_get
bind msg - $get(command) msg_get

if {![file exists $get(dir)]} {
 if {[catch {file mkdir $get(dir)}]}     { putlog "Error: Could not create directory $get(dir)" }
} elseif {![file isdirectory $get(dir)]} { putlog "Error: $get(dir) is not a directory" } \
elseif {![file readable $get(dir)]}      { putlog "Error: $get(dir) is not readable" }

putlog "*** Get.tcl 0.3 by KuNgFo0 loaded"



This script sounds pretty usefull but I get

Code:
Tcl error [pub_get]: invalid command name "dccsend"


Does my eggdrop fail to have dccsend activated or something? Or is it some script error...? Sad
Thanks and greetz Wink
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Apr 24, 2005 6:36 pm    Post subject: Reply with quote

load the module "filesys", dccsend is part of it.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Thunderdome
Op


Joined: 15 Mar 2005
Posts: 187

PostPosted: Mon Apr 25, 2005 8:45 am    Post subject: Reply with quote

worked fine! thanks! Very Happy
Back to top
View user's profile Send private message
Julia
Voice


Joined: 30 Jun 2007
Posts: 4
Location: Poitiers, France

PostPosted: Sat Jul 07, 2007 12:46 am    Post subject: Reply with quote

I have just a little question.
Isn't possible to have the size of the file in Kb, Mb, Gb.

For example :
Code:

[06:43] -Eggy|Fun-Frags- /hello.zip (size: 278477080 bytes)


I'm a newbie in tcl scripting, but maybe Embarassed
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber