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 

help with read/output file, public trigger

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
iNFERNiS
Voice


Joined: 21 Aug 2007
Posts: 13

PostPosted: Fri Nov 02, 2007 3:29 pm    Post subject: help with read/output file, public trigger Reply with quote

I'm very new to tcl and coding in general. I wanted to make a simple script that reads from a textfile, grabs a random line and outputs it to a channel, with a public trigger.

Suffice to say i failed horribly, i'm kind of stuck now. Can someone point me into the right direction?

Quote:

bind pub o|o !randtext pub:randtext

proc pub:randtext { } {
putserv "PRIVMSG $channel : randline("randomness.txt")"
}

proc randline {file} {
set fs [open $file r]
set data [read -nonewline $fs]
close $fs
return [lindex $data [expr {int(rand()*[llength $data])}]]
}
Back to top
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Fri Nov 02, 2007 8:07 pm    Post subject: Reply with quote

Start off with a basic TCL tutorial first, your code doesn't look like TCL to me :p
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Fri Nov 02, 2007 10:04 pm    Post subject: Reply with quote

Here's a basic script for reading text and spitting out random lines:
http://members.dandy.net/~fbn/jokes.tcl.txt
Back to top
View user's profile Send private message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Sat Nov 03, 2007 4:46 am    Post subject: Reply with quote

metroid wrote:
Start off with a basic TCL tutorial first, your code doesn't look like TCL to me :p


That was rude Very Happy
_________________
|AmDeAtH @ Undernet


Death is only the *Beginning*...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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