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 

Need a script line
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
mabus
Voice


Joined: 17 Jun 2005
Posts: 27

PostPosted: Mon Apr 14, 2008 3:40 pm    Post subject: Need a script line Reply with quote

When a user types;

!folder file 1:1

I need a line of script that returns the line 1:1 inside the requested file, inside the requested folder.

What would be the simplest way to do this?

I also need if possible for the $file variable to only look at the first 3 letters of the word and ignore the rest of the word.

Any help?
Back to top
View user's profile Send private message
theice
Voice


Joined: 13 Mar 2008
Posts: 36

PostPosted: Mon Apr 14, 2008 5:21 pm    Post subject: Reply with quote

start with a public proc / bind

Code:
set pubtrig "!"

#public format !displayfile folder file line

bind pub - ${pubtrig}displayfile display:pub
proc display:pub {nick uname hand chan text} {
   set folder [lindex [split $text] 0]
                set file [lindex [split $text] 1]
                set line [lindex [split $text] 2]

}

you can easily have it return the first 3 letters of the word, once you grab the information.
Back to top
View user's profile Send private message
mabus
Voice


Joined: 17 Jun 2005
Posts: 27

PostPosted: Mon Apr 14, 2008 5:39 pm    Post subject: Reply with quote

Thanks for the reply theice, I realise i was a bit unclear in my question though, sorry about that.

Here's perhaps a better description of what I need to do, Let me give you a step by step example so you can see what I meant;

The structure includes numerous FOLDERS, each folder has many (txt) FILES of 3 letter names. Each file has a lot of numerbed lines, each numbered line contains written text.

So, if a user types !recipies george 1
I would want the script to go into folder recipies
Seek out file geo [ignoring everything after the 3rd letter]
read line 1 (including all text on line 1)
and then read line 1 back to the user on the main channel

So for example;

<Bob> !recipies george 1
<Bot> george 1 - this is the text that appears on line 1
<Bob> !stories larry 4
<Bot> larry 4 - this is the text that appears on line 4
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Mon Apr 14, 2008 6:11 pm    Post subject: Reply with quote

EDIT: Changed some stuff, Fixed folder variable error

Code:
set folder(dir) "[pwd]/folders"
set folder(trigger) "!"

bind pubm - "$folder(trigger)*" displayfile

proc displayfile {nick host hand chan text} {
    global lastbind folder
    set folder_ [lindex [split $lastbind !] 1]
    set file [string range [lindex [split $text] 0] 0 2]
    set line [lindex [split $text] 1]
    if {$file == "" || $line == ""} {
       putserv "NOTICE $nickname :SYNTAX: !<folder> <file> <line(s)> (without the <>'s)."
    } elseif {![file exists [file join $folder(dir) $folder_ $file]]} {
       putserv "NOTICE $nick :File '$file' does not exist."
    } elseif {![string is integer $line]} {
       putserv "NOTICE $nick :Line(s) must be a digit."
    } else {
       set f [open [file join $folder(dir) $folder_ $file] r]
       set d [read -nonewline $f]
       close $f
       if {[llength $d] < 1} {
           putserv "NOTICE $nick :File '$file' is empty."
       } elseif {[llength $d] < $line]} {
           putserv "NOTICE $nick :Line number '#$line' does not exist."
       } else {
           set count 0
           puthelp "NOTICE $nick :Contents of file '$file':"
           foreach i [split $d \n] {
               if {$i == ""} { continue }
               incr count
               if {$count == $line} {
                   puthelp "NOTICE $nick :$i"
                   break
               }
           }
           puthelp "NOTICE $nick :Dumped contents of file '$file'."
       }
    }
}


NOT TESTED!
_________________
r0t3n @ #r0t3n @ Quakenet


Last edited by r0t3n on Fri Apr 18, 2008 12:10 pm; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Tue Apr 15, 2008 12:29 am    Post subject: Reply with quote

mabus, you need to provide better information on the files.
Where are the files? Are they in a directory within the eggdrop directory?
What format is the numbering? Is it "1 blahblahblah", or is it "1. blahblahblah", or is it different then those?
Back to top
View user's profile Send private message
mabus
Voice


Joined: 17 Jun 2005
Posts: 27

PostPosted: Tue Apr 15, 2008 10:28 am    Post subject: Reply with quote

Thanks for all the replies guys, I appreciate the help.

I'll be as detailed as I possibly can be;

The path is: #! /usr1/home/server/mabus/bot

The text files will be in: /bot/scripts/txt/

Inside /txt/ will be a series of folders all like /bot/scripts/txt/help/ or /bot/scripts/txt/rules/ or /bot/scripts/txt/dirs/ and so on

Inside each subfolder will be a bunch of text files. Each of the text files will be only 3 letters long. For example:

/bot/scripts/txt/help/cha
/bot/scripts/txt/help/bot
/bot/scripts/txt/help/web
/bot/scripts/txt/rules/cha
/bot/scripts/txt/rules/ftp
/bot/scripts/txt/dirs/bbs

now.... what i want is for when a user types something like !help channel 1-1

the bot returns the help 1-1 to the channel (from the file cha)

if the user types !rules ftp 20-7
the bot returns the line 20-7 in the rules folder (from the file ftp)
Back to top
View user's profile Send private message
mabus
Voice


Joined: 17 Jun 2005
Posts: 27

PostPosted: Tue Apr 15, 2008 10:28 am    Post subject: Reply with quote

Tosser, thanks for the code, unfortunately it does not seem to work. I get an error message;

"Tcl error [displayfile]: can't set
"folder": variable is array"
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Tue Apr 15, 2008 11:42 am    Post subject: Reply with quote

I edited my post with a fix, it should work.
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
mabus
Voice


Joined: 17 Jun 2005
Posts: 27

PostPosted: Tue Apr 15, 2008 1:28 pm    Post subject: Reply with quote

Hey tosser... interesting script, It gives me an error message now that file "fil does not exist". on the command !folder file test.txt 1

Thing is... that format is a good bit different than what i need. I really need the trigger to be !folder file # Example;

!help channel 17

should return line 17 from file cha from folder help
Back to top
View user's profile Send private message
mabus
Voice


Joined: 17 Jun 2005
Posts: 27

PostPosted: Thu Apr 17, 2008 10:30 am    Post subject: Reply with quote

No one knows how to do this?
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Thu Apr 17, 2008 9:22 pm    Post subject: Reply with quote

mabus wrote:
No one knows how to do this?

No one wants to do this?
corrected your quote above, no thanks neccessary...your tone sounds sarcastic, and your bump isn't going to magically make people do your bidding...
Back to top
View user's profile Send private message
mabus
Voice


Joined: 17 Jun 2005
Posts: 27

PostPosted: Fri Apr 18, 2008 9:29 am    Post subject: Reply with quote

there was no sarcasm.... and it wasn't a bump .... and it wasn't an attempt to make people "do my bidding" ... it's a script request forum is it not? It's a script I really need, and this is more of a plea for help. I thought that's what this forum was for after all.
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri Apr 18, 2008 10:49 am    Post subject: Reply with quote

mabus wrote:
there was no sarcasm.... and it wasn't a bump .... and it wasn't an attempt to make people "do my bidding" ... it's a script request forum is it not? It's a script I really need, and this is more of a plea for help. I thought that's what this forum was for after all.

There was indeed a bump you silly silly person. You posted this No one knows how to do this? as a new post, when you could've just edited your prior post. Instead of doing that, now you have two replies of your own in a row. This constitutes a bump. You did this so your request would move to the top. In doing this, you ARE NOT going to get any more help. In fact, quite the opposite, people will stop helping you.

Btw, noob, all you need to do is change this line, and instantly Tosser^^'s code works according to your layout.
set folder(dir) "[pwd]/folders" -> set folder(dir) "[pwd]/scripts/txt"
Back to top
View user's profile Send private message
mabus
Voice


Joined: 17 Jun 2005
Posts: 27

PostPosted: Fri Apr 18, 2008 10:58 am    Post subject: Reply with quote

Speechless, I came to the forum for help... Tosser offered a suggestion for a script that didn't work for me, and after no one replied after a couple of days I repeated my request to see if anyone else had any ideas (lest anyone think the problem was solved).

I assumed this was the best way to go about it, rather than double posting. Obviously I was mistaken and offended you, and I apologise, it was not my intention to do so.

As for your suggestion on the change to Tosser's script. It did not work. The bot does not reply to the command at all now.
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri Apr 18, 2008 11:24 am    Post subject: Reply with quote

mabus wrote:
Speechless, I came to the forum for help... Tosser offered a suggestion for a script that didn't work for me, and after no one replied after a couple of days I repeated my request to see if anyone else had any ideas (lest anyone think the problem was solved).

I assumed this was the best way to go about it, rather than double posting. Obviously I was mistaken and offended you, and I apologise, it was not my intention to do so.

As for your suggestion on the change to Tosser's script. It did not work. The bot does not reply to the command at all now.

Haw.. there is no need to apologize, as it doesn't change anything. The problem is people are assuming this forum section is a 'magic lamp'. Then posting here to them basically is the act of 'rubbing the lamp'. Now the part everybody waits on forever is the genie. Sometimes if you request is meger and not some intense 40hr project, you will get a genie faster... Your request was somewhere in the middle, and your genie was one with much expertise, so to assume after his initial attempts to help you that 'no one knows how to do this' insults your genie. Hopefully you understand, with the clues you gave as to the structure and what not of your files. You've confused many genies initially. Hopefully Tosser can help you further, and your persistant 'rubbing' doesn't upset him as well...
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
Goto page 1, 2  Next
Page 1 of 2

 
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