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 

Simple anti-flood code help wanted!

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


Joined: 05 Mar 2011
Posts: 5

PostPosted: Tue Mar 08, 2011 12:09 am    Post subject: Simple anti-flood code help wanted! Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Mar 08, 2011 1:42 am    Post subject: Reply with quote

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
View user's profile Send private message
Gwar
Voice


Joined: 05 Mar 2011
Posts: 5

PostPosted: Tue Mar 08, 2011 2:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Mar 08, 2011 4:19 pm    Post subject: Reply with quote

have you used user's example posted in there or mixed your code with that hoping something good will result? Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Gwar
Voice


Joined: 05 Mar 2011
Posts: 5

PostPosted: Tue Mar 08, 2011 4:22 pm    Post subject: Reply with quote

Both! Very Happy

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Mar 09, 2011 1:35 am    Post subject: Reply with quote

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
View user's profile Send private message
Gwar
Voice


Joined: 05 Mar 2011
Posts: 5

PostPosted: Wed Mar 09, 2011 9:05 am    Post subject: Reply with quote

Got ya. Tried it and it works perfectly now. Thank you so much!
Back to top
View user's profile Send private message
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