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 

getting someting inside a dir

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
pipo
Voice


Joined: 18 Nov 2006
Posts: 16

PostPosted: Thu Oct 11, 2007 5:00 pm    Post subject: getting someting inside a dir Reply with quote

Ok i use this code to get dcc send:

Code:

# dcc sends/recieves por Marco Ferra aka nXistence
# http://clientes.netvisao.pt/mferra/
# marcoferra@netvisao.pt
# versao 1.0

# !get <file>, !getlist

# por aqui a path ate' 'a filesystem do bot
set filesdir "/home/store/"

bind pub - !get pub:get

proc pub:get {nick uhost hand chan file} {
  global filesdir
  if {$file != ""} {
    switch -- [dccsend $filesdir/$file $nick] {
    0 {
      puthelp "NOTICE $nick :sending $file to you."
      dccsend $file $nick
    }
    1 { puthelp "NOTICE $nick :dcc table is full (too many connections), try to get $file later." }
    2 { puthelp "NOTICE $nick :can't open a socket for the transfer of $file." }
    3 { puthelp "NOTICE $nick :$file doesn't exist." }
    4 { puthelp "NOTICE $nick :$file was queued for later transfer." }
    }
  } else { puthelp "NOTICE $nick :!get <file> or !getlist" }
}

bind pub - !getlist pub:getlist

proc pub:getlist {nick uhost handle chan arg} {
  global filesdir
  if {$arg != ""} { set cdir $filesdir/$arg } else { set cdir $filesdir }
  set tdir [pwd]
  cd $cdir
  foreach fil "[glob *]" {
    if {[file isdirectory $fil]} { puthelp "NOTICE $nick :$arg/$fil" }
    if {[file isfile $fil]} { puthelp "NOTICE $nick :$arg/$fil (size: [file size $fil] bytes)" }
  }
  puthelp "NOTICE $nick :end of getlist!"
  cd $tdir
}

putlog "tcl: dcc sends/recieves loaded"


So it sends .txt files using the command.

Now some .txt files i upload have the same name, so what i need to do is create directories like 1, 2 etc and upload the .txt file to thoose dirs.

What i am looking for is a change in the scripts that allows me to do:

!get 1 and it will send the .txt that is in directory 1

Can this be done?

Thanks for the help
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sun Oct 14, 2007 2:52 am    Post subject: Reply with quote

Code:

set filesdir "/home/store"
                       
bind pub - !get pub:get
       
proc pub:get {nick uhost hand chan file} {
        global filesdir
        if {$file != ""} {
                if {$file == "1"} {
                        set filesdir "/path/to/dir1"
                } elseif {$file == "2"} {
                        set filesdir "/path/to/dir2"
                } elseif {$file == "3"} {
                        set filesdir "/path/to/dir3"
                } else {
                        # send an error message if the user doesn't give a valid number here..
                        puthelp "NOTICE $nick :!get <file>"
                        return
                }
                switch -- [dccsend $filesdir/$file\.txt $nick] {
                        0 {     
                                puthelp "NOTICE $nick :sending $file to you."
                                dccsend $file $nick
                        }
                        1 { puthelp "NOTICE $nick :dcc table is full (too many connections), try to get $file later." }
                        2 { puthelp "NOTICE $nick :can't open a socket for the transfer of $file." }
                        3 { puthelp "NOTICE $nick :$file doesn't exist." }
                        4 { puthelp "NOTICE $nick :$file was queued for later transfer." }
                }
        } else { puthelp "NOTICE $nick :!get <file>" }
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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