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 from textfile every 4 secs

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


Joined: 14 Jun 2008
Posts: 4

PostPosted: Sat Jun 14, 2008 10:01 pm    Post subject: Read from textfile every 4 secs Reply with quote

Hi,

I was wondering if someone could write me a smallt tcl script that would do the following:

1) Every 4 secs "Text.txt" is read - and messaged into a channel
2) Once the text has been read, the contents are deleted
3) If there's no contents in the Text, then nothing happens.

Any help would be greatly appreciated.

Thanks.

Edit: This is for an eggdrop

Edit2:

i had a mini go at it, just from cutting other scripts - unsure though if its correct, or how to put it on a timer:

Code:

#reading
set fname "yourfile.txt"
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]

#messaging
set wchan #Chan
global wchan {
putserv $lines
}

#deleting
set match *
while {[set i [lsearch -glob $lines $match]]>-1} {
set lines [lreplace $lines $i $i]
}

#writing file
set fp [open $fp "w"]
puts $fp [join $lines "\n"]
close $fp
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sun Jun 15, 2008 8:53 am    Post subject: Reply with quote

Example: (untested)

Code:
set file [open text.txt r]
set data [read -nonewline $file]
close $file
foreach line [split $data \n] {
    if {$line == ""} { continue }
    putserv "PRIVMSG #CHANNEL_HERE :$line"
}
set file [open text.txt w]
puts $file ""
close $file

_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
onesikgypo
Voice


Joined: 14 Jun 2008
Posts: 4

PostPosted: Sun Jun 15, 2008 2:29 pm    Post subject: Reply with quote

thanks, im unable to test it right now, and am also completely new to tcl scripts - but i dont think what you posted contains the 4sec timer i need?

Thanks
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sun Jun 15, 2008 5:22 pm    Post subject: Reply with quote

We expect users to help themselves here, you could of searched the forum for 'utimer' and created the timer yourself.

It should look something like:

Code:
proc dumpfile {} {
  set file [open text.txt r]
  set data [read -nonewline $file]
  close $file
  foreach line [split $data \n] {
    if {$line == ""} { continue }
    putserv "PRIVMSG #CHANNEL_HERE :$line"
  }
  set file [open text.txt w]
  puts $file ""
  close $file
  utimer 4 [list dumpfile]
}

utimer 4 [list dumpfile]

_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
tsukeh
Voice


Joined: 20 Jan 2005
Posts: 31

PostPosted: Mon Jun 16, 2008 9:30 am    Post subject: Reply with quote

Tosser^^ wrote:
We expect users to help themselves here, you could of searched the forum for 'utimer' and created the timer yourself.

It should look something like:

Code:
proc dumpfile {} {
  set file [open text.txt r]
  set data [read -nonewline $file]
  close $file
  foreach line [split $data \n] {
    if {$line == ""} { continue }
    putserv "PRIVMSG #CHANNEL_HERE :$line"
  }
  set file [open text.txt w]
  puts $file ""
  close $file
  utimer 4 [list dumpfile]
}

utimer 4 [list dumpfile]


Code:

 if {[lsearch [utimers] "* dumpfile *"] == -1} { utimer 4 [list dumpfile] }



Otherwise it starts a new timer always you .rehash..
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