| View previous topic :: View next topic |
| Author |
Message |
Gwar Voice
Joined: 05 Mar 2011 Posts: 5
|
Posted: Tue Mar 08, 2011 12:09 am Post subject: Simple anti-flood code help wanted! |
|
|
Hey all. I am trying to add a very rudimentary anti flood if/else statement to a very simple !command > spits out a text string code.
here is what I have so far:
| Code: |
bind pub - "!irc" irc
set spam "0"
proc delay {} {}
proc nospam {nick text} {putserv "privmsg $nick : Do *NOT* Spam the bot. Thank you."}
proc irc {nick uhost handle chan text} {
global spam
incr $spam
if {$spam == "1"} {putserv "privmsg $chan : Get the irc info here:"
incr $spam
utimer 15 delay
set spam 0
} else {
nospam $nick $text
}} |
What (I think) I am doing here is setting a global variable to 0, then when I run the irc proc, it ups it to 1. The if then checks if its 1. If it is, it increases it to 2, sets up a 15 second delay before running a null proc, then it sets it back to 0. If someone runs the command before the 15 seconds are up, it gets upped to 3 (or whatever) and the else part is triggered.
However, I am doing something wrong, because it just spits out the else trigger (I tried swapping the bits inside, same result), so It's probably to do with my lack of understanding how the variables work. I am totally new to tcl, and have read through several websites, but I must have missed something.
Thank you for your help in advance. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Mar 08, 2011 1:42 am Post subject: |
|
|
If you want to throttle a command then have a look here. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Gwar Voice
Joined: 05 Mar 2011 Posts: 5
|
Posted: Tue Mar 08, 2011 2:53 pm Post subject: |
|
|
Hey there caesar!
I tried out the suggestion there, but it didn't work! D: Now the command simply does nothing, and I don't know where it's going wrong! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Mar 08, 2011 4:19 pm Post subject: |
|
|
have you used user's example posted in there or mixed your code with that hoping something good will result?  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Gwar Voice
Joined: 05 Mar 2011 Posts: 5
|
Posted: Tue Mar 08, 2011 4:22 pm Post subject: |
|
|
Both!
Is there a way I can "see" how the code is running? Nothing shows up in the eggdrop DCC chat.
Edit, Ok, I feel like a total moron now. I had not done it right. Now that I have, the example posted works.
I'll try and mesh in my own code and see if I can get it working. Sorry for being so bloody stupid D:
One further question, It seems other people in my channel can't use the example script there. How do I set it so they can? |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Mar 09, 2011 1:35 am Post subject: |
|
|
| Quote: |
bind pub n !test pub:test
|
user's example code has the pub trigger bound to work only for owners (n), so replace the 'n' with '*' to allow anyone use the command.
Edit: you should replace:
| Code: |
if {[throttled $u,$c 30]} {
|
too to:
| Code: |
if {[throttled $c 30]} {
|
to make the throttle count all the users in a single variable rather than counting separately for each user on the channel. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Gwar Voice
Joined: 05 Mar 2011 Posts: 5
|
Posted: Wed Mar 09, 2011 9:05 am Post subject: |
|
|
| Got ya. Tried it and it works perfectly now. Thank you so much! |
|
| Back to top |
|
 |
|