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 

Slap with subject read from file

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


Joined: 10 Jan 2006
Posts: 139

PostPosted: Thu Apr 06, 2006 11:45 pm    Post subject: Slap with subject read from file Reply with quote

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
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Fri Apr 07, 2006 2:43 am    Post subject: Reply with quote

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
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