This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

2 things

Old posts that have not been replied to for several years.
Locked
i
inv|s|ble

Post by inv|s|ble »

I was looking through all the scripts here, and on bseen, and all I can find is ctcp flood banning scripts, lately my channel has been getting flooded with ctcp replies, while it doesnt do any real damage, it is slightly annoying. Is there a tcl or easy way to convert a normal flood tcl to do ctcp reply instead of ctcp?

Secondly, I have been looking for a tcl that will read a random line from a text file on a timer. Sort of like a cross between MC's random tcl, and a random quote script, but I already have a text file of a few meg, and dont want to sit, and edit it, to add the timer, and what not to my text file.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Since you said the text file is several megabytes, I did some non-standard line selection code so that it doesn't need to know the number of lines or scan in the whole file. If you have 100k lines, finding the 50k'th line takes a while in tcl heh. So the end result is that it may be very slightly biased for or against long lines in the file, depending on their distribution.

I didn't test it but it should be ok.

txtfile is the path of the file

min/max_interval is the delay between postings, in seconds

dest_chan is the channel in which it will be posted

Code: Select all

set txtfile {yourfile.txt}
set min_interval 60
set max_interval 120
set dest_chan {#baaa}

proc random_quote {} {
  global txtfile dest_chan
  set fp [open $txtfile r]
  seek $fp 0 end
  set len [tell $fp]
  seek $fp [rand $len]
  gets $fp partial
  if {[gets $fp line] == -1} {
    seek $fp 0
    gets $fp line
  }
  putserv "PRIVMSG $dest_chan :$line"
  return 0
}

proc random_timer {} {
  global min_interval max_interval
  set len [expr $max_interval - $min_interval]
  set time [expr [rand $len] + $min_interval]
  utimer $time random_timer
  random_quote
}

if {![info exists random_quote_loaded]} {
  set random_quote_loaded 1
  putlog "*** Random Quote by stdragon loaded"
  random_timer
}
i
inv|s|ble

Post by inv|s|ble »

Thanks, I will test it out tonight, and see how it does.
Locked