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.

Store host of nicks that quit IRC for a short period

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: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Store host of nicks that quit IRC for a short period

Post by simo »

Greetingz gentz,

i noticed when abusers join and abuse and quit IRC instant after that and our chanops try to use !kb nick it obviously sets ban on nick nick!*@* rather than on their host *!*@host since chanserv cant get their host after they left IRC
i wonder if there is a way to store that in eggdrop for a short period of time like 2 min or so to use for chanops to still be able to set a ban on the abusers host
i wonder if anyone has such a code or similar already written

thanks in advance.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i would think it starts with something like this:

Code: Select all

bind sign - "*" store:hosts

proc store:hosts {nick host hand chan text} {
 # store $nick $host here for short period
}




bind pub -|- !kb  gethost:kickban
 
proc gethost:kickban {nick host hand chan text} {
# get the host that goes with the stored nick that quit IRC
  putserv "mode $chan +b $storedhost"
}
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this comes close:

http://forum.egghelp.org/viewtopic.php?t=20852&start=15

except instead of setting ban we like to jjust store the host for like 1 or 2 min to be used by chanops to set bans with !kb nick
and to have it search for the stored host that fits the nick and set ban on it
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Still very crude and untested....

Code: Select all

bind part - * store:hosts
bind sign - * store:hosts

proc store:hosts {nk uh hn ch msg} {
  set aname [string tolower $nk@$ch]
  set ::storehosts($aname) [list $uh [expr {[unixtime]+120}]]
}

bind time - * expire:hosts

proc expire:hosts {mn hr da mo yr} {
  global storehosts
  set ut [unixtime]

  foreach {aname avalue} [array get storehosts] {
    if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
  }
}

bind pub o|o !kb pub:kickban

proc pub:kickban {nk uh hn ch tx} {
  global storehosts
  set target [lindex [split [string tolower $tx]] 0]
  set aname [string tolower $target@$ch]

  if {[onchan $target $ch]} {

    #kick and/or ban the person using info from the channel#

  } elseif {[info exists storehosts($aname)]} {
    set host [lindex [split [lindex $storehosts($aname) 0] @] 1]

    putquick "MODE $ch +b *!*@$host"

  }

}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

excellent that seems to work well SpiKe^^
i tried to use it with mass nicks for example if u like to do the same for multiple nicks in one command

i tried using it this way bit that didnt seem to do well :

Code: Select all

proc pub:kickban {nick host hand chan text} {
  global storehosts
  set target [lindex [split [string tolower $text]] 0]
  set aname [string tolower $target@$chan]

  set users [list]
  set umasks [list]
  set reason [join [lrange [split $text "."] 1 end] "."]
  set text  [lindex [split $text "."] 0]

  if {$reason eq ""} { set reason "Please change your behaviour thank you." }

  foreach user [split [string trim $text]] {
    if {![onchan $user $chan] && ![info exists storehosts($aname)]} {
      putserv "NOTICE $nick $user :is not on channel $chan"
    } elseif  {![onchan $user $chan]  && [info exists storehosts($aname)]} {
      lappend umasks [lindex [split [lindex $storehosts($aname) 0] @] 1] 
    } else {
      set chost [getchanhost $user $chan]
      lappend umasks [maskhost "$user!$chost" 2] 
      if {![isatleasthalfop2017ewa $user $chan]} {  lappend users $user   }
    }
  }

  if {[info exists umasks]} { stackBans3z $chan $umasks }
  if {[info exists users]} { stackKicks $chan $users $reason }
}

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

Post by simo »

to combine multiple kick/ban to be able to use !kb nick nick nick nick nick

for this function as well
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this is how i use my current kickban proc wich seems to work well i was hoping to integrate it to have 1 proc for kickban

Code: Select all

proc pub:kbanx1kxZ777 {nick host hand chan text} {
  if {![isatleasthalfop2017ewa $nick $chan]} { return 0 }
	set users [list]
	set umasks [list]
                set reason [join [lrange [split $text "."] 1 end] "."]
                set text  [lindex [split $text "."] 0]
	if {$reason eq ""} { set reason "Please change your behaviour thank you." }
  foreach user [split [string trim $text]] {
      		if {![onchan $user $chan]} {
			putserv "NOTICE $nick $user is not on channel $chan"
		} else {

				set chost [getchanhost $user $chan]
				if {![isatleasthalfop2017ewa $user $chan]} { lappend umasks [maskhost "$user!$chost" 2]  ; lappend users $user   }
  }
} 
    if {[info exists umasks]} { stackBans3z $chan $umasks }
     if {[info exists users]} { stackKicks $chan $users $reason }
}
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Try this out, includes !kb !k !b...

Code: Select all

# max number of bans to stack in one mode command (1 or more) #
set pkb(maxban) 6

# max number of kicks to stack in one kick command (1 or more) #
set pkb(maxkick) 3

##############


bind pub -|- !k pub:kick
proc pub:kick {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx k  }

bind pub -|- !b pub:ban
proc pub:ban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx b  }

bind pub -|- !kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
  global pkb storehosts
  if {![isop $nk $ch] && ![ishalfop $nk $ch]} {  return 0  }

  set reason [join [lrange [split $tx "."] 1 end] "."]
  if {$reason eq ""} { set reason "Please change your behaviour thank you." }

  set nickls [split [string trim [string tolower [lindex [split $tx "."] 0]]]]
  set chan [string tolower $ch]

  foreach nick $nickls {
    set aname "$nick@$chan"

    if {[onchan $nick $ch]} {
      if {[string match *b* $do]} {
        set chost [getchanhost $nick $ch]
        lappend bmasks [maskhost "$nick!$chost" 2]
      }
      if {[string match *k* $do]} {
        lappend knicks $nick
      }
    } elseif {[info exists storehosts($aname)]} {
      if {[string match *b* $do]} {
        set chost [lindex [split [lindex $storehosts($aname) 0] @] 1]
        lappend bmasks [maskhost "$nick!$chost" 2]
      }
    } else {
      putserv "NOTICE $nk: $nick :is not on channel $ch"
    }
  }

  if {[info exists bmasks]} {
    while {[set len [llength $bmasks]] > 0} {
      if {$len > $pkb(maxban)} {
        set mode [string repeat "b" $pkb(maxban)]
        set masks [join [lrange $bmasks 0 [expr {$pkb(maxban) - 1}]]]
        set bmasks [lrange $bmasks $pkb(maxban) end]
      } else {
        set mode [string repeat "b" $len]
        set masks [join $bmasks]
        set bmasks ""
      }
      putquick "MODE $ch +$mode $masks"
    }
  }
  if {[info exists knicks]} {
    while {[set len [llength $knicks]] > 0} {
      if {$len > $pkb(maxkick)} {
        set nicks [join [lrange $knicks 0 [expr {$pkb(maxkick) - 1}]] ","]
        set knicks [lrange $knicks $pkb(maxkick) end]
      } else {
        set nicks [join $knicks ","]
        set knicks ""
      }
      putserv "KICK $ch $nicks :$reason"
    }
  }
}


####

bind part - * store:hosts
bind sign - * store:hosts

proc store:hosts {nk uh hn ch msg} {
  set aname [string tolower $nk@$ch]
  set ::storehosts($aname) [list $uh [expr {[unixtime]+120}]]
}

bind time - * expire:hosts

proc expire:hosts {mn hr da mo yr} {
  global storehosts
  set ut [unixtime]

  foreach {aname avalue} [array get storehosts] {
    if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
  }
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

ive tested your last posted code SpiKe^^
it all works except when testing the quited nicks it returns this:
*!*@allard!All4Masti-v89.77r.138.369.IP *!*@applegate!All4Masti-29b.e9z.478.285.IP *!*@asher!All4Masti-o68.c4a.967.882.IP *!*@duarte!All4Masti-140.wso.660.492.IP *!*@gant!All4Masti-6f6.c0z.650.472.IP *!*@hollingsworth!All4Masti-f8q.t2j.564.470.IP *!*@huskey!All4Masti-3x4.6zk.328.421.IP *!*@kohn!All4Masti-bx2.t0y.861.064.IP *!*@laughlin!All4Masti-4eg.8f1.962.486.IP *!*@leslie!All4Masti-v6p.8d0.174.673.IP
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

also when using !b it helps to also devoice user else the ban is not effiecient
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i noticed if the stored nicks expired and u try to call it again it sends error:
Tcl error [pub:kickban]: can't read "nick": no such variable
instead of the :
nick is not on channel
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

!kb !k !b script with drive-by helper

Post by SpiKe^^ »

Try this fixed version of the script, hope it clears your issues...

Code: Select all

# max number of bans to stack in one mode command (1 or more) #
set pkb(maxban) 6

# max number of kicks to stack in one kick command (1 or more) #
set pkb(maxkick) 3

##############


bind pub o|o !k pub:kick
proc pub:kick {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx k  }

bind pub o|o !b pub:ban
proc pub:ban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx b  }

bind pub o|o !kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
  global pkb storehosts
  if {![isop $nk $ch] && ![ishalfop $nk $ch]} {  return 0  }

  set reason [join [lrange [split $tx "."] 1 end] "."]
  if {$reason eq ""} { set reason "Please change your behaviour thank you." }

  set nickls [split [string trim [string tolower [lindex [split $tx "."] 0]]]]
  set chan [string tolower $ch]

  foreach nick $nickls {
    set aname "$nick@$chan"

    if {[onchan $nick $ch]} {
      if {[string match *b* $do]} {
        set chost [getchanhost $nick $ch]
        lappend bmasks [maskhost "$nick!$chost" 2]
      }
      if {[string match *k* $do]} {
        lappend knicks $nick
      }
    } elseif {[info exists storehosts($aname)]} {
      if {[string match *b* $do]} {
        set chost [lindex $storehosts($aname) 0]
        lappend bmasks [maskhost "$nick!$chost" 2]
      }
    } else {
      putserv "NOTICE $nk :$nick :is not on channel $ch"
    }
  }

  if {[info exists bmasks]} {
    while {[set len [llength $bmasks]] > 0} {
      if {$len > $pkb(maxban)} {
        set mode [string repeat "b" $pkb(maxban)]
        set masks [join [lrange $bmasks 0 [expr {$pkb(maxban) - 1}]]]
        set bmasks [lrange $bmasks $pkb(maxban) end]
      } else {
        set mode [string repeat "b" $len]
        set masks [join $bmasks]
        set bmasks ""
      }
      putquick "MODE $ch +$mode $masks"
    }
  }
  if {[info exists knicks]} {
    while {[set len [llength $knicks]] > 0} {
      if {$len > $pkb(maxkick)} {
        set nicks [join [lrange $knicks 0 [expr {$pkb(maxkick) - 1}]] ","]
        set knicks [lrange $knicks $pkb(maxkick) end]
      } else {
        set nicks [join $knicks ","]
        set knicks ""
      }
      putserv "KICK $ch $nicks :$reason"
    }
  }
}


####

bind part - * store:hosts
bind sign - * store:hosts

proc store:hosts {nk uh hn ch msg} {
  set aname [string tolower $nk@$ch]
  set ::storehosts($aname) [list $uh [expr {[unixtime]+120}]]
}

bind time - * expire:hosts

proc expire:hosts {mn hr da mo yr} {
  global storehosts
  set ut [unixtime]

  foreach {aname avalue} [array get storehosts] {
    if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
  }
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks SpiKe^^ works fine now nice job on the code once again much apreciated i believe this one will benefit many
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this is my version where i added !m to set mutebans ~q
and also if muteban is used or just ban it checks for voice and removes as well it also checks for chan(half)ops and for flag o to exempt


Code: Select all

# max number of bans to stack in one mode command (1 or more) #
set pkb(maxban) 6

# max number of kicks to stack in one kick command (1 or more) #
set pkb(maxkick) 4

##############


bind pub -|- !k pub:kick
proc pub:kick {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx k  }

bind pub -|- !b pub:ban
proc pub:ban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx b  }

bind pub -|- !m pub:muteban
proc pub:muteban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx m  }

bind pub -|- !kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
 global pkb storehosts
 
  if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr [nick2hand $nk] o|o $ch]} { return 0 }

  set reason [join [lrange [split $tx "."] 1 end] "."]
  if {$reason eq ""} { set reason "Please change your behaviour thank you." }

  set nickls [split [string trim [string tolower [lindex [split $tx "."] 0]]]]
  set chan [string tolower $ch]

  foreach nick $nickls {
    set aname "$nick@$chan"

    if {[onchan $nick $ch]} {
      if {[string match *b* $do]} {
        if {![isop $nick $ch] && ![ishalfop $nick $ch] &&  [isvoice $nick $ch] && ![matchattr [nick2hand $nick] o|o $ch]} {  lappend users $nick }
        set chost [getchanhost $nick $ch]
         if {![isop $nick $ch] && ![ishalfop $nick $ch] &&  ![matchattr [nick2hand $nick] o|o $ch]} { lappend bmasks [maskhost "$nick!$chost" 2] }
      }
      if {[string match *m* $do]} {
        if {![isop $nick $ch] && ![ishalfop $nick $ch] &&  [isvoice $nick $ch] && ![matchattr [nick2hand $nick] o|o $ch]} {  lappend users $nick }
         set chost [getchanhost $nick $ch]
         if {![isop $nick $ch] && ![ishalfop $nick $ch] &&  ![matchattr [nick2hand $nick] o|o $ch]} { lappend bmasks ~q:[maskhost "$nick!$chost" 2] }
      }
      if {[string match *k* $do]} {
        lappend knicks $nick
      }
    } elseif {[info exists storehosts($aname)]} {
      if {[string match *b* $do]} {
        set chost [lindex $storehosts($aname) 0]
       lappend bmasks [maskhost "$nick!$chost" 2]
      }
    } else {
      putserv "NOTICE $nk  $nick :is not on channel $ch"
    }
  }
     if {[info exists users]} {  stackdevoice $chan $users  }

  if {[info exists bmasks]} {
    while {[set len [llength $bmasks]] > 0} {
      if {$len > $pkb(maxban)} {
        set mode [string repeat "b" $pkb(maxban)]
        set masks [join [lrange $bmasks 0 [expr {$pkb(maxban) - 1}]]]
        set bmasks [lrange $bmasks $pkb(maxban) end]
      } else {
        set mode [string repeat "b" $len]
        set masks [join $bmasks]
        set bmasks ""
      }
      putquick "MODE $ch +$mode $masks"
    }
  }
  if {[info exists knicks]} {
    while {[set len [llength $knicks]] > 0} {
      if {$len > $pkb(maxkick)} {
        set nicks [join [lrange $knicks 0 [expr {$pkb(maxkick) - 1}]] ","]
        set knicks [lrange $knicks $pkb(maxkick) end]
      } else {
        set nicks [join $knicks ","]
        set knicks ""
      }
      putserv "KICK $ch $nicks :$reason"
    }
  }
}


proc stackdevoice {chan banlist {max 6}} {
      set count [llength $banlist]
      while {$count > 0} {
         if {$count> $max} {
            set mode [string repeat "v" $max]
            set masks [join [lrange $banlist 0 [expr {$max - 1}]]]
            set banlist [lrange $banlist $max end]
            incr count -$max
            incr total $max
         } else {
            set mode [string repeat "v" $count]
            set masks [join $banlist]
            incr total $count
            set count 0
         }
         putquick "MODE $chan -$mode $masks"
      }
   }




####

bind part - * store:hosts
bind sign - * store:hosts

proc store:hosts {nk uh hn ch msg} {
  set aname [string tolower $nk@$ch]
  set ::storehosts($aname) [list $uh [expr {[unixtime]+120}]]
}

bind time - * expire:hosts

proc expire:hosts {mn hr da mo yr} {
  global storehosts
  set ut [unixtime]

  foreach {aname avalue} [array get storehosts] {
    if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
  }
}

User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

!kb !k !b !m script with drive-by helper & protected use

Post by SpiKe^^ »

This should be a cleaned up version of the script with all current options and commands...

Code: Select all

# max number of bans/devoice to stack in one mode command (1 or more) #
set pkb(maxban) 6

# max number of kicks to stack in one kick command (1 or more) #
set pkb(maxkick) 3

##############


bind pub -|- !k pub:kick
proc pub:kick {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx k  }

bind pub -|- !b pub:ban
proc pub:ban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx b  }

bind pub -|- !m pub:muteban
proc pub:muteban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx m  }

bind pub -|- !kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
  global pkb storehosts
  if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
    return 0
  }

  set reason [join [lrange [split $tx "."] 1 end] "."]
  if {$reason eq ""} { set reason "Please change your behaviour thank you." }

  set nickls [split [string trim [string tolower [lindex [split $tx "."] 0]]]]
  set chan [string tolower $ch]

  foreach nick $nickls {
    set aname "$nick@$chan"

    if {[onchan $nick $ch]} {
      if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
      if {[matchattr [nick2hand $nick] o|o $ch]} { continue }

      if {[string match *b* $do]} {
        set chost [getchanhost $nick $ch]
        lappend bmasks [maskhost "$nick!$chost" 2]
        if {[isvoice $nick $ch] && ![string match *k* $do]} {
          lappend dvnicks $nick
        }
      }
      if {[string match *m* $do]} {
        set chost [getchanhost $nick $ch]
        lappend bmasks ~q:[maskhost "$nick!$chost" 2]
        if {[isvoice $nick $ch]} {  lappend dvnicks $nick  }
      }
      if {[string match *k* $do]} {
        lappend knicks $nick
      }

    } elseif {[info exists storehosts($aname)]} {
      if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }

      if {[string match *b* $do]} {
        set chost [lindex $storehosts($aname) 0]
        lappend bmasks [maskhost "$nick!$chost" 2]
      }
      if {[string match *m* $do]} {
        set chost [lindex $storehosts($aname) 0]
        lappend bmasks ~q:[maskhost "$nick!$chost" 2]
      }

    } else {
      putserv "NOTICE $nk :$nick :is not on channel $ch"
    }
  }

  if {[info exists dvnicks]} {
    while {[set len [llength $dvnicks]] > 0} {
      if {$len > $pkb(maxban)} {
        set mode [string repeat "v" $pkb(maxban)]
        set nicks [join [lrange $dvnicks 0 [expr {$pkb(maxban) - 1}]]]
        set dvnicks [lrange $dvnicks $pkb(maxban) end]
      } else {
        set mode [string repeat "v" $len]
        set nicks [join $dvnicks]
        set dvnicks ""
      }
      putquick "MODE $ch -$mode $nicks"
    }
  }
  if {[info exists bmasks]} {
    while {[set len [llength $bmasks]] > 0} {
      if {$len > $pkb(maxban)} {
        set mode [string repeat "b" $pkb(maxban)]
        set masks [join [lrange $bmasks 0 [expr {$pkb(maxban) - 1}]]]
        set bmasks [lrange $bmasks $pkb(maxban) end]
      } else {
        set mode [string repeat "b" $len]
        set masks [join $bmasks]
        set bmasks ""
      }
      putquick "MODE $ch +$mode $masks"
    }
  }
  if {[info exists knicks]} {
    while {[set len [llength $knicks]] > 0} {
      if {$len > $pkb(maxkick)} {
        set nicks [join [lrange $knicks 0 [expr {$pkb(maxkick) - 1}]] ","]
        set knicks [lrange $knicks $pkb(maxkick) end]
      } else {
        set nicks [join $knicks ","]
        set knicks ""
      }
      putserv "KICK $ch $nicks :$reason"
    }
  }
}


####

bind part - * store:hosts
bind sign - * store:hosts

proc store:hosts {nk uh hn ch msg} {
  set aname [string tolower $nk@$ch]
  set ::storehosts($aname) [list $uh [expr {[unixtime]+120}] $hn]
}

bind time - * expire:hosts

proc expire:hosts {mn hr da mo yr} {
  global storehosts
  set ut [unixtime]

  foreach {aname avalue} [array get storehosts] {
    if {$ut >= [lindex $avalue 1]} { unset storehosts($aname) }
  }
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Post Reply