This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Read the five newest inputs from a file

Old posts that have not been replied to for several years.
J
JoshuaUK
Voice
Posts: 24
Joined: Sun Aug 07, 2005 11:35 am

Post by JoshuaUK »

Cheers :D:D so now what I do is have say file.tcl say added in my config file and then put a .txt file say called file.tct in the scripts directory ? not managed to get it to work for me yte but I may be doing something wrong
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

the .txt file must be in bot's main directory, not in scripts directory
J
JoshuaUK
Voice
Posts: 24
Joined: Sun Aug 07, 2005 11:35 am

Post by JoshuaUK »

Uhuh, ok I'll give it a go, currently got a little trouble with the bot itself atm, so going to have to re-install it or get it re-installed but will give it a go A.S.A.P :) Thanks again :D
J
JoshuaUK
Voice
Posts: 24
Joined: Sun Aug 07, 2005 11:35 am

Post by JoshuaUK »

[00:49] can't set "data(key1 )": variable isn't array
while executing
"set data($k) {} "
("foreach" body line 4)
invoked from within
"foreach t [split [read $f] \n] {
if {[string match !* $t]} {
set k [string range $t 1 e]
set data($k) {}
} {
..."
invoked from within
"if {![catch {set f [open file.txt]}]} {
foreach t [split [read $f] \n] {
if {[string match !* $t]} {
set k [string range $t 1 e] ..."
(file "scripts/info.tcl" line 2)
invoked from within
"source scripts/info.tcl"
(file "eggdrop.conf" line 1349)
[00:49] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)

Seem to get that error now :S Not sure why it is showing that ... it's late here so maybe I have done somrthing completly wrong lol.
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

There's already a variable called data on your bot, thus you can't use it as an array. Replace data with some other array name.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Sir_Fz wrote:There's already a variable called data on your bot, thus you can't use it as an array. Replace data with some other array name.
nah... actually I'm initializing data incorrectly

JoshuaUK, substitute first line of the script with array unset data
J
JoshuaUK
Voice
Posts: 24
Joined: Sun Aug 07, 2005 11:35 am

Post by JoshuaUK »

Loads now without crashing, but not able to get it to say anything when I type !key1 or (can I alter that too to another key?) Not sure I have the text file "file.txt" in the main directory and the tcl is set in config and is called info.tcl

This is the code..

Code: Select all

array unset 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" 
   } 
}
the file.txt is also in the bot directory just had it there too...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

I didn't say !key1, I said !get key1

if you are not sure if you have a particular file in a particular directory, you shouldn't be running eggdrop

and key1 is a placeholder for your actual key (0509, Rules, Chart or whatever), it couldn't be more obvious than that
J
JoshuaUK
Voice
Posts: 24
Joined: Sun Aug 07, 2005 11:35 am

Post by JoshuaUK »

Sorted it :) is there a way I can alter things like have!get changed to !test for example? if not that's cool, I know I can change get to anything like another word so like !info chart for example. But it seems to work with those ones so far :P getting somewhere now :D
J
JoshuaUK
Voice
Posts: 24
Joined: Sun Aug 07, 2005 11:35 am

Post by JoshuaUK »

JoshuaUK wrote:Sorted it :) is there a way I can alter things like have!get changed to !test for example? if not that's cool, I know I can change get to anything like another word so like !info chart for example. But it seems to work with those ones so far :P getting somewhere now :D
So it could be just a trigger of !rules or !chart etc... just curious, sorry to be a pain lol I know I am being a pain to all you guys really,but fantastic that I can now actually call info from a text file in chat :)
Locked