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 »

We can add some debugging if you would like to it to see it it's indeed something server side or bot side. :)
Once the game is over, the king and the pawn go back in the same box.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

simo wrote: ...
but its ok if theres any remaining ban left i ll remove manually

thnx again caesar
Just curious -

If you immediately run it again (and again if necessary), what happens on each run? Does is remove some, part, or none?

This may be useful info for anyone that is trying to figure it out.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

After or before the:

Code: Select all

puthelp "MODE $chan -$mode $masks"
add the following line and do the !clarbans:

Code: Select all

putlog "Clearbans: mode: $mode | masks: $masks"
and compare what you see in DCC Chat with it with what happens on the channel.
Once the game is over, the king and the pawn go back in the same box.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

simo wrote:is there a way to make it clear all bans
Let's try this Not using the eggdrop [chanbans $chan] command...

Code: Select all

# clearchanbans.tcl revisited #

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 clearbans($chan) [list 0]

  bind raw - 367 cb:bind:raw
  bind raw - 368 cb:bind:raw

  putserv "MODE $chan b"
  return 0
}

proc cb:bind:raw {from key text} {
  global clearbans
  lassign [split $text] not chan mask

  if {![info exists clearbans($chan)]} {  return 0  }

  set masks [lassign $clearbans($chan) total]

  if {$key == 367} {
    lappend masks $mask  ;  incr total
  }

  set cnt [llength $masks]
  if {$total == 0} {
    puthelp "PRIVMSG $chan :$chan Bans list is empty."
  } elseif {$cnt == $clearbans(max) || ($cnt>0 && $key==368)} {
    set mode [string repeat "b" $cnt]
    putserv "MODE $chan -$mode [join $masks]"

    set clearbans($chan) [list $total]
  } else {
    set clearbans($chan) [linsert $masks 0 $total]
  }

  if {$key == 368} {
    unset clearbans($chan)
    unbind raw - 367 cb:bind:raw
    unbind raw - 368 cb:bind:raw
    puthelp "PRIVMSG $chan :Removed $total bans. $chan Bans list is empty."
  }

  return 1
}

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 »

thnx spike^^ this one clears banlist leaving none fine job well done
User avatar
d3n
Voice
Posts: 15
Joined: Wed Jul 13, 2016 2:30 pm
Location: Italy
Contact:

Post by d3n »

i put this file on my bot, but doesn't work :S and say anything... why?
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

which tcl used... and it be fixed that error goes out for him so they help him..


to me me both work well
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
d3n
Voice
Posts: 15
Joined: Wed Jul 13, 2016 2:30 pm
Location: Italy
Contact:

Post by d3n »

Code: Select all

# clearchanbans.tcl revisited #

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 clearbans($chan) [list 0]

  bind raw - 367 cb:bind:raw
  bind raw - 368 cb:bind:raw

  putserv "MODE $chan b"
  return 0
}

proc cb:bind:raw {from key text} {
  global clearbans
  lassign [split $text] not chan mask

  if {![info exists clearbans($chan)]} {  return 0  }

  set masks [lassign $clearbans($chan) total]

  if {$key == 367} {
    lappend masks $mask  ;  incr total
  }

  set cnt [llength $masks]
  if {$total == 0} {
    puthelp "PRIVMSG $chan :$chan Bans list is empty."
  } elseif {$cnt == $clearbans(max) || ($cnt>0 && $key==368)} {
    set mode [string repeat "b" $cnt]
    putserv "MODE $chan -$mode [join $masks]"

    set clearbans($chan) [list $total]
  } else {
    set clearbans($chan) [linsert $masks 0 $total]
  }

  if {$key == 368} {
    unset clearbans($chan)
    unbind raw - 367 cb:bind:raw
    unbind raw - 368 cb:bind:raw
    puthelp "PRIVMSG $chan :Removed $total bans. $chan Bans list is empty."
  }

  return 1
} 
i put this, and i used eggdrop 1.6.21 ! this tcl doesn't work
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

d3n wrote:i put this, and i used eggdrop 1.6.21 ! this tcl doesn't work
For anyone reading along:

I think that he had the channel name, when entered with .+chan
with the first letter in upper case.

$clearbans($chan) might be: #Channelname
when it was looking for: #channelname from the ircd.
Or vice versa... whew...

A line like this:

Code: Select all

set chan [string tolower $chan]
in the right place, seemed to fix it.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i dont know why lately this same exact code returns this error
Tcl error [clear:bans]: wrong # args: should be "clear:bans nick uhost hand text"
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Do a .tcl $errorInfo from DCC Chat/Telnet with the bot when you see that error to track down the source of the issue.

Would also help if post what code you used, as me and Spike offered a few solution, granted his final one uses a different approach than what I suggested initially.

Here's my "version" that also relies on the raw 367 outputs from the server instead of bot's banlist.

Code: Select all

set clearbans(max) 6

bind pub o|o !clearbans clear:bans

proc clear:bans {nick uhost hand chan text} {
	global clearbans
	set chan [string tolower $chan]
	if {![botisop $chan]} return
	set clearbans($chan) {}
	bind raw - 367 cb:bind:raw
	bind raw - 368 cb:bind:raw
	putserv "MODE $chan b"
} 

proc cb:bind:raw {from key text} {
	global clearbans
	switch -- $key {
		367 {
			lassign [split $text] bot chan mask
			set chan [string tolower $chan]
			if {![info exists clearbans($chan)]} return
			if {[lsearch $clearbans($chan) $mask] > -1} return
			lappend clearbans($chan) $mask
		}
		368 {
			lassign [split $text] bot chan
			set chan [string tolower $chan]
			if {![info exists clearbans($chan)]} return
			unbind raw - 367 cb:bind:raw
			unbind raw - 368 cb:bind:raw
			set len [llength $clearbans($chan)] 
			set total 0
			if {$len > 0} {
				while {$len > 0} {
					if {$len > $clearbans(max)} {
						set mode [string repeat "b" $clearbans(max)]
						set masks [join [lrange $clearbans($chan) 0 [expr {$clearbans(max) - 1}]]]
						set clearbans($chan) [lrange $clearbans($chan) $clearbans(max) end]
						incr len -$clearbans(max)
						incr total $clearbans(max)
					} else {
						set mode [string repeat "b" $len]
						set masks [join $clearbans($chan)]
						incr total $len
						set len 0
					}
					puthelp "MODE $chan -$mode $masks"
				}
			} else {
				puthelp "PRIVMSG $chan :Bans list is empty."
			}
			puthelp "PRIVMSG $chan :Removed $total bans and list is now empty." 
		}
	}
}
Did minimal testing so reply back if you get any error.

Edit: Fixed.
Last edited by caesar on Tue Feb 05, 2019 2:04 am, edited 1 time in total.
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 »

hey there caesar gettin this in return:
19:04:18 <Cappuccino> Tcl error: invalid command name "wrong # args: should be "clear:bans nick uhost hand text"
19:04:18 <Cappuccino> Tcl error: while executing
19:04:18 <Cappuccino> Tcl error: "clear:bans $_pub1 $_pub2 $_pub3 $_pub4 $_pub5""
using your version returns me the same error
S
Stefano1990
Voice
Posts: 25
Joined: Mon Jun 04, 2018 10:07 am
Contact:

Hello

Post by Stefano1990 »

the clearbans of ceasar show me this when i used again the public command !clearbans !cb .cb
and is not remove all bans need to retype same command
need to remove unban all bans #channel 10 20 30 max
and to have and 2 others option extra for specific user to unban !unban !ub .ub nick
and if on channel status ban have up on 1 hour bans to remove it automatically
if is possbible to fix it thx in advance

with set clearbans(max) 12

removing 24 ban and remains some others on ban when i retype second time same !clearbans is show me this on PL
Tcl error [cb:bind:raw]: wrong # args: should be "incr varName ?increment?"
[07:50:18] <Jupiter> !clearbans
[07:50:18] * TEST sets mode: -bbbbbbbbbbbb *!*@Test.com-auy.493.44.63.IP *!*@Test.com-119.446.34.43.IP *!*@Test.com-e16.301.24.70.IP *!*@Test.com-3qe.231.01.58.IP *!*@Test.com-iad.991.65.43.IP *!*@Test.com-864.736.99.51.IP *!*@Test.com-k0a.858.08.93.IP *!*@Test.com-nqm.630.94.98.IP *!*@Test.com-gb1.376.93.25.IP *!*@Test.com-r08.604.99.34.IP *!*@Test.com-06c.073.85.59.IP ~q:*!*@Test.com-4cu.725.79.52.IP
[07:50:18] * TEST sets mode: -bbbbbbbbbbbb *!*@Test.com-082.554.45.60.IP *!*@Test.com-5yb.488.57.95.IP ~q:*!*@Test.com-pp2.301.69.59.IP ~q:*!*@Test.com-hfz.047.53.28.IP ~q:*!*@Test.com-ufb.604.06.85.IP ~q:*!*@Test.com-c02.400.26.20.IP ~q:*!*@Test.com-22n.154.50.91.IP ~q:*!*@Test.com-7k1.596.54.91.IP ~q:*!*@Test.com-p8v.513.59.32.IP ~q:*!*@Test.com-827.144.52.27.IP ~q:*!*@Test.com-8p0.118.97.15.IP *!*@Test.com-429.729.78.47.IP
[07:51:05] <Jupiter> !clearbans
Use your common sense and try not to make me look too much like I know what I'm doing.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

@simo Sounds like you have two procs with the same name. By any chance you have this one? Try unloading all scripts and leave only this one and see if you still get the error. A fix for this issue would be to get everything into a namespace.

@Stefano1990 Yeah, my bad. Locate:

Code: Select all

incr total $clearbans(max) $len
and replace it with:

Code: Select all

incr total $len
Did a copy/paste and forgot to remove $clearbans(max). Now it should remove everything nicely.
Last edited by caesar on Tue Feb 05, 2019 2:43 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
S
Stefano1990
Voice
Posts: 25
Joined: Mon Jun 04, 2018 10:07 am
Contact:

Hello

Post by Stefano1990 »

hello ceasar now its works look great job thx ,

Code: Select all

[08:23:27] Jupiter !clearbans
[08:23:27] * TEST sets mode: -bbbbbbbbbbbb ~q:*!*@Test.com-4cu.725.79.52.IP *!*@Test.com-06c.073.85.59.IP *!*@Test.com-r08.604.99.34.IP *!*@Test.com-gb1.376.93.25.IP *!*@Test.com-nqm.630.94.98.IP *!*@Test.com-k0a.858.08.93.IP *!*@Test.com-864.736.99.51.IP *!*@Test.com-iad.991.65.43.IP *!*@Test.com-3qe.231.01.58.IP *!*@Test.com-e16.301.24.70.IP *!*@Test.com-119.446.34.43.IP *!*@Test.com-auy.493.44.63.IP
[08:23:27] * TEST sets mode: -bbbbbbbbbbbb ~q:*!*@Test.com-hfz.047.53.28.IP ~q:*!*@Test.com-pp2.301.69.59.IP *!*@Test.com-5yb.488.57.95.IP *!*@Test.com-082.554.45.60.IP *!*@Test.com-429.729.78.47.IP ~q:*!*@Test.com-8p0.118.97.15.IP ~q:*!*@Test.com-827.144.52.27.IP ~q:*!*@Test.com-p8v.513.59.32.IP ~q:*!*@Test.com-7k1.596.54.91.IP ~q:*!*@Test.com-22n.154.50.91.IP ~q:*!*@Test.com-c02.400.26.20.IP ~q:*!*@Test.com-ufb.604.06.85.IP
[08:23:27] * TEST sets mode: -b *!*@Test.com-i49.482.76.85.IP
[08:23:27] * &TEST Removed 25 bans and list is now empty.
but can u add and 2 options and to unban a simple user . ! ub nick not other bans and when the bans have 1 hour and more to remove automatically all bans
thx in advance
Use your common sense and try not to make me look too much like I know what I'm doing.
Post Reply