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.

remove last ban or a range of last set bans

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

remove last ban or a range of last set bans

Post by simo »

greetingz folks,

we have been using this code for a while now and it works fine removing the last set single ban im wondering how this could be edited to remove either last few set bans or just the single last one that was set :

Code: Select all

bind pub -|- "!rlb" unban:lastbans

proc unban:lastbans {nick uhost hand chan text} {
   global botnick
    if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
     set chanbanlist [lsort -index 2 -integer -decreasing [chanbans $chan]]
     set last [lindex [lindex $chanbanlist end] 0]
     if {[llength $chanbanlist] > 0} {
     putquick "MODE $chan -b $last"
     return 0
  }
}


for example :

!rlb 4
to remove the last 4 set bans

or :

!rlb


to remove only the single last set ban
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Quite easy, you didn't search a lot I guess:

Code: Select all

bind pub -|- "!rlb" unban:lastbans

proc unban:lastbans {nick uhost hand chan text} {
   global botnick
    if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
     set n [join [lindex $text 0]]
     if {![string is integer -strict $n]} { set n 0 }
     set chanbanlist [lsort -index 2 -integer -decreasing [chanbans $chan]]
     set lasts [lrange $chanbanlist end-$n end]
     foreach last $lasts {
         putquick "MODE $chan -b $last"
     }
  }
}
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks for the reply CrazyCat i tested it and found it sometimes when for example using like:

!rlb 2
it removes 3 instead of 2
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 lasts [lrange $chanbanlist end-[expr {$n - 1}] end]
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: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tried your suggestion as well Spike^^ like this :

Code: Select all


bind pub -|- "!rlb" unban:lastbans

proc unban:lastbans {nick uhost hand chan text} {
   global botnick
    if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
     set n [join [lindex $text 0]]
     if {![string is integer -strict $n]} { set n 0 }
     set chanbanlist [lsort -index 2 -integer -decreasing [chanbans $chan]]
     set lasts [lrange $chanbanlist end-[expr {$n - 1}] end]
     foreach last $lasts {
       pushmode $chan -b $last
     }
}


when i use like:

!rlb 5


for some reason it removes only 2 while there are 10 bans in the banlist
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

on suggestion of Spike^^ i came up with this wich seems to work but not sure if its proper wiritten :

Code: Select all


bind pub -|- "!rlb" unban:lastbans

proc unban:lastbans {nick uhost hand chan text} {
    if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
     set n [join [lindex $text 0]]
    if {![string is digit $n]} { putserv "notice $nick :value must be digits only like\: !rlb 3 "  ; return 0 }
     if {![string is integer -strict $n]} { set n 0 }
     set chanbanlist [lsort -index 2 -integer -decreasing [chanbans $chan]]
     set lasts [lrange $chanbanlist end-[expr {$n - 1}] end]
     foreach last $lasts {
       pushmode $chan -b "[lindex $last 0]"  
     }
}

Last edited by simo on Mon May 08, 2023 10:14 am, edited 1 time in total.
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

the single
!rlb
still doesnt seem to trigger at all tho

from what i understood of the code is it expect a range everytime iic
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

on suggestion of Spike^^ i came up with this :

Code: Select all


bind pub -|- "!rlb" unban:lastbans

proc unban:lastbans {nick uhost hand chan text} {
    if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }
     set n [join [lindex $text 0]]
    if {![string is digit $n]} { putserv "notice $nick :value must be digits only like\: !rlb 3"  ; return 0 }
    if {![string is digit -strict $n] || $n == 0} { set n 1 }
     set chanbanlist [lsort -index 2 -integer -decreasing [chanbans $chan]]
     set lasts [lrange $chanbanlist end-[expr {$n - 1}] end]
     foreach last $lasts {
       pushmode $chan -b "[lindex $last 0]"
     }
}


not sure if its all written proper but it seems to work as expected thanks so far gentz
Post Reply