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.

first warn, then kick

Help for those learning Tcl or writing their own scripts.
Post Reply
B
BCyo+8C4
Voice
Posts: 24
Joined: Sun Sep 03, 2006 11:11 am

first warn, then kick

Post by BCyo+8C4 »

How would I go if I wanted to first warn a user and if he does it again in less then x seconds kick him?
I guess I'd need to create a timer when warning and then check whether such a time exists, but I don't really know how I'd do that. Could someone provide me with an short example please?

Sorry if this was asked before, couldn't find anything
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Perhaps this might be useful.
B
BCyo+8C4
Voice
Posts: 24
Joined: Sun Sep 03, 2006 11:11 am

Post by BCyo+8C4 »

Hi,
I got this to work in some parts, but there's still problems.
I check for certain russian letters and then warn the users. If the line contains only one of those letters it works fine, but if there's more than one in the line the script warns + kicks.

Code: Select all

bind pubm - "*ð*"						english
bind pubm - "*ó*"						english
bind pubm - "*ñ*"						english

proc english {nick host hand chan text} {
	if {([isop $nick $chan]) || ([ishalfop $nick $chan]) || ([isvoice $nick $chan])} {
		return 1;
	}
	if {[throttled $nick,$chan 90]} {
		putkick $chan $nick "speak english (autokick)"
	} else {
		putserv "PRIVMSG $chan :$nick - Please speak english in this channel!"
	}
}

proc throttled {id time} {
	global throttled
	if {[info exists throttled($id)]} {
		return 1;
	} else { 
		set throttled($id) [clock sec] 
		utimer $time [list unset throttled($id)]
		return 0;
	}
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

bind pubm - * english

proc english {nick host hand chan text} {
   if {([isop $nick $chan]) || ([ishalfop $nick $chan]) || ([isvoice $nick $chan])} {
      return 1
   }
   if {![regexp {[ðóñ]} $text]} {return 0}
   if {[throttled $nick,$chan 90]} {
      putkick $chan $nick "speak english (autokick)"
   } else {
      putserv "PRIVMSG $chan :$nick - Please speak english in this channel!"
   }
}

proc throttled {id time} {
   global throttled
   if {[info exists throttled($id)]} {
      return 1
   } else {
      set throttled($id) [clock sec]
      utimer $time [list unset throttled($id)]
      return 0
   }
}
B
BCyo+8C4
Voice
Posts: 24
Joined: Sun Sep 03, 2006 11:11 am

Post by BCyo+8C4 »

won't that require way more ressources as it has to regexp every single line said on chat? it's not like this is a quite chat, a days log is about 1-2mb and i fear this would kill the bot.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

I wouldn't count on it. It will work fine.
B
BCyo+8C4
Voice
Posts: 24
Joined: Sun Sep 03, 2006 11:11 am

Post by BCyo+8C4 »

i tried it and cpu usage went up 2% :-( any other ideas to prevent this? isn't there some setting/command/whatever to tell eggdrop to perform one action per line in chat only?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Although it is fine as is, you can use [string match] instead.

Code: Select all

if {![string match {*[ðóñ]*} $text]} {return 0}
B
BCyo+8C4
Voice
Posts: 24
Joined: Sun Sep 03, 2006 11:11 am

Post by BCyo+8C4 »

thanks, that one works better :)
Post Reply