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
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

clearbans it's not working

Post by Arnold_X-P »

good morning to all
I found this tcl that cleans the channels bans
I used it and began my eggdrop again but the tcl never worked.

my eggdrop is 6.21
[16:23] * sedition sets mode: +b mmmmdd!*@*
[16:23] * sedition sets mode: +b *!*@200.36.689.3
[16:23] <sedition> !op
[16:26] * JulieTh sets mode: +o sedition
[16:27] * sedition sets mode: +b *!*@200.36.689.3669
[16:27] * sedition sets mode: +b utee!*@*
[16:27] <@sedition> !clearbans
he would be grateful to them very much if someone makes her work

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

##############################################

################
bind pub o|o !clearbans cb

proc cb { nick uhost hand chan arg } {
        foreach global_ban [banlist] {
                killban [lindex $global_ban 0]
        }
   
        foreach chan_ban [channels] {
                foreach ban [banlist $chan_ban] {
                        killchanban $chan_ban [lindex $ban 0]
                }
        }
}
putlog "cb.tcl ver 0.1 by tomekk loaded"
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Re: clearbans it's not working

Post by willyw »

Arnold_X-P wrote:
...

Code: Select all

   
        foreach chan_ban [channels] {
                foreach ban [banlist $chan_ban] {
                        killchanban $chan_ban [lindex $ban 0]
                }
        }
...
I suspect the above section.


Try replacing it with this:

Code: Select all


foreach c [channels] {
		if {[botonchan $c]} {
			foreach chan_ban [chanbans $c] {
				pushmode $c -b [lindex $chan_ban 0]
			}
		}
	}
This is untested.
You need to test it carefully.

I hope this helps.
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
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

The script looks fine as it was first written, it cleans up the bot's internal ban list.
That has nothing to do with the current bans set on any channel on irc:)
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

SpiKe^^ wrote: ...
That has nothing to do with the current bans set on any channel on irc:)
Yep. Exactly. And I suspect that is what he is looking for.
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: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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
	set banlist [chanbans $chan]
	set len [llength $banlist]
	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
		}
		pushmode $chan -$mode $masks
	}
}
Set clearbans(max) to match the max amount of ban modes per line the IRC Server you are connected to.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Re: clearbans it's not working

Post by Arnold_X-P »

thanks willyw SpiKe^^ (my bros) caesar
thank you very much 8)
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Re: clearbans it's not working

Post by Arnold_X-P »

[11:19] * sedition sets mode: +b *!*@233.86.69.3
[11:19] * sedition sets mode: +b *!*@233.86.69.3ddd
[11:19] * sedition sets mode: +b lucas!*@*
[11:25] * sedition sets mode: +b mmss!*@*
[11:25] * sedition sets mode: +b mmsssss!*@*
[11:25] * sedition sets mode: +b pols!*@*
[11:25] * sedition sets mode: +b stim!*@*
[11:36] <@sedition> !clearbans
[11:37] * sedition sets mode: +b bopm!*@*
[11:37] * sedition sets mode: +b bopm39!*@*

I proved both suggestions and none worked it does not remove the bans
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Re: clearbans it's not working

Post by willyw »

Arnold_X-P wrote: ...
I proved both suggestions and none worked it does not remove the bans

Tested this:

Code: Select all

foreach c [channels] {
      if {[botonchan $c]} {
         foreach chan_ban [chanbans $c] {
            pushmode $c -b [lindex $chan_ban 0]
         }
      }
   } 
from earlier post.

It works for me. Removes channel bans (not bans within the bot)

Post your complete script, just as it was when you tested it.


p.s.
Please clarify:
You want to remove bans set within the bot?
You want to remove bans set by channel Ops, on the channel?
You want to remove both?
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
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Re: clearbans it's not working

Post by Arnold_X-P »

I want that it removes or removes both bans

its writing does not work
begin my eggdrop again and try and it does not work :roll:
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Let's work a little with Caesar's code:)

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
  set banlist [chanbans $chan]
  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
}

Set clearbans(max) to match the max amount of ban modes per line the IRC Server you are connected to.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

clearbans it's not working - solved

Post by Arnold_X-P »

thanks SpiKe^^ :D
thank you friend you are a genius ..



[19:30] <@sedition> !clearbans
[19:30] * JulieTh sets mode: -bbbb dompe!*@* mdmmdd!*@* *!*@52.36.988. *!*@52.36.988.8
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3776
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
	foreach {ban bywho age} [join [chanbans $chan]] {
		lappend banlist $ban
	}
	set len [llength $banlist]
	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"
	}
}
And I'm an idiot cos rushed and forgot that chanbans returns an array with 3 elements (ban, by who and seconds) for each ban.

Switched to puthelp cos for some reason that I don't understand right now the pushmode doesn't do anything although the variables are ok and should work, yet nothing happens. No error, no nothing. :roll:

Added a:

Code: Select all

putlog "mode $chan -$mode $masks"
for debugging purposes and see the mode change just fine in party-line:
[04:56:52] mode #chan -bbbbbb *!*@6 *!*@5 *!*@4 *!*@3 *!*@2 *!*@1
[04:56:52] mode #chan -bbbbbb *!*@12 *!*@11 *!*@10 *!*@9 *!*@8 *!*@7
[04:56:52] mode #chan -bbbbb *!*@17 *!*@16 *!*@15 *!*@14 *!*@13
yet nothing happens on the channel. But as soon as switch to puthelp i see the mode change on the channel as well:
[08:00:44] <@cez> !clearbans
[08:00:44] * Bot sets mode: -bbbbbb *!*@1 *!*@2 *!*@3 *!*@4 *!*@5 *!*@6
[08:00:46] * Bot sets mode: -bbbbbb *!*@7 *!*@8 *!*@9 *!*@10 *!*@11 *!*@12
[08:00:48] * Bot sets mode: -bbbbb *!*@13 *!*@14 *!*@15 *!*@16 *!*@17
Anyone can shed some light on this? Eggdrop v1.6.21. TCL 8.6.1.
Once the game is over, the king and the pawn go back in the same box.
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 »

but the tcl lacks something more a little that newly it notices today

that happens if the list of bans this empty absence that more to add

example:

[19:09] <@sedition> !clearbans
[19:13] <@JulieTh> #tcls Bans list is empty.
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
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 »

quite very well you achieved it
once again thanks for the help friend..

[22:20] * sedition sets mode: +b k!*@*
[22:20] <@sedition> !clearbans
[22:20] * JulieTh sets mode: -b k!*@*
[22:20] <@sedition> !clearbans
[22:20] <@JulieTh> #bom Bans list is empty.
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
Post Reply