egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

devoice on ban

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 20, 2020 2:19 am    Post subject: devoice on ban Reply with quote

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
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Jul 20, 2020 4:03 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 20, 2020 4:58 am    Post subject: Reply with quote

excellent that seems to do the trick flawlessly
thnx CrazyCat
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Jul 20, 2020 6:42 am    Post subject: Reply with quote

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
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Jul 20, 2020 6:54 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 20, 2020 8:08 am    Post subject: Reply with quote

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
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 20, 2020 8:24 am    Post subject: Reply with quote

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
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 20, 2020 8:30 am    Post subject: Reply with quote

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
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Jul 20, 2020 8:31 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 20, 2020 8:38 am    Post subject: Reply with quote

tnx crazycat
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber