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.

Simple anti-flood code help wanted!

Help for those learning Tcl or writing their own scripts.
Post Reply
G
Gwar
Voice
Posts: 5
Joined: Sat Mar 05, 2011 10:24 am

Simple anti-flood code help wanted!

Post by Gwar »

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: Select all

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.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
G
Gwar
Voice
Posts: 5
Joined: Sat Mar 05, 2011 10:24 am

Post by Gwar »

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!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
G
Gwar
Voice
Posts: 5
Joined: Sat Mar 05, 2011 10:24 am

Post by Gwar »

Both! :D

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?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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: Select all

if {[throttled $u,$c 30]} {
too to:

Code: Select all

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.
G
Gwar
Voice
Posts: 5
Joined: Sat Mar 05, 2011 10:24 am

Post by Gwar »

Got ya. Tried it and it works perfectly now. Thank you so much!
Post Reply