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.

check banlist for certain banmasks

Help for those learning Tcl or writing their own scripts.
Post Reply
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

check banlist for certain banmasks

Post by simo »

i was wondering how this could be used to check if banmask m:*!*@* is still in the banlist of channel when the timer expires and triggers the check

because we dont want it to remove something wich is no longer there

Code: Select all

bind mode - "#% +b" timedmutechecker 

proc timedmutechecker {nick uhost hand chan mc ban} {
    if {[string match -nocase m:*!*@* $ban]} {  after [expr {20*1000*60}] [list pushmode $chan -b m:*!*@*] }
} 

Last edited by simo on Wed Aug 26, 2020 10:36 am, edited 1 time in total.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

The idea is if anyone sets this ban:

+b m:*!*@*

to have a timer remove it but if some chan op manually removed it with -b m:*!*@* to stop the previous set timer as the ban mask is no longer there to be removed
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried using this but it didnt seem to work to stop the timer

Code: Select all

bind mode - "#% -b" timedmutecheckerX2 

proc timedmutecheckerX2 {nick uhost hand chan mc ban} {
    if {[string match -nocase m:*!*@* $ban]} {  
 foreach thetimer [timers] {
    if {[string equal -nocase timedmutechecker [lindex $thetimer 1]]} {
        killtimer [lindex $thetimer 2]
         break
       }
      } 
   }
} 
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried various examples i got here: http://forum.egghelp.org/viewtopic.php?t=9941

but none seems to work for me im not sure if that should work for the kkind of timer i use here the: after
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I'm trying to understand your problem...

An op can add a +b m:*!*@* to mute anyone on the channel, and you want the eggdrop to automaticaly remove it after 20 minutes.
BUT if someone removes the ban, you want to kill the timer.

Code: Select all

bind mode - "#% +b" runban
bind mode - "#% -b" stopban

proc runban {nick uhost handle chan mode target} {
   if {[string match -nocase m:*!*@* $target]} {
      set ::btimer [list [timer 20 rmban]]
   }
}

proc stopban {nick uhost handle chan mode target} {
   if {[string match -nocase m:*!*@* $target]} {
      rmban
   }
}

proc rmban {} {
   if { [info exists ::btimer] } {
      killtimer $::btimer
      unset ::btimer
   }
}
Explanations
The runban proc create the timer, and will run "rmban" at the end of the timer.
The stopban proc directly call the rmban proc
The rmban proc checks if the timer exists, and if it exists, it kills the timer and unset its id.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tnx for your reply CrazyCat ive tested it but it doesnt seem to remove the banmask after 20 min if nobody has removed it with -b m:*!*!@
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

True, I focused on your trouble and forget to remove the ban :)


You can try the following code, but I've a small doubt about the ischanban usage and I can't test it right now. Tell me if it doesn't work, I'll look deeper.

Code: Select all

bind mode - "#% +b" runban
bind mode - "#% -b" stopban

proc runban {nick uhost handle chan mode target} {
   if {[string match -nocase m:*!*@* $target]} {
      set ::btimer [list [timer 20 rmban $chan]]
   }
}

proc stopban {nick uhost handle chan mode target} {
   if {[string match -nocase m:*!*@* $target]} {
      rmban $chan
   }
}

proc rmban {chan} {
   if { [info exists ::btimer] } {
      killtimer $::btimer
      unset ::btimer
   }
   if { [ischanban m:*!*@* $chan] } {
      pushmode $chan -b m:*!*@*
   }
}
Another way is to have a variable to know if the ban is set or not, but it's the ugly way imho :)
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

getting these errors:

Tcl error in script for 'timer16203':
wrong # args: should be "rmban chan"


Tcl error in script for 'timer16220':
invalid timerID
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

When did you got the first error ?
Can you do .set errorInfo when it happens and paste here the result please ?
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I made tests and corrected the script, this one may work :)

Code: Select all

bind mode - "#% +b" runban
bind mode - "#% -b" stopban

proc runban {nick uhost handle chan mode target} {
   if {[string match -nocase m:*!*@* $target]} {
      set ::btimer($chan) [list [timer 20 [rmban $chan]]]
   }
}

proc stopban {nick uhost handle chan mode target} {
   if {[string match -nocase m:*!*@* $target]} {
      rmban $chan
   }
}

proc rmban {chan} {
   if { [info exists ::btimer($chan)] } {
      killtimer $::btimer($chan)
      unset ::btimer($chan)
   }
   if { [ischanban m:*!*@* $chan] } {
      pushmode $chan -b m:*!*@*
   }
}
I've changed the timer creation (timer is now set in an array) and the call of rmban
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried your latest post and the moment i the ban i get

Tcl error [stopban]: invalid timerID

and it unbans instantly
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Shouldn't it be:

Code: Select all

timer sec [list proc $arg1 $arg2 ...]
I mean shouldn't:

Code: Select all

set ::btimer($chan) [list [timer 20 [rmban $chan]]] 
be:

Code: Select all

set ::btimer($chan) [timer 20 [list rmban $chan]]
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tried that and got the same error caesar:

Tcl error in script for 'timer33938':
invalid timerID
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, I think I understand the errors I made...

Try this:

Code: Select all

bind mode - "#% +b" runban
bind mode - "#% -b" stopban

proc runban {nick uhost handle chan mode target} {
	if {[string match -nocase m:*!*@* $target]} {
		set ::btimer($chan) [list [timer 20 [list rmban $chan]]]
	}
}

proc stopban {nick uhost handle chan mode target} {
	if {[string match -nocase m:*!*@* $target]} {
		rmban $chan
	}
}

proc rmban {chan} {
	if { [array exists ::btimer] && [info exists ::btimer($chan)] } {
		if { [lsearch -index 2 [timers] $::btimer($chan)] != -1} {
			killtimer $::btimer($chan)
		}
		unset ::btimer($chan)
	}
	if { [ischanban m:*!*@* $chan] } {
		pushmode $chan -b m:*!*@*
	}
}
Errors occured because when timer is ended, it's automaticaly unsetted, so we don't have to manualy kill it.

The 2 difficulties in the script:
- how to well launch the timer and keep its ID. list is the solution :)
- how to find if the timer exists using its ID. lsearch is the solution :)
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tried your last post CrazyCat and it seems to work fine tnx alot
i like to thank Caesar too
Post Reply