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.

Flood Protection for trigger

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
t
tuShai
Voice
Posts: 9
Joined: Fri Feb 18, 2005 5:02 am

Flood Protection for trigger

Post by tuShai »

Hi.
I have a little Script here that needs a Spamtrigger but i am not shure where to insert it. Hopefully you can help me with this.
Well, first the Script

Code: Select all

namespace eval rules {
   namespace eval variable {

      variable trigger ".rules"
      variable channel "#channel"
      variable filename "scripts/rules.txt"
      variable method "privmsg"
   }
   bind PUBM - "$::rules::variable::channel $::rules::variable::trigger*" [namespace current]::public
   proc public {nickname hostname handle channel arg} {
      set file [open $::rules::variable::filename r]
      while {![eof $file]} {
         switch $::rules::variable::method {
            privmsg {
               putmsg $nickname [gets $file]
            }
            notice {
               putnotc $nickname [gets $file]   
            }
         }
      }
      close $file
   }
}
and here is an example of an Spamcheck Trigger i would like to use
Maybe you have a better one...

Code: Select all

set inuse 0

proc pub:info {nick host hand chan arg} {
    global inuse

    if { $inuse == 1 } {
    putquick "PRIVMSG $nick :Pls wait 20 Secs. Function is in use"
    return 
Thanks to all for helping me
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Code: Select all

namespace eval rules {
	namespace eval variable {

		variable trigger ".rules"
		variable channel "#channel"
		variable filename "scripts/rules.txt"
		variable method "privmsg"

		variable use "0"
		
		if {![info exists timer]} { 
		    variable timer "" 
		} elseif {$timer != ""} { 
		    catch {killutimer $timer}
			variable timer ""
		}
		
		variable timeout "20"; # in seconds
		
	}

	bind PUBM - "$::rules::variable::channel $::rules::variable::trigger*" [namespace current]::public

	proc public {nickname hostname handle channel arg} {
		if {$rules::variable::use} {
			putserv "$rules::variable::method $nickname :Function in use, please try again in around 20 seconds."
		} else {
			set rules::variable::use "1"
			set rules::variable::timer [utimer $rules::variable::timeout [list set rules::variable::use "0"]]
			set file [open $rules::variable::filename r]
			set data [read -nonewline $file]
			close $file
			if {[llength $data] < 1} {
				putserv "$rules::variable::method $nickname :There are no rules..."
			} else {
				foreach line [split $data \n] {
					if {$line == ""} { continue }
					putserv "$rules::variable::method $nickname :$line"
				}
			}
		}
	}
	
}
Untested
r0t3n @ #r0t3n @ Quakenet
F
Fraud
Op
Posts: 101
Joined: Mon May 19, 2008 7:57 am

Post by Fraud »

Works good for me.

One more change if its possible. Can u change this

putserv "$rules::variable::method $nickname :Function in use, please try again in around 20 seconds."

in a notice message?
Thanks
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

change:

Code: Select all

variable method "privmsg" 
to

Code: Select all

variable method "notice" 
r0t3n @ #r0t3n @ Quakenet
F
Fraud
Op
Posts: 101
Joined: Mon May 19, 2008 7:57 am

Post by Fraud »

Thanks
t
tuShai
Voice
Posts: 9
Joined: Fri Feb 18, 2005 5:02 am

Post by tuShai »

Japp all can write too

Thanks a lot
Post Reply