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.

add banlist counter

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

add banlist counter

Post by simo »

greetings i tried to add a counter of the amount of line in this banlist tcl but it doesnt seem to count but instead it uses number 1 only im not that familiar with incr so i thought id ask here.

Code: Select all


bind dcc n banx dcc_ban_duration


proc dcc_ban_duration {hand idx channel} {
	set chan [lindex $channel 0]
	if {![validchan $chan]} {
		putidx $idx "um... I'm not in $chan... what are u thinking?"
	} else {
		bind raw - 367 Bans:Duration:OUtput
		bind raw - 368 Bans:Duration:OUtput
		putserv "mode $chan +b"
	}
}


proc Bans:Duration:OUtput {from key text} {

	switch -- $key {

		367 {
			lassign [split $text] bot chan mask
			if {[lsearch $chan $mask] > -1} return
			set banner2 "[lindex [split $text] 3]"
			set banner  "[lindex [split $banner2 "!"] 0]"
			set banmask "[lindex [split $text] 2]"
			set banduration2 "[lindex [split $text] 4]"
			set banduration "[expr [clock seconds] - $banduration2]"
			set currentTime "[clock seconds]"
			set Ago [expr $currentTime - $banduration2]
			incr BanListCounter 1
			putlog "\00314,01 \[$BanListCounter\] - $banner - $chan - \00311 $mask - \00308 [duration $Ago] \017"
		}

		368 {
			unset -nocomplain BanListCounter
			unbind raw - 367 Bans:Duration:OUtput
			unbind raw - 368 Bans:Duration:OUtput
		}


	}
}






here's an example of a test:

18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@77gd-9a2f-60ob-qqc-7s90.486.5739.IP - 19 minutes 34 seconds
18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@7ecg-tm1o-148-j0h-vt1.3634.774.IP - 19 minutes 34 seconds
18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@55z-9j7-l01w-819-5hzp.9315.873.IP - 19 minutes 34 seconds
18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@puy-9669-74m7-t2t-vt3.085.563.IP - 19 minutes 34 seconds
18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@i4mc-ao2c-m3t-zwa-g7o5.545.8772.IP - 19 minutes 34 seconds
18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@83p9-y8l-v018-7l7-8z5.869.849.IP - 19 minutes 34 seconds
18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@77c-nfc5-dlt-2m96-s56v.7116.3083.IP - 19 minutes 34 seconds
18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@768-829a-726-1arl-l0x.218.8911.IP - 19 minutes 34 seconds
18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@t6i-112-2gf-nvtp-3dxr.367.3724.IP - 19 minutes 34 seconds
18:46:52 <EggBot> [18:46:54] [1] - Simo - *!*@ldh3-owg6-1721-1q06-l05.903.267.IP - 19 minutes 34 seconds
M
MMX
Voice
Posts: 5
Joined: Sun Mar 20, 2022 5:42 pm

Re: add banlist counter

Post by MMX »

You receive the ban list from the server line by line and these binds trigger for each line/ban. Your counter variable is local, so you create/increase it from 0 to 1 for each ban line and that's why it does not go higher than 1. Maybe you should try to make your counter variable global.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Re: add banlist counter

Post by simo »

thanks MMX that seems to work well.
Post Reply