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 

check banlist for certain banmasks

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


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Aug 25, 2020 6:51 pm    Post subject: check banlist for certain banmasks Reply with quote

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:

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
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Aug 26, 2020 1:24 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Aug 26, 2020 10:35 am    Post subject: Reply with quote

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

Code:

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
       }
      }
   }
}
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Aug 26, 2020 11:46 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Thu Aug 27, 2020 2:51 am    Post subject: Reply with quote

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:
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.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Thu Aug 27, 2020 12:53 pm    Post subject: Reply with quote

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:*!*!@
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Thu Aug 27, 2020 2:18 pm    Post subject: Reply with quote

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


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:
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 Smile
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Thu Aug 27, 2020 3:32 pm    Post subject: Reply with quote

getting these errors:

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


Tcl error in script for 'timer16220':
invalid timerID
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Thu Aug 27, 2020 6:26 pm    Post subject: Reply with quote

When did you got the first error ?
Can you do .set errorInfo when it happens and paste here the result please ?
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Fri Aug 28, 2020 5:17 am    Post subject: Reply with quote

I made tests and corrected the script, this one may work Smile
Code:
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
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Fri Aug 28, 2020 1:46 pm    Post subject: Reply with quote

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

Tcl error [stopban]: invalid timerID

and it unbans instantly
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Sat Aug 29, 2020 1:44 pm    Post subject: Reply with quote

Shouldn't it be:
Code:

timer sec [list proc $arg1 $arg2 ...]

I mean shouldn't:
Code:

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

be:
Code:

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

_________________
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
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Aug 29, 2020 5:03 pm    Post subject: Reply with quote

tried that and got the same error caesar:

Tcl error in script for 'timer33938':
invalid timerID
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sun Aug 30, 2020 10:03 am    Post subject: Reply with quote

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

Try this:
Code:
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 Smile
- how to find if the timer exists using its ID. lsearch is the solution Smile
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Aug 30, 2020 11:22 am    Post subject: Reply with quote

tried your last post CrazyCat and it seems to work fine tnx alot
i like to thank Caesar too
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