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.

devoice on ban

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

devoice on ban

Post by simo »

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: Select all

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.
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

the $ban string contains "m:", so it will never match.
You'll have to adapt the $ban string if needed:

Code: Select all

if { [string first ":" $ban] != -1 } {
   set ban [lindex [split $ban ":"] 1]
}
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

excellent that seems to do the trick flawlessly
thnx CrazyCat
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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: Select all

if {[isbotnick $nick] || ![botisop $chan]} { return }
and then again in the loop:

Code: Select all

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: Select all

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.
Last edited by caesar on Mon Jul 20, 2020 7:17 am, edited 3 times in total.
Once the game is over, the king and the pawn go back in the same box.
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

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.
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried your proc caesar :

Code: Select all

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
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

took the error out this is what i got atm:

Code: Select all

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
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

fixed the errors seems to be working proper now thnx CrazyCat and Caesar
much apreciated

this is what i have as end result:

Code: Select all

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.
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

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.
s
simo
Revered One
Posts: 1079
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tnx crazycat
Post Reply