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.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
simo
Revered One
Posts: 1100 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun May 07, 2023 11:17 am
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
CrazyCat
Revered One
Posts: 1276 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sun May 07, 2023 11:52 am
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"
}
}
}
simo
Revered One
Posts: 1100 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun May 07, 2023 12:14 pm
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
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sun May 07, 2023 12:21 pm
Code: Select all
set lasts [lrange $chanbanlist end-[expr {$n - 1}] end]
simo
Revered One
Posts: 1100 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun May 07, 2023 12:24 pm
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
simo
Revered One
Posts: 1100 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun May 07, 2023 1:07 pm
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.
simo
Revered One
Posts: 1100 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun May 07, 2023 1:19 pm
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
simo
Revered One
Posts: 1100 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Sun May 07, 2023 1:35 pm
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