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!
m4s
Halfop
Posts: 97 Joined: Mon Jan 30, 2017 3:24 pm
Post
by m4s » Wed May 16, 2018 2:21 pm
Hello to everyone!
May I ask Your help to create a script for me?
My channel banlist often fills up and I thought my bot should remove the 5 oldest ban if a halfop gives a private command to the bot.
The bans are only channel bans and the format is *!*@host.
Nickbans should not be removed.
The private command and the nr. of bans should be configured in the script.
Thanks for your replies!
Last edited by
m4s on Wed May 23, 2018 1:48 pm, edited 1 time in total.
caesar
Mint Rubber
Posts: 3776 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Thu May 17, 2018 3:30 am
Code: Select all
set clearbans(max) 5
bind msg o|o clearbans clear:bans
proc clear:bans {nick uhost hand text} {
if {[scan $text {%s} chan] != 1} {
puthelp "PRIVMSG $nick :Usage: clearbans #channel"
return
}
if {[string first # $chan] == -1 || ![validchan $chan]} {
puthelp "PRIVMSG $nick :Error: $chan is not a valid input."
return
}
if {![botonchan $chan]} {
puthelp "PRIVMSG $nick :Error: I'm not on $chan channel."
return
}
if {![botisop $chan]} {
puthelp "PRIVMSG $nick :Error: I'm not a channel operator on $chan channel."
return
}
global clearbans
foreach {ban bywho age} [join [chanbans $chan]] {
scan $ban {%[^!]!%[^@]@%s} n u h
# format is *!*@host
if {$n != "*" || $u != "*"} continue
lappend data [list $age $ban]
}
if {![info exists data]} return
set data [lsort -decreasing -integer -index 0 $data]
set no 0
foreach {age ban} [join $data] {
incr no
if {$no > $clearbans(max)} break
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"
}
}
Haven't tested this so let me know if you get any errors.
Edit: Fixed variables.
Last edited by
caesar on Wed May 23, 2018 1:11 am, edited 3 times in total.
Once the game is over, the king and the pawn go back in the same box.
m4s
Halfop
Posts: 97 Joined: Mon Jan 30, 2017 3:24 pm
Post
by m4s » Thu May 17, 2018 12:30 pm
Hi caesar!
Thank you for your help again.
I tested it but no action after clearbans #channel private command.
If I use clearbans I got: Usage: clearbans #channel
and clearbans channel (without #) I got: Error: help is not a valid input.
caesar
Mint Rubber
Posts: 3776 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Thu May 17, 2018 12:58 pm
The #channel is a valid channel, bot is on it and has channel operator? Are there any channel bans set in the format you said you want?
Once the game is over, the king and the pawn go back in the same box.
m4s
Halfop
Posts: 97 Joined: Mon Jan 30, 2017 3:24 pm
Post
by m4s » Thu May 17, 2018 1:01 pm
caesar wrote: The #channel is a valid channel, bot is on it and has channel operator? Are there any channel bans set in the format you said you want?
Yes of course!
I forgot to mention a haven't got any error msgs aftet clearbans #channel.
Just nothing happened.
willyw
Revered One
Posts: 1200 Joined: Thu Jan 15, 2009 12:55 am
Post
by willyw » Thu May 17, 2018 6:24 pm
caesar wrote:
...
Haven't tested this so let me know if you get any errors.
Me either ... I haven't loaded it.
But I found it interesting.
Have a look at this line:
I don't see what sets $max prior to that line.
Maybe you meant to use the array var there?
That possibility might account for the unmatched ) too.
I hope this saves you some time.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
caesar
Mint Rubber
Posts: 3776 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Fri May 18, 2018 12:43 am
willyw is right.
Initially had that piece of code inside another function, but then decided to drop it and forgot to replace the
$max variable with
$clearbans(max) to suit the names in this code.
Anyway, updated the code above and should be good now. Thanks willyw.
Once the game is over, the king and the pawn go back in the same box.
willyw
Revered One
Posts: 1200 Joined: Thu Jan 15, 2009 12:55 am
Post
by willyw » Fri May 18, 2018 1:49 pm
caesar wrote:
Initially had that piece of code inside another function, but then decided to drop it and forgot to ....."
Do I ever know THAT feeling .... heheehehe
Thanks willyw.
You're welcome.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
m4s
Halfop
Posts: 97 Joined: Mon Jan 30, 2017 3:24 pm
Post
by m4s » Tue May 22, 2018 11:44 am
Hello,
Sorry for the late answer, I was far from the "modern" world.
I tried the updated script but still no result. After "clearbans #channel" nothing happens.
Last edited by
m4s on Wed May 23, 2018 1:44 pm, edited 1 time in total.
simo
Revered One
Posts: 1090 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue May 22, 2018 6:16 pm
i tried it as well and nottin happens i made sure banlist is full and executed the script but it didnt do anything and no errors in PL
caesar
Mint Rubber
Posts: 3776 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Wed May 23, 2018 1:10 am
/facepalm
should be:
notice the missing $
First is with clearbans(max) set to 5, then set it to 2 to see what happens.
[08:02] * cez sets mode: +bbbbb *!*@host.com *!*@something.net *!bla@* john!*@* *!*@host.net
[08:02] * bot sets mode: -bbb *!*@host.net *!*@something.net *!*@host.com
[08:02] * cez sets mode: +bbb *!*@host.com *!*@something.net *!*@host.net
[08:02] * bot sets mode: -bb *!*@host.net *!*@host.com
Set it to 3 and removes 3 oldest bans as should:
[08:03] * cez sets mode: +bbb *!*@host.com *!*@something.net *!*@host.net
[08:05] * cez sets mode: +b *!*@host.org
[08:05] * bot sets mode: -bbb *!*@host.net *!*@something.net *!*@host.com
And it works as expected.
Once the game is over, the king and the pawn go back in the same box.
simo
Revered One
Posts: 1090 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Wed May 23, 2018 2:24 am
excellent it works well
thnx caesar.
m4s
Halfop
Posts: 97 Joined: Mon Jan 30, 2017 3:24 pm
Post
by m4s » Wed May 23, 2018 1:47 pm
The script works, thank you caesar!
And thanks for willyw as well!
May I upload it to the tclarchive.org?
caesar
Mint Rubber
Posts: 3776 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Thu May 24, 2018 12:43 am
Your welcome. Sure, no problem.
Once the game is over, the king and the pawn go back in the same box.