| View previous topic :: View next topic |
| Author |
Message |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Thu Apr 06, 2006 11:45 pm Post subject: Slap with subject read from file |
|
|
I got this slap:
| Code: |
bind pub o- .slap slap:target
proc slap:target {nick uhost hand chan arg} {
set target "[lindex [split $arg] 0]" ; set reason "[join [lrange [split $arg] 1 end]]"
putserv "PRIVMSG $chan :\001ACTION slaps $target around with a hord of bots!! $reason\001"
}
|
Is there anyway I could make it read from a file containing various stuff for the slap subject?
I mean if I type .slap nick around with <the stuf from the file>
it would then read from a file random. |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Fri Apr 07, 2006 2:43 am Post subject: |
|
|
Utilising the following should work; edit as required:
| Code: | set slap "./slap.txt"
set slapmsg [string range [randomline $slap] 0 end]
# Insert your own procedure.
proc randomline { filename } {
set position [rand [expr [file size $filename] - 1024]]
set fd [open $filename r]
catch {
seek $fd $position
set text [read $fd 1024]
}
close $fd
set lines [split $text \n]
set lineno [randrange 1 [expr [llength $lines] - 1]]
return [lindex $lines $lineno]
} |
Of course you'd have already created "slap.txt" in the ~scripts folder and inserted your own custom messages. _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
|