| View previous topic :: View next topic |
| Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Jul 20, 2020 2:19 am Post subject: devoice on ban |
|
|
hey there i was using this to have it check if a banned user is voiced to devoice
in the case of a normal ban like +b nick!ident@host it works fine
but on some servers it has extended bans like
muteban: +b ~q:nick!ident@host
or
muteban: +b m:nick!ident@host
is there a way to have it check for all these scenarios and devoice if banned nick has voice
using this at the moment:
| Code: |
bind mode - "* +b" devoice-ban
proc devoice-ban {nick uhost hand chan mc ban} {
if {[isbotnick $nick] || ![botisop $chan]} { return }
foreach n [chanlist $chan] {
if {[string match -nocase $ban $n![getchanhost $n $chan]]} {
if {![botisop $chan]} { return 0 }
if {[isop $n $chan]} { return 0 }
if {[ishalfop $n $chan]} { return 0 }
if {[matchattr [nick2hand $n] fnmo|fnmo $chan]} { return 0 }
if {[isbotnick $n]} { return 0}
if {[isvoice $n $chan] && ![isop $n $chan] && ![ishalfop $n $chan] && ![matchattr [nick2hand $n] fnmo|fnmo $chan]} { pushmode $chan -v $n }
}
}
flushmode $chan
}
|
heres an example of what happens:
this devoices as well:
09:20:44 +[simo] Sets Mode on #opers to: +b *!*@33.34.104.17
09:20:45 @TCL-Tester Sets Mode on #opers to: -v Peachey
this doesnt devoice while nick is voiced
09:21:18 +[simo] Sets Mode on #opers to: +b m:*!*@33.34.104.17
thnx in advance gents. |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Mon Jul 20, 2020 4:03 am Post subject: |
|
|
the $ban string contains "m:", so it will never match.
You'll have to adapt the $ban string if needed:
| Code: | if { [string first ":" $ban] != -1 } {
set ban [lindex [split $ban ":"] 1]
} |
_________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Jul 20, 2020 4:58 am Post subject: |
|
|
excellent that seems to do the trick flawlessly
thnx CrazyCat |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Jul 20, 2020 6:42 am Post subject: |
|
|
Use continue instead of return inside a loop.
And you should loop over the channel user list you should skip those that don't have voice in the first place and then do the matching and whatnot.
Apart this I see this:
| Code: |
if {[isbotnick $nick] || ![botisop $chan]} { return }
|
and then again in the loop:
| Code: |
if {![botisop $chan]} { return 0 }
|
Your loop should make more sense like:
- if the user is bot OR the user isn't voiced continue with the next user in the chanlist
- if the user is channel operator or halfop continue with the next user in the chanlist
- if the user has fnmo|fnmo continue with the next user in the chanlist
- if the host doesn't match user's host continue with the next user in the chanlist
- else devoice the user
| Code: |
proc devoice-ban {nick uhost hand chan mc ban} {
if {[isbotnick $nick] || ![botisop $chan]} return
foreach user [chanlist $chan] {
if {[isbotnick $user] || ![isvoice $user $chan]} continue
if {[isop $n $chan] || [ishalfop $user $chan]} continue
if {[matchattr [nick2hand $user] fnmo|fnmo $chan]}} continue
if {![string match -nocase $ban $user![getchanhost $user $chan]]} continue
pushmode $chan -v $user
}
flushmode $chan
}
|
Edit: fixed a typo and pushed the host check last. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Mon Jul 20, 2020 7:17 am; edited 3 times in total |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Mon Jul 20, 2020 6:54 am Post subject: |
|
|
| caesar wrote: | | Use continue instead of return inside a loop. |
Didn't see that, caesar is right.
If the user has clones, you will only devoice the first seen, not the others. _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Jul 20, 2020 8:08 am Post subject: |
|
|
i tried your proc caesar :
| Code: |
bind mode - "* +b" devoice-bans
proc devoice-ban {nick uhost hand chan mc ban} {
if {[isbotnick $nick] || ![botisop $chan]} return
foreach user [chanlist $chan] {
if {[isbotnick $user] || ![isvoice $user $chan]} continue
if {[isop $n $chan] || [ishalfop $user $chan]} continue
if {[matchattr [nick2hand $user] fnmo|fnmo $chan]}} continue
if {![string match -nocase $ban $user![getchanhost $user $chan]]} continue
pushmode $chan -v $user
}
flushmode $chan
}
|
and got this error:
Error loading script 'test.tcl': can't read "chan": no such variable |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Jul 20, 2020 8:24 am Post subject: |
|
|
took the error out this is what i got atm:
| Code: |
bind mode - "* +b" devoice-bans
proc devoice-ban {nick uhost hand chan mc ban} {
if {[isbotnick $nick] || ![botisop $chan]} return
foreach user [chanlist $chan] {
if {[isbotnick $user] || ![isvoice $user $chan]} continue
if {[isop $n $chan] || [ishalfop $user $chan]} continue
if {[matchattr [nick2hand $user] fnmo|fnmo $chan]} continue
if {![string match -nocase $ban $user![getchanhost $user $chan]]} continue
pushmode $chan -v $user
}
flushmode $chan
}
|
noting happens tho it doesnt devoice |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Jul 20, 2020 8:30 am Post subject: |
|
|
fixed the errors seems to be working proper now thnx CrazyCat and Caesar
much apreciated
this is what i have as end result:
| Code: |
bind mode - "* +b" devoice-ban
proc devoice-ban {nick uhost hand chan mc ban} {
if {[isbotnick $nick] || ![botisop $chan]} return
if { [string first ":" $ban] != -1 } {
set ban [lindex [split $ban ":"] 1]
}
foreach user [chanlist $chan] {
if {[isbotnick $user] || ![isvoice $user $chan]} continue
if {[isop $user $chan] || [ishalfop $user $chan]} continue
if {[matchattr [nick2hand $user] fnmo|fnmo $chan]} continue
if {![string match -nocase $ban $user![getchanhost $user $chan]]} continue
pushmode $chan -v $user
}
flushmode $chan
}
|
Last edited by simo on Mon Jul 20, 2020 8:36 am; edited 1 time in total |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Mon Jul 20, 2020 8:31 am Post subject: |
|
|
bind mode - "* +b" devoice-bans
proc devoice-ban {nick uhost hand chan mc ban} {
Use same name in bind and proc.
And when you have an error, use .set errorInfo to have more information. _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Jul 20, 2020 8:38 am Post subject: |
|
|
| tnx crazycat |
|
| Back to top |
|
 |
|