| View previous topic :: View next topic |
| Author |
Message |
froost Voice
Joined: 09 Sep 2005 Posts: 4
|
Posted: Fri Sep 09, 2005 4:36 pm Post subject: |
|
|
Ty stdragon for the great info
What should i do in my scenario?
I have a file with info in it that is added by users with !commands..
Would it be possible to make a small script that would read the five newest inputs in that file? (The newest are always at the bottom of the file)
For example !new , and it displays it in the channel u want it to.
The file im talking about is with lines and looks like this:
blablabla
hey
hello, hows things
I hope u understand what i mean
/regards Froost |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Sep 09, 2005 5:49 pm Post subject: |
|
|
Always post such requests in the proper forum (dont ask in the TCL faq)
| Code: | set yourfile "scripts/file.txt"
bind pub - !new show:new
proc show:new {nick uhost hand chan arg} {
global yourfile
foreach n [lrange [split [read [set f [open $yourfile]]] \n] end-4 end] {
puthelp "privmsg $chan :$n"
}
close $f
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
froost Voice
Joined: 09 Sep 2005 Posts: 4
|
Posted: Fri Sep 09, 2005 6:04 pm Post subject: |
|
|
| Sir_Fz wrote: | Always post such requests in the proper forum (dont ask in the TCL faq)
| Code: | set yourfile "scripts/file.txt"
bind pub - !new show:new
proc show:new {nick uhost hand chan arg} {
global yourfile
foreach n [lrange [split [read [set f [open $yourfile]]] \n] end-4 end] {
puthelp "privmsg $chan :$n"
}
close $f
} |
|
Ops, sorry that i posted in the wrong place
Sir_Fz , ty for your answer! but it didnt show anything in the channel.
I saved this into a empty .tcl file and loaded it in the eggdrop source/scripts.
| Code: |
set yourfile "scripts/define.db"
bind pub - !new show:new
proc show:new {nick uhost hand chan arg} {
global yourfile
foreach n [lrange [split [read [set f [open $yourfile]]] \n] end-4 end] {
puthelp "privmsg $chan :$n"
}
close $f
}
|
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Sep 09, 2005 8:56 pm Post subject: |
|
|
Make sure that the last 5 lines in define.db are not empty. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
froost Voice
Joined: 09 Sep 2005 Posts: 4
|
Posted: Sat Sep 10, 2005 4:07 am Post subject: |
|
|
| Sir_Fz wrote: | | Make sure that the last 5 lines in define.db are not empty. |
Yes, it had some spaces in it.
I cant thank you enough for this, thank you  |
|
| Back to top |
|
 |
JoshuaUK Voice
Joined: 07 Aug 2005 Posts: 24
|
Posted: Sun Sep 11, 2005 6:51 am Post subject: |
|
|
| HI I am trying to find a script which will allow me to add custom triggers and read lines from a text file, so for example !released0509 for example and it would announce so information not announcing it for everyone to see but only the person who requested it as a 'notice' in the channel they are in and it is set to... there may be something like this already just going to continue but this seems the closest I have seen so far. |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sun Sep 11, 2005 9:25 pm Post subject: |
|
|
| normally, the trigger keywords would be constants and you specify what you want not by introducing a new trigger command but by supplying parameters to your command line which are interpreted by that command's handler proc in a certain way |
|
| Back to top |
|
 |
JoshuaUK Voice
Joined: 07 Aug 2005 Posts: 24
|
Posted: Mon Sep 12, 2005 10:17 am Post subject: |
|
|
| Hmm not sure if there is such a script I found one called mc.readfile1.5.tcl.tcl not sure if it works or what, but not sure if anyone here would know how I could set up a script to say when someone types !rules it takes rules from a text file for example, so the info can be altered easily though a text file on the server.. one which I can have more than one trigger would be great. |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Mon Sep 12, 2005 10:38 am Post subject: |
|
|
| JoshuaUK wrote: | | Hmm not sure if there is such a script I found one called mc.readfile1.5.tcl.tcl not sure if it works or what, ... |
Ever thought of reading the instructions at the top of the script? Had thoughts of actually testing it? _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Mon Sep 12, 2005 1:30 pm Post subject: |
|
|
| also, a simple forum search for "faq" or "rules" should give you zillions of hits |
|
| Back to top |
|
 |
JoshuaUK Voice
Joined: 07 Aug 2005 Posts: 24
|
Posted: Mon Sep 12, 2005 1:40 pm Post subject: |
|
|
Yeah I have looked into it, but I can't seem to get it to work, going to try again with it, but not sure if it will work, and not sure what I should search for! I looked for Trigger scripts, reading from text file etc.. and not really sure what it would come under.. I will try FAQ and rules etc.. and see  |
|
| Back to top |
|
 |
JoshuaUK Voice
Joined: 07 Aug 2005 Posts: 24
|
Posted: Mon Sep 12, 2005 1:53 pm Post subject: |
|
|
Can't see any that read from txt files or that I can have multiple triggers for. |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Mon Sep 12, 2005 3:51 pm Post subject: |
|
|
| what do you need multiple triggers for? If you cannot clearly and unambiguously describe what you need, nobody could help you even if they wanted to |
|
| Back to top |
|
 |
JoshuaUK Voice
Joined: 07 Aug 2005 Posts: 24
|
Posted: Mon Sep 12, 2005 4:00 pm Post subject: |
|
|
| Right wel what I would like is to have a !Chart option !Rules and !srealses0509 !areleases0509 etc.. for music releases and I can just alter the trigger when I update and remove them and add new ones, and can modify new additions to the lists for each one everytime like the chart etc.. each week through a text file and just .rehash the bot |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Mon Sep 12, 2005 4:39 pm Post subject: |
|
|
| Code: |
set data {}
if {![catch {set f [open file.txt]}]} {
foreach t [split [read $f] \n] {
if {[string match !* $t]} {
set k [string range $t 1 e]
set data($k) {}
} {
lappend data($k) $t
}
}
close $f
}
bind pub - !get foo
proc foo {n u h c t} {
if {[info exists ::data($t)]} {
foreach e $::data($t) {puthelp "notice $n :$e"}
} {
puthelp "notice $n :no data found for $t"
}
}
|
your file.txt looks like this:
| Code: |
!key1
line1 for key1
line2 for key1
...
lineN for key1
!key2
line1 for key2
line2 for key2
...
lineM for key2
!key3
...
|
and you retrieve data for keyK by typing !get keyK |
|
| Back to top |
|
 |
|