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 

Read the five newest inputs from a file
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
JoshuaUK
Voice


Joined: 07 Aug 2005
Posts: 24

PostPosted: Mon Sep 12, 2005 6:28 pm    Post subject: Reply with quote

Cheers Very HappyVery Happy 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
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Sep 12, 2005 8:39 pm    Post subject: Reply with quote

the .txt file must be in bot's main directory, not in scripts directory
Back to top
View user's profile Send private message Visit poster's website
JoshuaUK
Voice


Joined: 07 Aug 2005
Posts: 24

PostPosted: Tue Sep 13, 2005 5:20 am    Post subject: Reply with quote

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 Smile Thanks again Very Happy
Back to top
View user's profile Send private message
JoshuaUK
Voice


Joined: 07 Aug 2005
Posts: 24

PostPosted: Tue Sep 13, 2005 7:52 pm    Post subject: Reply with quote

[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.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Sep 13, 2005 8:16 pm    Post subject: Reply with quote

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.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Sep 13, 2005 9:48 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
JoshuaUK
Voice


Joined: 07 Aug 2005
Posts: 24

PostPosted: Wed Sep 14, 2005 4:03 pm    Post subject: Reply with quote

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:

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...
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Sep 14, 2005 4:24 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
JoshuaUK
Voice


Joined: 07 Aug 2005
Posts: 24

PostPosted: Wed Sep 14, 2005 4:46 pm    Post subject: Reply with quote

Sorted it Smile 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 Razz getting somewhere now Very Happy
Back to top
View user's profile Send private message
JoshuaUK
Voice


Joined: 07 Aug 2005
Posts: 24

PostPosted: Fri Sep 16, 2005 11:16 am    Post subject: Reply with quote

JoshuaUK wrote:
Sorted it Smile 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 Razz getting somewhere now Very Happy


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 Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 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