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.

need help with a script i made

Old posts that have not been replied to for several years.
Locked
S
SnOoPDoGg187

Post by SnOoPDoGg187 »

i'm making a script called pub releaser that will display pubs to anyone that types a trigger.. now i have some of it done and was wondering if it'd be possible to make it so people can search the list for a specific release ect now it holds all the releases in a file which i called pubs.dat so it would have to search that file but i don't know how to make it do it.. and also i'd like to make it so someone can't keep typing the triggers so it floods the room or lags the bot down.. and maybe make it is so that the person can only type it one time ever so often like once a day but needs to be made so i can adjust it if i need to and one more thing these triggers and flags can only be changed through editing the script i'd like to make it so i can change all of them in dcc chat with th e bot on the partyline.. can anyone help me with these?? thanks alot i'd appreciate it

SnOoP

<font size=-1>[ This Message was edited by: SnOoPDoGg187 on 2001-11-14 00:41 ]</font>
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I'm feeling verbose right now so I'll really lay out some stuff here.

For your search thing, here's some sample code. It opens up pubs.dat, reads all the lines, and searches for a line with the word "sheep" on it:

Code: Select all

set fp [open pubs.dat r]
set lines [split [read $fp] n]
close $fp
set idx [lsearch -glob "*sheep*" $lines]
if {$idx != -1} {
  ... found at index $idx ...
} else {
  ... not found ....
}
For your flooding problem, try keeping a global array of times when people have spoken. That way you can choose to ignore people who have called your command in the last XX seconds. The code I put here is just the beginning.. you also need to monitor nick changes, parts, quits, kicks, etc, and adjust the array. To make the amount of time adjustable, use a variable instead of a fixed number.

Code: Select all

proc yourproc {nick uhost hand chan text} {
  global spoken
  set now [clock seconds]
  if {[info exists spoken($nick)]} {
    set time [expr $now - $spoken($nick)]
    if {$time < 43200} {return 0}
    # Returns if less than 12 hours (43200 seconds)
  }
  set spoken($nick) $now
  # Hasn't used us in last 12 hours, continue
  ...
}
Are you sure you want to make your script adjustale during runtime? For some stuff, it's easy: the user can use .set variable newvalue, and that should be fine. For binds, you'll have to unbind() and then bind() the stuff all over again, so it's more work, and the user can't use .set. Also, if you want to make the changes permanent, you'll have to start storing config data in an external file, which makes it even more complicated, because then you have to have built-in default values for when the file doesn't exist.

Btw, you might find it helpful to check out tcl.activestate.com and look at the docs for all the tcl commands. They also have tutorials and howto's and stuff.
S
SnOoPDoGg187

Post by SnOoPDoGg187 »

thanks i'll start with that and see were i can take that now 1 question thought how could i get it to display the line(s) that it found in the file and maybe make it only display a certain amout of lines it found like i can set it to 5?

thanks stdragon this will get me started i appreciate the help : )

SnOoP
Locked