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.

timed unset of a channel mode and kill timer if running

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

timed unset of a channel mode and kill timer if running

Post by simo »

hey there,
i was curious how this code that was checking for ban +b m:*!*@* could be modified we actually wanted to check for channel mode +U and -U
if +U is set we wanted to have a timer remove it after 20 min
and if some chanops unsets it #channel -U before the timer has expired 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($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:*!*@*
   }
}

and instead of pushmode we wanted to use a regular mode used
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

so basically if channel mode +U has been set to have a timer unset it in 20 minutes but if a chanop or anything else unsets it manually -U to halt the timer as its no longer needed
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried this but it didnt react as it prob doesnt recognize the channel mode +U
-U

Code: Select all

bind mode - "#% +U" runbanX5
bind mode - "#% -U" stopbanX5

proc runbanX5 {nick uhost handle chan mode target} {
      if {[string first U [getchanmode $target]] ne "-1"} {   
      set ::btimer($chan) [list [timer 20 [list rmbanX5 $chan]]]
   }
}

proc stopbanX5 {nick uhost handle chan mode target} {
      if {[string first U [getchanmode $target]] ne "-1"} {   
      rmbanX5 $chan
   }
}

 

proc rmbanX5 {chan} {
   if { [array exists ::btimer] && [info exists ::btimer($chan)] } {
      if { [lsearch -index 2 [timers] $::btimer($chan)] != -1} {
         killtimer $::btimer($chan)
      }
      unset ::btimer($chan)
   }
      if {[string first U [getchanmode $chan]] ne "-1"} {   
     putnow "mode $chan -U"  
     }
}
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Is there any way to achieve this?
Post Reply