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.

Chanops Nick Abuse

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Im thinking of a different approach now by getting the chanops nicks with a timer and store them and use that list to compare to instead of doing so on every nick joining channel or changing nick
s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i came up with this :

Code: Select all


bind cron - {* * * * *} chanops:abuse:cron

setudef flag chanopsabuse


proc chanops:abuse:cron {min hour day month weekday} {
	global ChanOpsList
	foreach chan [channels] {
		if {![channel get $chan chanopsabuse]} continue
		foreach member [chanlist $chan] {
			if {[isop $member $chan] || [ishalfop $member $chan] || [matchattr [nick2hand $member] o|o $chan]} {
				lappend ChanOpsList($chan) $member

			}
		}
	}
}
not sure how to use the stored lappend list in the code i have to compare to tho
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Might want to unset the array before creating it if it exists, to avoid having duplicated details at least.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

would this be the proper way to do it ?

Code: Select all


bind cron - {* * * * *} chanops:abuse:cron

setudef flag chanopsabuse


proc chanops:abuse:cron {min hour day month weekday} {
   global ChanOpsList
   foreach chan [channels] {
      if {![channel get $chan chanopsabuse]} continue
      foreach member [chanlist $chan] {
         if {[isop $member $chan] || [ishalfop $member $chan] || [matchattr [nick2hand $member] o|o $chan]} {
         if {[info exists ChanOpsList($chan)]} { array unset ChanOpsList($chan) }
            lappend ChanOpsList($chan) $member
         }
      }
   }
} 

User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Move the unset outside of the loop cos as it is it will set on first member and unset on the next, thus in the end you will have only one member.

I'd go with:

Code: Select all

if {[info exists ChanOpsList]} { unset ChanOpsList }
directly placed above the 1st foreach loop. This way you reset everything and only create elements where is needed.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks Ceasar this is what i have so far if ive done it proper :

Code: Select all




bind nick - * Chanops-Nick-Abuse

proc Chanops-Nick-Abuse {nick uhost hand chan newnick} {
    Chanops-Join-Abuse $newnick $uhost $hand $chan
}




bind join - * Chanops-Join-Abuse



proc Chanops-Join-Abuse {nick uhost hand chan} {
	global ChanOpsList

	if {[isbotnick $nick]} return

	if {[info exists ChanOpsList($chan)]} {
		foreach choplist [lsort -unique -dictionary $ChanOpsList($chan)] {
			if {[onchan choplis $chan]} {
				set length [string length $choplist]
				set bdnickpart [wildcard $choplist]
				regsub -all {\*{1,}} $bdnickpart "*" bdnickpart
				if {[string match -nocase "$bdnickpart" $nick] && $length > 5} {
					pushmode $chan +b *$choplist?*!*@*
					pushmode $chan +b *?$choplist*!*@*
					regsub -all -- ~ $uhost "" uhost
					if {[string match -nocase "*@*irccloud*" [maskhost $nick!$uhost 2]]} {
						set ident  "[lindex [split $uhost @] 0]"
						set xbmaskx "[string map {sid id uid id} $ident]"
						set bmask  "*[string tolower $xbmaskx ]@*"
						pushmode $chan +b $bmask
					} else {
						set bmask "[maskhost $nick!$uhost 2]"
						pushmode $chan +b $bmask
					}
					putquick "kick $chan $nick � -- Please Dont Impersonate/Abuse Chanop Nicks Thank You.... -- �"
				}
			}
		}
	}
		flushmode $chan
}

 


 
proc wildcard {text} {
   set sep {*}
   set reg $sep
   for {set i 0} {$i<=[string length $text]} {incr i} {
      append reg [string index $text $i]$sep
   }
   return $reg
}


bind cron - {* * * * *} chanops:abuse:cron

setudef flag chanopsabuse


proc chanops:abuse:cron {min hour day month weekday} {
   global ChanOpsList
   foreach chan [channels] {
      if {![channel get $chan chanopsabuse]} continue
      foreach member [chanlist $chan] {
         if {[isop $member $chan] || [ishalfop $member $chan] || [matchattr [nick2hand $member] o|o $chan]} {
            lappend ChanOpsList($chan) $member
         }
      }
   if {[info exists ChanOpsList]} { unset ChanOpsList }
   }
}

Last edited by simo on Thu Apr 06, 2023 4:06 pm, edited 1 time in total.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Right now you create the associative array and when finally done with it you unset everything, thus the result doesn't even exist.

I said move the unset before the loop, meaning when you create it, so you start fresh.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks Caesar that seems to work as expected

Much apreciated as always

complete code if someone needs it:

Code: Select all


bind nick - * Chanops-Nick-Abuse

proc Chanops-Nick-Abuse {nick uhost hand chan newnick} {
   if {[isbotnick $newnick]} return
    Chanops-Join-Abuse $newnick $uhost $hand $chan
}





bind join - * Chanops-Join-Abuse

proc Chanops-Join-Abuse {nick uhost hand chan} {
   global ChanOpsList

   if {[isbotnick $nick]} return

   if {[info exists ChanOpsList($chan)]} {
      foreach choplist [lsort -unique -dictionary $ChanOpsList($chan)] {
         if {[onchan $choplist $chan]} {
            set length [string length $choplist]
            set bdnickpart [wildcard $choplist]
            regsub -all {\*{1,}} $bdnickpart "*" bdnickpart
            if {[string match -nocase "$bdnickpart" $nick] && $length > 5} {
               pushmode $chan +b *$choplist?*!*@*
               pushmode $chan +b *?$choplist*!*@*
               regsub -all -- ~ $uhost "" uhost
               if {[string match -nocase "*@*irccloud*" [maskhost $nick!$uhost 2]]} {
                  set ident  "[lindex [split $uhost @] 0]"
                  set xbmaskx "[string map {sid id uid id} $ident]"
                  set bmask  "*!*[string tolower $xbmaskx ]@*"
                  pushmode $chan +b $bmask
               } else {
                 set bmask "[maskhost $nick!$uhost 2]"
                 pushmode $chan +b $bmask
               }
               putquick "kick $chan $nick   :Please Dont Impersonate/Abuse Chanop Nicks,... Thank You"
            }
         }
      }
   }
      flushmode $chan
}

 


 
proc wildcard {text} {
   set sep {*}
   set reg $sep
   for {set i 0} {$i<=[string length $text]} {incr i} {
      append reg [string index $text $i]$sep
   }
   return $reg
}


# Syntax !chanops on / off

bind PUB -|- !chanops ChanOpsAbuse:control
 

proc ChanOpsAbuse:control {nick uhost hand chan arg} {
   if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }

  switch -nocase -- [lindex [split $arg] 0] {
    on {
      if {[channel get $chan chanopsabuse]} {
        putserv "NOTICE $nick :chanopsabuse checker is already enabled on $chan."
      } else { 
        channel set $chan +chanopsabuse
        putserv "NOTICE $nick :chanopsabuse checker is now enabled."
}
    }
    off {
      if {![channel get $chan chanopsabuse]} {
        putserv "NOTICE $nick :chanopsabuse checker is already disabled on $chan."
      } else {
        channel set $chan -chanopsabuse
        putserv "NOTICE $nick :chanopsabuse checker is now disabled."
     }
    }    
  }
}

setudef flag chanopsabuse


 bind cron - {* * * * *} chanops:abuse:cron

 proc chanops:abuse:cron {min hour day month weekday} {
   global ChanOpsList
   if {[info exists ChanOpsList]} { unset ChanOpsList }
   foreach chan [channels] {
       if {![channel get $chan chanopsabuse] || ![botisop $chan]} continue
      foreach member [chanlist $chan] {
         if {[isop $member $chan] || [ishalfop $member $chan] || [matchattr [nick2hand $member] o|o $chan]} {
            lappend ChanOpsList($chan) $member
         }
      }
   }
}

s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

ive been using this to check for chanop impersonators on join and instead of looping throu the chanlist nicks on each joining nick i used a timer to store the list like every 1 minute wich seems to work well except if a chanops for some reason connection drops down and chanop leaves channel only to return few seconds later its still in the stored list and will get booted from the channel i was wondering if there is a method to remove a chanop/chanhalfop the moment they leave channel

so far all i came up with is this and am kind of stuck how to remove the nick from the list :

Code: Select all

bind nick - * Chanops-Nick-Abuse

proc Chanops-Nick-Abuse {nick uhost hand chan newnick} {
   if {[isbotnick $newnick]} return
    Chanops-Join-Abuse $newnick $uhost $hand $chan
}





bind join - * Chanops-Join-Abuse

proc Chanops-Join-Abuse {nick uhost hand chan} {
   global ChanOpsList

   if {[isbotnick $nick]} return

   if {[info exists ChanOpsList($chan)]} {
      foreach choplist [lsort -unique -dictionary $ChanOpsList($chan)] {
         if {[onchan $choplist $chan]} {
            set length [string length $choplist]
            set bdnickpart [wildcard $choplist]
            regsub -all {\*{1,}} $bdnickpart "*" bdnickpart
            if {[string match -nocase "$bdnickpart" $nick] && $length > 5} {
               pushmode $chan +b *$choplist?*!*@*
               pushmode $chan +b *?$choplist*!*@*
               regsub -all -- ~ $uhost "" uhost
               if {[string match -nocase "*@*irccloud*" [maskhost $nick!$uhost 2]]} {
                  set ident  "[lindex [split $uhost @] 0]"
                  set xbmaskx "[string map {sid id uid id} $ident]"
                  set bmask  "*!*[string tolower $xbmaskx ]@*"
                  pushmode $chan +b $bmask
               } else {


  regsub -all -- {([a-zA-Z\?]*\?{1,}[a-zA-Z\?]*)(-|\.|$)} [maskhost $uhost 14] {*\2} target14
  regsub -all -- {\?+} [maskhost $uhost 14] {*} target27

 
   set domain "[join [lrange [split $uhost .] end-0 end] .]"

 set XllenX [llength [split [lindex [split $uhost "@"] 1] "-"]]
     set llen [llength [split [lindex [split $uhost "@"] 1] "."]]

     if {$llen == 2} {  set bmask "$target27"
       } elseif {[string match "ip" $domain]} {
        set bmask "*!*@*.[join [lrange [split $uhost .] end-2 end] .]"
    } elseif {[regexp {^\d+\.\d+\.\d+\.\d+$} $uhost]} {  set bmask "$target14"
         } elseif {$XllenX == 5 && $llen == 4} {  set bmask "*!*@*.[join [lrange [split $uhost .] end-2 end] .]"
  }  elseif {$XllenX == 5 && $llen == 3} {  set bmask  "*!*@*.[join [lrange [split $uhost .] 1 end] .]" 
  } else { set bmask $target14  }
              if {![ischanban $bmask $chan]} { pushmode $chan +b $bmask }
               }
               qkick  $chan $nick  "«--Please Dont Impersonate/Abuse Chanop Nicks Thank You--»"
            }
         }
      }
   }
}

 


 
proc wildcard {text} {
   set sep {*}
   set reg $sep
   for {set i 0} {$i<=[string length $text]} {incr i} {
      append reg [string index $text $i]$sep
   }
   return $reg
}




bind PUB -|- !chanops ChanOpsAbuse:control
 

proc ChanOpsAbuse:control {nick uhost hand chan arg} {
           if {![isop $nick $chan] && ![ishalfop $nick $chan] && ![matchattr $hand o|o $chan]} { return 0 }

  switch -nocase -- [lindex [split $arg] 0] {
    on {
      if {[channel get $chan chanopsabuse]} {
        putserv "NOTICE $nick :chanopsabuse checker is already enabled on $chan."
      } else {
        channel set $chan +chanopsabuse
        putserv "NOTICE $nick :chanopsabuse checker is now enabled."
}
    }
    off {
      if {![channel get $chan chanopsabuse]} {
        putserv "NOTICE $nick :chanopsabuse checker is already disabled on $chan."
      } else {
        channel set $chan -chanopsabuse
        putserv "NOTICE $nick :chanopsabuse checker is now disabled."
     }
    }   
  }
}

setudef flag chanopsabuse


 bind cron - {* * * * *} chanops:abuse:cron

 proc chanops:abuse:cron {min hour day month weekday} {
   global ChanOpsList
   if {[info exists ChanOpsList]} { unset ChanOpsList }
   foreach chan [channels] {
       if {![channel get $chan chanopsabuse] || ![botisop $chan]} continue
      foreach member [chanlist $chan] {
         if {[isop $member $chan] || [ishalfop $member $chan] || [matchattr [nick2hand $member] o|o $chan]} {
             if {![regexp -nocase {^darkness$} $member]} { lappend ChanOpsList($chan) $member }
         }
      }
   }
}

putlog "ChanOps-Abuse.tcl loaded"
s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i came this far and am stuck as to how to remove the nick from the list
that is if this is the best way to store the list and edit it

Code: Select all

bind sign - * ChanOpsList:Quit-checker
proc ChanOpsList:Quit-checker {nick uhost hand chan reason} {
   global ChanOpsList
   if {[info exists ChanOpsList($chan)]} { do stuff }

}


bind part - * ChanOpsList:Part-checker
proc ChanOpsList:Part-checker {nick uhost hand chan text} {
   global ChanOpsList
   if {[info exists ChanOpsList($chan)]} { do stuff }
}

Online
User avatar
CrazyCat
Revered One
Posts: 1252
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

You want to remove an element ($nick) from ChanOpsList($chan) ?
Use lreplace:

Code: Select all

set ChanOpsList($chan) [lreplace $ChanOpsList($chan) [lsearch $ChanOpsList($chan) $nick] [lsearch $ChanOpsList($chan) $nick]]
s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Thanks crazycat I'll try that
s
simo
Revered One
Posts: 1090
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

seems to work as expected thanks CrazyCat
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

set pos [lsearch -nocase $ChanOpsList($chan) $nick]
if {$pos > -1} {
	set ChanOpsList($chan) [lreplace $ChanOpsList($chan) $pos $pos]
}
Assign a position (if one exists in the first place) and reuse it, don't lsearch twice.
Once the game is over, the king and the pawn go back in the same box.
Online
User avatar
CrazyCat
Revered One
Posts: 1252
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Does it really affects the performances ?
BTW, I sometime assign the position and sometime double the lsearch, depend on my mood :)
Post Reply