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.

clearbans it's not working

Help for those learning Tcl or writing their own scripts.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

set clearbans(max) 6

bind pub - !clearbans clear:bans

proc clear:bans {nick uhost hand chan text} {
	global clearbans
	if {![botisop $chan]} return
	set chanbans [chanbans $chan]
	set len [llength $chanbans]
	if {!$len} {
		puthelp "PRIVMSG $chan :Bans list is empty."
		return
	}
	foreach {ban bywho age} [join $chanbans] {
		lappend banlist $ban
	}
	while {$len > 0} {
		if {$len > $clearbans(max)} {
			set mode [string repeat "b" $clearbans(max)]
			set masks [join [lrange $banlist 0 [expr {$clearbans(max) - 1}]]]
			set banlist [lrange $banlist $clearbans(max) end]
			incr len -$clearbans(max)
		} else {
			set mode [string repeat "b" $len]
			set masks [join $banlist]
			set len 0
		}
		puthelp "MODE $chan -$mode $masks"
	}
}
[07:48:01] * cez sets mode: +bbbbbb *!*@5 *!*@6 *!*@7 *!*@8 *!*@9 *!*@10
[07:48:07] * cez sets mode: +bbbb *!*@1 *!*@2 *!*@3 *!*@4
[07:48:56] <@cez> !clearbans
[07:48:56] * Bot sets mode: -bbbbbb *!*@10 *!*@9 *!*@8 *!*@7 *!*@6 *!*@5
[07:48:58] * Bot sets mode: -bbbb *!*@4 *!*@3 *!*@2 *!*@1
[07:49:00] <@cez> !clearbans
[07:49:00] <@Bot> Bans list is empty.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i was wondering why it always leaves some bans left and doest clear all bans ?

also it seems anyone can clear bans
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

i was wondering why it always leaves some bans left and doest clear all bans ?
Which one of these scripts are you commenting on?
also it seems anyone can clear bans
My public command is limited to o|o
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i was refer to:

Code: Select all

set clearbans(max) 6

bind pub - !clearbans clear:bans

proc clear:bans {nick uhost hand chan text} {
   global clearbans
   if {![botisop $chan]} return
   set chanbans [chanbans $chan]
   set len [llength $chanbans]
   if {!$len} {
      puthelp "PRIVMSG $chan :Bans list is empty."
      return
   }
   foreach {ban bywho age} [join $chanbans] {
      lappend banlist $ban
   }
   while {$len > 0} {
      if {$len > $clearbans(max)} {
         set mode [string repeat "b" $clearbans(max)]
         set masks [join [lrange $banlist 0 [expr {$clearbans(max) - 1}]]]
         set banlist [lrange $banlist $clearbans(max) end]
         incr len -$clearbans(max)
      } else {
         set mode [string repeat "b" $len]
         set masks [join $banlist]
         set len 0
      }
      puthelp "MODE $chan -$mode $masks"
   }
}
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Yeah, my fault there. On the test bot don't have access to it so had to leave it blank for debugging. Replace the "-" in

Code: Select all

bind pub - !clearbans clear:bans 
with something you like, for instance o|o to allow only local and global users with "o" flag to do that cleaning.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

works nice caesar only it doesnt seem to clear all bans
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Really? It should. Don't see any reasons it shouldn't. Care to share some of the bans that aren't lifted? maybe I'm missing something.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this is an example:

last ones i had to remove manually myselve
20:23:14 AmaziGH Sets Mode on #servernet to: +bbbbbbbbbbbbbbb *!*@ServerNet-nw2.306.31.32.IP *!*@ServerNet-6yf.996.67.52.IP *!*@ServerNet-65h.270.93.88.IP *!*@ServerNet-gw4.255.78.85.IP *!*@ServerNet-20s.322.67.09.IP *!*@ServerNet-3pm.573.54.19.IP *!*@ServerNet-m96.584.30.96.IP *!*@ServerNet-5h7.567.17.15.IP *!*@ServerNet-aph.345.71.65.IP *!*@ServerNet-6v2.134.07.52.IP *!*@ServerNet-x10.424.75.92.IP *!*@ServerNet-929.684.29.67.IP *!*@ServerNet-a8q.384.05.73.IP *!*@ServerNet-e0x.855.57.99.IP *!*@Serv
20:23:14 AmaziGH Sets Mode on #servernet to: +bbbbbbbbbbbbbbb *!*@ServerNet-7vy.250.78.84.IP *!*@ServerNet-ny3.519.27.30.IP *!*@ServerNet-9y7.117.89.68.IP *!*@ServerNet-428.964.81.58.IP *!*@ServerNet-5pz.964.12.89.IP *!*@ServerNet-d80.586.43.90.IP *!*@ServerNet-8ax.895.02.10.IP *!*@ServerNet-lhk.173.07.82.IP *!*@ServerNet-u6a.859.65.69.IP *!*@ServerNet-4lk.857.05.09.IP *!*@ServerNet-uwd.850.13.71.IP *!*@ServerNet-a7y.401.71.60.IP *!*@ServerNet-x75.265.80.44.IP *!*@ServerNet-ihi.957.85.85.IP *!*@Serv
20:23:14 AmaziGH Sets Mode on #servernet to: +bbbbbbbbbbbbbbb *!*@ServerNet-857.688.05.84.IP *!*@ServerNet-l9b.666.65.96.IP *!*@ServerNet-295.092.61.00.IP *!*@ServerNet-r89.545.76.68.IP *!*@ServerNet-956.593.88.84.IP *!*@ServerNet-739.155.90.66.IP *!*@ServerNet-0u6.010.74.63.IP *!*@ServerNet-2j0.486.14.37.IP *!*@ServerNet-2qg.395.54.78.IP *!*@ServerNet-d90.320.18.31.IP *!*@ServerNet-532.443.07.22.IP *!*@ServerNet-am0.403.63.16.IP *!*@ServerNet-o42.086.68.66.IP *!*@ServerNet-8j8.212.02.18.IP *!*@Serv
20:23:15 AmaziGH Sets Mode on #servernet to: +bbbbb *!*@ServerNet-3fz.369.64.30.IP *!*@ServerNet-z34.181.57.95.IP *!*@ServerNet-o41.840.38.06.IP *!*@ServerNet-u09.760.22.12.IP *!*@ServerNet-83z.908.06.67.IP
20:23:20 (AmaziGH) : !clearbans
20:23:20 &SeCuRiTy Sets Mode on #servernet to: -bbbbbbbbb *!*@ServerNet-nw2.306.31.32.IP *!*@ServerNet-6yf.996.67.52.IP *!*@ServerNet-65h.270.93.88.IP *!*@ServerNet-gw4.255.78.85.IP *!*@ServerNet-20s.322.67.09.IP *!*@ServerNet-3pm.573.54.19.IP *!*@ServerNet-m96.584.30.96.IP *!*@ServerNet-5h7.567.17.15.IP *!*@ServerNet-aph.345.71.65.IP
20:23:20 &SeCuRiTy Sets Mode on #servernet to: -bbbbbbbbbbbbbbb *!*@ServerNet-6v2.134.07.52.IP *!*@ServerNet-x10.424.75.92.IP *!*@ServerNet-929.684.29.67.IP *!*@ServerNet-a8q.384.05.73.IP *!*@ServerNet-e0x.855.57.99.IP *!*@ServerNet-7vy.250.78.84.IP *!*@ServerNet-ny3.519.27.30.IP *!*@ServerNet-9y7.117.89.68.IP *!*@ServerNet-428.964.81.58.IP *!*@ServerNet-5pz.964.12.89.IP *!*@ServerNet-d80.586.43.90.IP *!*@ServerNet-8ax.895.02.10.IP *!*@ServerNet-lhk.173.07.82.IP *!*@ServerNet-u6a.859.65.69.IP *!*@ServerNet-4lk
20:23:20 &SeCuRiTy Sets Mode on #servernet to: -bbbbbbbbbbbbbbb *!*@ServerNet-uwd.850.13.71.IP *!*@ServerNet-a7y.401.71.60.IP *!*@ServerNet-x75.265.80.44.IP *!*@ServerNet-ihi.957.85.85.IP *!*@ServerNet-857.688.05.84.IP *!*@ServerNet-l9b.666.65.96.IP *!*@ServerNet-295.092.61.00.IP *!*@ServerNet-r89.545.76.68.IP *!*@ServerNet-956.593.88.84.IP *!*@ServerNet-739.155.90.66.IP *!*@ServerNet-0u6.010.74.63.IP *!*@ServerNet-2j0.486.14.37.IP *!*@ServerNet-2qg.395.54.78.IP *!*@ServerNet-d90.320.18.31.IP *!*@ServerNet-532
20:23:20 &SeCuRiTy Sets Mode on #servernet to: -bbbbbbbb *!*@ServerNet-am0.403.63.16.IP *!*@ServerNet-o42.086.68.66.IP *!*@ServerNet-8j8.212.02.18.IP *!*@ServerNet-3fz.369.64.30.IP *!*@ServerNet-z34.181.57.95.IP *!*@ServerNet-o41.840.38.06.IP *!*@ServerNet-u09.760.22.12.IP *!*@ServerNet-83z.908.06.67.IP

20:24:48 OperServ Sets Mode on #servernet to: -bbb *!*@ServerNet-6eh.222.56.32.IP *!*@ServerNet-k61.482.40.26.IP *!*@ServerNet-8v5.602.49.99.IP
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

is there a way to make it clear all bans
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Why not use mine that works...

Code: Select all

set clearbans(max) 6

bind pub o|o !clearbans clear:bans

proc clear:bans {nick uhost hand chan text} {
	global clearbans
	if {![botisop $chan]} {  return 0  }
	set banlist [chanbans $chan]

  if {![llength $banlist]} {
    puthelp "PRIVMSG $chan :$chan Bans list is empty."
    return 0
  }

  set blist ""
  set modes ""

  foreach ban $banlist {
    append modes b
    lappend blist [lindex $ban 0]

    if {[llength $blist] == $clearbans(max)} {
      putserv "MODE $chan -$modes [join $blist]"
      set blist ""
      set modes ""
    }
  }

  if {[llength $blist] > 0} {
    putserv "MODE $chan -$modes [join $blist]"
  }

  return 0
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

This makes no sense. I've added about all the bans you quoted above and all where removed.
[07:49:27] <@cez> !clearbans
[07:49:28] <@Bot> Bans list is empty.
[07:49:39] * cez sets mode: +bbbbbb *!*@ServerNet-nw2.306.31.32.IP *!*@ServerNet-6yf.996.67.52.IP *!*@ServerNet-65h.270.93.88.IP *!*@ServerNet-gw4.255.78.85.IP *!*@ServerNet-20s.322.67.09.IP *!*@ServerNet-3pm.573.54.19.IP
[07:49:57] * cez sets mode: +bbbbbb *!*@ServerNet-m96.584.30.96.IP *!*@ServerNet-5h7.567.17.15.IP *!*@ServerNet-aph.345.71.65.IP *!*@ServerNet-6v2.134.07.52.IP *!*@ServerNet-x10.424.75.92.IP *!*@ServerNet-929.684.29.67.IP
[07:49:59] * cez sets mode: +bbbbbb *!*@ServerNet-a8q.384.05.73.IP *!*@ServerNet-e0x.855.57.99.IP *!*@ServerNet-7vy.250.78.84.IP *!*@ServerNet-ny3.519.27.30.IP *!*@ServerNet-9y7.117.89.68.IP *!*@ServerNet-428.964.81.58.IP
[07:50:02] * cez sets mode: +bbbbbb *!*@ServerNet-5pz.964.12.89.IP *!*@ServerNet-d80.586.43.90.IP *!*@ServerNet-8ax.895.02.10.IP *!*@ServerNet-lhk.173.07.82.IP *!*@ServerNet-u6a.859.65.69.IP *!*@ServerNet-4lk.857.05.09.IP
[07:50:04] * cez sets mode: +bbbbbb *!*@ServerNet-uwd.850.13.71.IP *!*@ServerNet-a7y.401.71.60.IP *!*@ServerNet-x75.265.80.44.IP *!*@ServerNet-ihi.957.85.85.IP *!*@ServerNet-857.688.05.84.IP *!*@ServerNet-l9b.666.65.96.IP
[07:50:07] * cez sets mode: +bbbbbb *!*@ServerNet-295.092.61.00.IP *!*@ServerNet-r89.545.76.68.IP *!*@ServerNet-956.593.88.84.IP *!*@ServerNet-739.155.90.66.IP *!*@ServerNet-0u6.010.74.63.IP *!*@ServerNet-2j0.486.14.37.IP
[07:50:09] * cez sets mode: +bbbbbb *!*@ServerNet-2qg.395.54.78.IP *!*@ServerNet-d90.320.18.31.IP *!*@ServerNet-532.443.07.22.IP *!*@ServerNet-am0.403.63.16.IP *!*@ServerNet-o42.086.68.66.IP *!*@ServerNet-8j8.212.02.18.IP
[07:50:19] <@cez> !clearbans
[07:50:22] * Bot sets mode: -bbbbbb *!*@ServerNet-3pm.573.54.19.IP *!*@ServerNet-20s.322.67.09.IP *!*@ServerNet-gw4.255.78.85.IP *!*@ServerNet-65h.270.93.88.IP *!*@ServerNet-6yf.996.67.52.IP *!*@ServerNet-nw2.306.31.32.IP
[07:50:25] * Bot sets mode: -bbbbbb *!*@ServerNet-929.684.29.67.IP *!*@ServerNet-x10.424.75.92.IP *!*@ServerNet-6v2.134.07.52.IP *!*@ServerNet-aph.345.71.65.IP *!*@ServerNet-5h7.567.17.15.IP *!*@ServerNet-m96.584.30.96.IP
[07:50:28] * Bot sets mode: -bbbbbb *!*@ServerNet-428.964.81.58.IP *!*@ServerNet-9y7.117.89.68.IP *!*@ServerNet-ny3.519.27.30.IP *!*@ServerNet-7vy.250.78.84.IP *!*@ServerNet-e0x.855.57.99.IP *!*@ServerNet-a8q.384.05.73.IP
[07:50:31] * Bot sets mode: -bbbbbb *!*@ServerNet-4lk.857.05.09.IP *!*@ServerNet-u6a.859.65.69.IP *!*@ServerNet-lhk.173.07.82.IP *!*@ServerNet-8ax.895.02.10.IP *!*@ServerNet-d80.586.43.90.IP *!*@ServerNet-5pz.964.12.89.IP
[07:50:34] * Bot sets mode: -bbbbbb *!*@ServerNet-l9b.666.65.96.IP *!*@ServerNet-857.688.05.84.IP *!*@ServerNet-ihi.957.85.85.IP *!*@ServerNet-x75.265.80.44.IP *!*@ServerNet-a7y.401.71.60.IP *!*@ServerNet-uwd.850.13.71.IP
[07:50:37] * Bot sets mode: -bbbbbb *!*@ServerNet-2j0.486.14.37.IP *!*@ServerNet-0u6.010.74.63.IP *!*@ServerNet-739.155.90.66.IP *!*@ServerNet-956.593.88.84.IP *!*@ServerNet-r89.545.76.68.IP *!*@ServerNet-295.092.61.00.IP
[07:50:40] * Bot sets mode: -bbbbbb *!*@ServerNet-8j8.212.02.18.IP *!*@ServerNet-o42.086.68.66.IP *!*@ServerNet-am0.403.63.16.IP *!*@ServerNet-532.443.07.22.IP *!*@ServerNet-d90.320.18.31.IP *!*@ServerNet-2qg.395.54.78.IP
Maybe the server has a anti-flood function that prevents you to do mass modes? Have you tried removing all those bans by yourself?
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i have an opered bot with all privliages and no limmitations on testnet wich has max of 15 mode settings in 1 line
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried your version and it works nice
altho sometimes it doesnt remove all bans
i guess there is no way to guarantee that
tnx spike^^
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

As expected, either code you've used makes no sense not to have them all removed and this means there's something on the server side that doesn't let the bot to remove all bans, or more than a certain amount. Count them when it doesn't remove them all and then try with slightly less and see if there's indeed a limit or something.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

server side allows bot to set as much modes as it wants since its opered and limitless privliges so that cant be it

but its ok if theres any remaining ban left i ll remove manually

thnx again caesar
Post Reply