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.

joinpart.tcl

Old posts that have not been replied to for several years.
Locked
User avatar
mrdr
Halfop
Posts: 42
Joined: Thu Jun 16, 2005 2:20 pm
Location: Lithuania / Vilnius / Underground
Contact:

joinpart.tcl

Post by mrdr »

I modified joinpart.tcl.
Deleted some functions that I don't need, and I don't know are there are no errors. I don't want to crash the bot because of uptime. :)

Code: Select all

set jp(part) 3
set jpban_type 7
set jp(reason) "Banned: join/part"

setudef flag joinpart
bind part - * ban:jp

proc ban:jp {nick uhost hand chan arg} {
  global jp botnick jpchan
  if {[isbotnick $nick] || ![botisop $chan] || ![channel get $chan joinpart]} {
    return
  }
  if {![info exists jpchan($chan)]} {
    set jpchan($chan) 0
  }
  if {($chan == $botnick) || [matchattr $hand b] || [matchattr $hand fom|fom $chan]} {
    return
  }
  if {[getchanjoin $nick $chan] >= [expr {[clock seconds]-$jp(part)}]} {
    set banmask [jp:banmask $uhost $nick]
    putquick "MODE $chan +b $banmask" 
    putserv "KICK $chan $nick :$jp(reason)"
  }
}
proc jp:banmask {uhost nick} {
 global jpban_type
  switch -- $jpban_type {
   1 { set banmask "*!*@[lindex [split $uhost @] 1]" }
   2 { set banmask "*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
   3 { set banmask "*!*$uhost" }
   4 { set banmask "*!*[lindex [split [maskhost $uhost] "!"] 1]" }
   5 { set banmask "*!*[lindex [split $uhost "@"] 0]*@[lindex [split $uhost "@"] 1]" }
   6 { set banmask "*$nick*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
   7 { set banmask "*$nick*!*@[lindex [split $uhost "@"] 1]" }
   8 { set banmask "$nick![lindex [split $uhost "@"] 0]@[lindex [split $uhost @] 1]" }
   9 { set banmask "$nick![lindex [split $uhost "@"] 0]@[lindex [split [maskhost $uhost] "@"] 1]" }
   default { set banmask "*!*@[lindex [split $uhost @] 1]" }
   return $banmask
  }
}
IRC: #egghelp @ Aitvaras.NET
IRC: #NASA @ Aitvaras.NET
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Your code will work, but there're some redundant checks that can be removed

Code: Select all

proc ban:jp {nick uhost hand chan arg} { 
 global jp botnick
 if {[isbotnick $nick] || ![botisop $chan] || ![channel get $chan joinpart] || [matchattr $hand b] || [matchattr $hand fom|fom $chan]} { return } 
 if {[getchanjoin $nick $chan] >= [clock seconds]-$jp(part)} { 
  set banmask [jp:banmask $uhost $nick] 
  putquick "MODE $chan +b $banmask" 
  if {[onchan $nick $chan]} {
   putserv "KICK $chan $nick :$jp(reason)" 
  }
 } 
}
User avatar
mrdr
Halfop
Posts: 42
Joined: Thu Jun 16, 2005 2:20 pm
Location: Lithuania / Vilnius / Underground
Contact:

Post by mrdr »

Thanks Sir_Fz :wink:
IRC: #egghelp @ Aitvaras.NET
IRC: #NASA @ Aitvaras.NET
Locked