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.

auto clear only certain bans with cron

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: 1104
Joined: Sun Mar 22, 2015 2:41 pm

auto clear only certain bans with cron

Post by simo »

Greetz folks,

we have been using this tcl for a while for 1 channel and it seems to work fine if used for just 1 channel altho im not sure if its proper written cause when we enable it for multiple channels it doesnt seem to trigger for all channels i have been testing with this for a while
but i cant get it to clear bans on all enabled channels and also i wonder if there is a way to send the mode #channel b with a delay incase multiple channels are enabled to prevent to send all in 1 go the way it is now and may result in possible disconnect due too commands flood perhaps also i noticed in the putlog "«4» - $chan - $Testclearbans($chan)" it doesnt show all stacked banmasks sometimes the last one in the list is cut and not the entire banmask has been stored for some reason not sure how to make sure only complete and actuall existing banmasks are stored.

Code: Select all


   bind cron - {* * * * *} Tester-botbans-clear:cron

	setudef flag checkbotbans


	proc Tester-botbans-clear:cron {min hour day month weekday} {
   global Testclearbans clearbotbans_throttle
		foreach channel [channels] {
                 set channel [string tolower $channel] 
		        if {![channel get $channel checkbotbans]} continue             
                  if {![botisop $channel]} { continue }
                  set Testclearbans($channel) {} 
			  bind raw - 367 ClearBN:BindS:RawX 
                bind raw - 368 ClearBN:BindS:RawX
                putserv "MODE $channel b" 
                  putlog "«1» - mode $channel b"
		}
	}




proc ClearBN:BindS:RawX {from key text} {
	global Testclearbans
                 set Testclearbans(max) 10
	switch -- $key {
		367 {
			lassign [split $text] bot chan mask
			set chan [string tolower $chan]
			if {![info exists Testclearbans($chan)]} return
			if {[lsearch $Testclearbans($chan) $mask] > -1} return
         if {![regexp {U\:|m\:G|u\:G\:|N\:} $mask]} { lappend Testclearbans($chan) $mask }

                  putlog "«3» - $chan - $mask"
		}
		368 {
			lassign [split $text] bot chan
			set chan [string tolower $chan]
			unbind raw - 367 ClearBN:BindS:RawX
			unbind raw - 368 ClearBN:BindS:RawX
			if {![info exists Testclearbans($chan)]} { return 0 }

                  putlog "«4» - $chan - $Testclearbans($chan)"

			set len [llength $Testclearbans($chan)] 
			set total 0
			if {$len > 0} {
				while {$len > 0} {
					if {$len > $Testclearbans(max)} {
						set mode [string repeat "b" $Testclearbans(max)]
						set masks [join [lrange $Testclearbans($chan) 0 [expr {$Testclearbans(max) - 1}]]]
						set Testclearbans($chan) [lrange $Testclearbans($chan) $Testclearbans(max) end]
						incr len -$Testclearbans(max)
						incr total $Testclearbans(max)
					} else {
						set mode [string repeat "b" $len]
						set masks [join $Testclearbans($chan)]
						incr total $len
						set len 0
					}
                           incr counter 1
                           after [expr {$counter*4000}] [list  putnow "MODE $chan -$mode $masks"] 
				}
			} 
		}
	}
}

when testing i get these results :

notice (channel #test has no bans in it yet is still displays «4») the other channels have bans set and yet dont display in any of the putlogs except the first wich checks if the mode $chan b is actually sent.

«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -
«1» - mode #test b
«1» - mode #cappuccino b
«1» - mode #chat b
«1» - mode #rifchat b
«1» - mode #rifsytes b
«1» - mode #lahore-relay b
«4» - #test -


Thanks in advance.
Post Reply