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

Post by simo »

tested it and it works flawlessly excellent work there spike^^ much apreciated once again
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

it would be even more complete if !ub !um is added to have it work on unban and unmute as well
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

New commands !ub and !um

Post by SpiKe^^ »

See if these new commands are what you had in mind.
Extended the time to save hosts to 5 minutes.

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 -|- !ub pub:unban
proc pub:unban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx ub  }

bind pub -|- !um pub:unmute
proc pub:unmute {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx um  }
####


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
  }

  if {[string match u* $do]} {
    set plus "-"
    set nickls [split [string trim $tx]]
  } else {
    set plus "+"
    set reason [join [lrange [split $tx "."] 1 end] "."]
    if {$reason eq ""} { set reason "Please change your behaviour thank you." }
    set nickls [split [string trim [lindex [split $tx "."] 0]]]
  }

  foreach nick $nickls {

    if {[string match u* $do] && [string match *!*@* $nick]} {
      set bmask $nick
      if {[string match um $do] && ![string match ~q:* $bmask]} {
        set bmask ~q:$bmask
      }
      if {[ischanban $bmask $ch]} {  lappend bmasks $bmask
      } else { putserv "NOTICE $nk :$bmask is not a current ban on $ch" }
      continue
    }

    set aname [string tolower "$nick@$ch"]

    if {[onchan $nick $ch]} {
      if {![string match u* $do]} {
        if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
        if {[matchattr [nick2hand $nick] o|o $ch]} { continue }
      }

      if {[string match {*[bm]} $do]} {
        set chost [getchanhost $nick $ch]
        set bmask [maskhost "$nick!$chost" 2]
        if {[string match *m $do]} {  set bmask ~q:$bmask  }

        if {[string match u* $do] && ![ischanban $bmask $ch]} {
          putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
          continue
        }
        lappend bmasks $bmask

        if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
          lappend dvnicks $nick
        }
      }

      if {[string match k* $do]} {  lappend knicks $nick  }

    } elseif {[info exists storehosts($aname)] && ($do ne "k")} {
      if {![string match u* $do]} {
        if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
      }

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

      if {[string match u* $do] && ![ischanban $bmask $ch]} {
        putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
        continue
      }
      lappend bmasks $bmask

    } 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 $plus$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]+300}] $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) }
  }
}

Last edited by SpiKe^^ on Fri Apr 16, 2021 4:53 pm, edited 2 times in total.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
D
DasBrain
Voice
Posts: 13
Joined: Thu Apr 08, 2021 12:31 pm

Post by DasBrain »

By the way, there is also /whowas nick. :D
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Dasbrain the problem with that is if different ppl use the same name u end up with many IPS wich makes it hard to determine wich one to use when using /whowas
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tested again and it works as expected excellent thanks SpiKe^^
G
Gulio
Halfop
Posts: 73
Joined: Sun Nov 01, 2020 11:53 am

Hello

Post by Gulio »

is possible to set ban time for ban 5 min (300)
!b nick

and for kb and mute 1 hour (3600) and to be unban
!kb nick
!m nick

and to be the both trigger with !m !b !kb and with .m .b .kb

and !b /.b nick 10 ( to be set ban for 10 min , when default is 5 same and for kb and mute )
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Gulio : Please test this out some.

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


# set default ban/mute times (in minutes) #
#   0 = this script doesn't remove bans/mutes #
set pkb(kb_bantime) 60
set pkb(b_bantime)  5
set pkb(m_mutetime) 60


# set mask type for bans and mutes #
# https://docs.eggheads.org/mainDocs/tcl-commands.html#maskhost-nick-user-host-masktype #
set pkb(ban_masktype)  1
set pkb(mute_masktype) 1

set pkb(mute_maskpre) "~q:"


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


bind pub -|- !k pub:kick
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
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
bind pub -|- .m pub:muteban
proc pub:muteban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx m  }

bind pub -|- !ub pub:unban
bind pub -|- .ub pub:unban
proc pub:unban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx ub  }

bind pub -|- !um pub:unmute
bind pub -|- .um pub:unmute
proc pub:unmute {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx um  }

bind pub -|- !kb pub:kickban
bind pub -|- .kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
  global pkb storehosts

  if {$uh ne "Timer"} {
    if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
      return 0
    }
  }

  if {[string match u* $do]} {
    set plus "-"
    set nickls [split [string trim $tx]]
  } else {
    set plus "+"
    set reason [join [lrange [split $tx "."] 1 end] "."]
    if {$reason eq ""} { set reason "Please change your behaviour thank you." }
    set nickls [split [string trim [lindex [split $tx "."] 0]]]
  }


  set seconds 0
  if {[string is digit [lindex $nickls end]]} {
    if {[string match {[bm]} $do] || ($do eq "kb")} {
      set seconds [expr {[lindex $nickls end] * 60}]
    }
    set nickls [lrange $nickls 0 end-1]
  } elseif {$do eq "m"} {  set seconds [expr {$pkb(m_mutetime) * 60}]
  } elseif {$do eq "b"} {  set seconds [expr {$pkb(b_bantime) * 60}]
  } elseif {$do eq "kb"} {  set seconds [expr {$pkb(kb_bantime) * 60}]  }

  set masktype $pkb(ban_masktype)
  if {[string match *m $do]} {  set masktype $pkb(mute_masktype)  }


  foreach nick $nickls {
    if {$nick eq ""} { continue }

    if {[string match u* $do] && [string match *!*@* $nick]} {
      set bmask $nick
      if {($do eq "um") && ![string match $pkb(mute_maskpre)* $bmask]} {
        set bmask $pkb(mute_maskpre)$bmask
      }
      if {[ischanban $bmask $ch]} {  lappend bmasks $bmask
      } elseif {$uh ne "Timer"} {
        putserv "NOTICE $nk :$bmask is not a current ban on $ch"
      }
      continue
    }

    set aname [string tolower "$nick@$ch"]

    if {[onchan $nick $ch]} {
      if {![string match u* $do]} {
        if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
        if {[matchattr [nick2hand $nick] o|o $ch]} { continue }
      }

      if {[string match {*[bm]} $do]} {
        set chost [getchanhost $nick $ch]
        set bmask [maskhost "$nick!$chost" $masktype]
        if {[string match *m $do]} {  set bmask $pkb(mute_maskpre)$bmask  }

        if {[string match u* $do] && ![ischanban $bmask $ch]} {
          putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
          continue
        }
        lappend bmasks $bmask

        if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
          lappend dvnicks $nick
        }
      }

      if {[string match k* $do]} {  lappend knicks $nick  }

    } elseif {[info exists storehosts($aname)] && ($do ne "k")} {
      if {![string match u* $do]} {
        if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
      }

      set chost [lindex $storehosts($aname) 0]
      set bmask [maskhost "$nick!$chost" $masktype]
      if {[string match *m $do]} {  set bmask $pkb(mute_maskpre)$bmask  }

      if {[string match u* $do] && ![ischanban $bmask $ch]} {
        putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
        continue
      }
      lappend bmasks $bmask

    } 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]} {

    if {$seconds > 0} {
      utimer $seconds [list pub:kickban $nk Timer $hn $ch [join $bmasks] ub]
    }

    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 $plus$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]+600}] $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
.
G
Gulio
Halfop
Posts: 73
Joined: Sun Nov 01, 2020 11:53 am

hello

Post by Gulio »

Spike^^ now is work good excellent great work thx

if u have time to set 1 more option

when is find hostmask *.irccloud.com || *.mibbit.com

to set ban on ident of cloud *!uid123457@* and for mibbit *!ba1r34d@*

this to be added on proc ban and mute


thx again in advance

Code: Select all


* Joins: John (uid479754@Test-DA54ABD8.irccloud.com)

[20:45:31] <@Nick> .b Cathe Mary John 1
[20:45:32] * BOT sets mode: +bbb *!*@48D59C09.BFD0590A.37B03A79.IP *!*@96C6E1DE.ABD124CC.73152542.IP *!*@Test-DA54ABD8.irccloud.com

to set ban this way for ircloud iden

+bbb *!*@48D59C09.BFD0590A.37B03A79.IP *!*@96C6E1DE.ABD124CC.73152542.IP *!uid479754@*


this code to be same for ban and mute proc

Code: Select all


if {[set chost [getchanhost $user $chan]] ne ""} {
				switch -glob -- $chost {
					{*.irccloud.com} - {*.mibbit.com} - {*.kiwiirc.com} - {*.8C39393E.IP} {
						set mask *![lindex [split $chost @] 0]@*
					}
					{default} {
						set mask [maskhost "$user!$chost" 2]
					}


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

Post by SpiKe^^ »

Try this version with the protected hosts deal...

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


# set default ban/mute times (in minutes) #
#   0 = this script doesn't remove bans/mutes #
set pkb(kb_bantime) 60
set pkb(b_bantime)  5
set pkb(m_mutetime) 60


# set mask type for bans and mutes #
# https://docs.eggheads.org/mainDocs/tcl-commands.html#maskhost-nick-user-host-masktype #
set pkb(ban_masktype)  2
set pkb(mute_masktype) 4

set pkb(mute_maskpre) "~q:"

# protected hosts #
# set only username bans on these domains (ex. *!uid123457@*) #
set pkb(phosts) "*.irccloud.com *.mibbit.com *.kiwiirc.com *.8C39393E.IP"


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


bind pub -|- !k pub:kick
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
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
bind pub -|- .m pub:muteban
proc pub:muteban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx m  }

bind pub -|- !ub pub:unban
bind pub -|- .ub pub:unban
proc pub:unban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx ub  }

bind pub -|- !um pub:unmute
bind pub -|- .um pub:unmute
proc pub:unmute {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx um  }

bind pub -|- !kb pub:kickban
bind pub -|- .kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
  global pkb storehosts

  if {$uh ne "Timer"} {
    if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
      return 0
    }
  }

  if {[string match u* $do]} {
    set plus "-"
    set nickls [split [string trim $tx]]
  } else {
    set plus "+"
    set reason [join [lrange [split $tx "."] 1 end] "."]
    if {$reason eq ""} { set reason "Please change your behaviour thank you." }
    set nickls [split [string trim [lindex [split $tx "."] 0]]]
  }


  set seconds 0
  if {[string is digit [lindex $nickls end]]} {
    if {[string match {[bm]} $do] || ($do eq "kb")} {
      set seconds [expr {[lindex $nickls end] * 60}]
    }
    set nickls [lrange $nickls 0 end-1]
  } elseif {$do eq "m"} {  set seconds [expr {$pkb(m_mutetime) * 60}]
  } elseif {$do eq "b"} {  set seconds [expr {$pkb(b_bantime) * 60}]
  } elseif {$do eq "kb"} { set seconds [expr {$pkb(kb_bantime) * 60}]  }

  set masktype $pkb(ban_masktype)
  if {[string match *m $do]} {  set masktype $pkb(mute_masktype)  }


  foreach nick $nickls {
    if {$nick eq ""} { continue }

    if {[string match u* $do] && [string match *!*@* $nick]} {
      set bmask $nick
      if {($do eq "um") && ![string match $pkb(mute_maskpre)* $bmask]} {
        set bmask $pkb(mute_maskpre)$bmask
      }
      if {[ischanban $bmask $ch]} {  lappend bmasks $bmask
      } elseif {$uh ne "Timer"} {
        putserv "NOTICE $nk :$bmask is not a current ban on $ch"
      }
      continue
    }

    set aname [string tolower "$nick@$ch"]

    if {[onchan $nick $ch]} {
      set hand [nick2hand $nick]
      if {![string match u* $do]} {
        if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
        if {[matchattr $hand o|o $ch]} { continue }
      }
      set chost [getchanhost $nick $ch]

      if {[string match {*[bm]} $do]} {

        set bmask [mask:host $nick $chost $masktype $do]

        if {[string match u* $do] && ![ischanban $bmask $ch]} {
          putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
          continue
        }
        lappend bmasks $bmask

        if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
          lappend dvnicks $nick
        }
      }

      if {[string match k* $do]} {  lappend knicks $nick
        store:hosts $nick $chost $hand $ch pkb.tcl
      }

    } elseif {[info exists storehosts($aname)] && ($do ne "k")} {
      if {![string match u* $do]} {
        if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
      }

      set chost [lindex $storehosts($aname) 0]

      set bmask [mask:host $nick $chost $masktype $do]

      if {[string match u* $do] && ![ischanban $bmask $ch]} {
        putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
        continue
      }
      lappend bmasks $bmask

    } 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]} {

    if {$seconds > 0} {
      utimer $seconds [list pub:kickban $nk Timer $hn $ch [join $bmasks] ub]
    }

    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 $plus$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"
    }
  }
}


#### protected hosts code

set pkb(phosts) [split [string trim $pkb(phosts)]]

proc mask:host {nick chost masktype do} {
  set bmask [maskhost "$nick!$chost" $masktype]
  foreach phost $::pkb(phosts) {
    if {[string match -nocase $phost $chost]} {
      set bmask "*![lindex [split $chost @] 0]@*"
      break
    }
  }
  if {[string match *m $do]} { set bmask $::pkb(mute_maskpre)$bmask }
  return $bmask
}

#### stored nicks & uhosts code

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]+900}] $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) }
  }
}

Last edited by SpiKe^^ on Sun Apr 25, 2021 7:38 pm, edited 1 time in total.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
G
Gulio
Halfop
Posts: 73
Joined: Sun Nov 01, 2020 11:53 am

Hello

Post by Gulio »

Spike^^ congratulation excellent work

i tested all option ban mute kick kb and is work great as i wanted it

thx a lot
G
Gulio
Halfop
Posts: 73
Joined: Sun Nov 01, 2020 11:53 am

Hello

Post by Gulio »

is possible to add and 1 options here in this script save host

set chtarget "#Test"

set chadmin "#Opers"

from channel #opers to use those triger command for main chan #Test same command how is for main channel so the staf can kick and ban and from #opers and this command to be used only from staf who stay in chan #opers



will be very usefull and helpfull , thx in advance

Code: Select all


set pkb(chtarget) "#Test2"

set pkb(chadmin) "#Test3"

# 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


# set default ban/mute times (in minutes) #
#   0 = this script doesn't remove bans/mutes #
set pkb(kb_bantime) 60
set pkb(b_bantime)  5
set pkb(m_mutetime) 60


# set mask type for bans and mutes #
# https://docs.eggheads.org/mainDocs/tcl-commands.html#maskhost-nick-user-host-masktype #
set pkb(ban_masktype)  2
set pkb(mute_masktype) 4

set pkb(mute_maskpre) "~q:"

# protected hosts #
# set only username bans on these domains (ex. *!uid123457@*) #
set pkb(phosts) "*.irccloud.com *.mibbit.com *.kiwiirc.com *.8C39393E.IP"


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


bind pub -|- !k pub:kick
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
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
bind pub -|- .m pub:muteban
proc pub:muteban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx m  }

bind pub -|- !ub pub:unban
bind pub -|- .ub pub:unban
proc pub:unban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx ub  }

bind pub -|- !um pub:unmute
bind pub -|- .um pub:unmute
proc pub:unmute {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx um  }

bind pub -|- !kb pub:kickban
bind pub -|- .kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
	global pkb storehosts
	set ch [string tolower $ch]
	if {$ch eq $pkb(chtarget) || $ch eq $pkb(chadmin) } {
		if {![onchan $nk $pkb(chadmin)]} { return }
	}
	foreach user $tx {

		if {![onchan $user $pkb(chtarget)]} {
			putserv "NOTICE $nk $user is not on channel $pkb(chtarget)"
		} elseif {[isop $user $pkb(chtarget)]} {
			putserv "notice $nk :$user is op in $pkb(chtarget) "
		} else {
			if {[onchan $user $pkb(chadmin)]} {
				putserv "NOTICE $nk $user is on channel $pkb(chadmin) dont ban him/her"
			}
		}
	}
	if {$uh ne "Timer"} {
		if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
			return 0
		}
	}

	if {[string match u* $do]} {
		set plus "-"
		set nickls [split [string trim $tx]]
	} else {
		set plus "+"
		set reason [join [lrange [split $tx "."] 1 end] "."]
		if {$reason eq ""} { set reason "Please change your behaviour thank you." }
		set nickls [split [string trim [lindex [split $tx "."] 0]]]
	}


	set seconds 0
	if {[string is digit [lindex $nickls end]]} {
		if {[string match {[bm]} $do] || ($do eq "kb")} {
			set seconds [expr {[lindex $nickls end] * 60}]
		}
		set nickls [lrange $nickls 0 end-1]
	} elseif {$do eq "m"} {  set seconds [expr {$pkb(m_mutetime) * 60}]
	} elseif {$do eq "b"} {  set seconds [expr {$pkb(b_bantime) * 60}]
	} elseif {$do eq "kb"} { set seconds [expr {$pkb(kb_bantime) * 60}]  }

	set masktype $pkb(ban_masktype)
	if {[string match *m $do]} {  set masktype $pkb(mute_masktype)  }


	foreach nick $nickls {
		if {$nick eq ""} { continue }

		if {[string match u* $do] && [string match *!*@* $nick]} {
			set bmask $nick
			if {($do eq "um") && ![string match $pkb(mute_maskpre)* $bmask]} {
				set bmask $pkb(mute_maskpre)$bmask
			}
			if {[ischanban $bmask $ch]} {  lappend bmasks $bmask
			} elseif {$uh ne "Timer"} {
				putserv "NOTICE $nk :$bmask is not a current ban on $ch"
			}
			continue
		}

		set aname [string tolower "$nick@$ch"]

		if {[onchan $nick $ch]} {
			set hand [nick2hand $nick]
			if {![string match u* $do]} {
				if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
				if {[matchattr $hand o|o $ch]} { continue }
			}
			set chost [getchanhost $nick $ch]

			if {[string match {*[bm]} $do]} {

				set bmask [mask:host $nick $chost $masktype $do]

				if {[string match u* $do] && ![ischanban $bmask $ch]} {
					putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
					continue
				}
				lappend bmasks $bmask

				if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
					lappend dvnicks $nick
				}
			}

			if {[string match k* $do]} {  lappend knicks $nick
				store:hosts $nick $chost $hand $ch pkb.tcl
			}

		} elseif {[info exists storehosts($aname)] && ($do ne "k")} {
			if {![string match u* $do]} {
				if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
			}

			set chost [lindex $storehosts($aname) 0]

			set bmask [mask:host $nick $chost $masktype $do]

			if {[string match u* $do] && ![ischanban $bmask $ch]} {
				putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
				continue
			}
			lappend bmasks $bmask

		} 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]} {

		if {$seconds > 0} {
			utimer $seconds [list pub:kickban $nk Timer $hn $ch [join $bmasks] ub]
		}

		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 $plus$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"
		}
	}
}


#### protected hosts code

set pkb(phosts) [split [string trim $pkb(phosts)]]

proc mask:host {nick chost masktype do} {
	set bmask [maskhost "$nick!$chost" $masktype]
	foreach phost $::pkb(phosts) {
		if {[string match -nocase $phost $chost]} {
			set bmask "*![lindex [split $chost @] 0]@*"
			break
		}
	}
	if {[string match *m $do]} { set bmask $::pkb(mute_maskpre)$bmask }
	return $bmask
}

#### stored nicks & uhosts code

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]+900}] $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) }
	}
}

G
Gulio
Halfop
Posts: 73
Joined: Sun Nov 01, 2020 11:53 am

hi

Post by Gulio »

I have another request for store info on kicks from other scripts or cs
like bind store kicks if is possible to be add , thx in advance
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Gulio : This version should now save nick/host/handle info from every kick, from this script and all other sources...

Code: Select all

# pkb.tcl version 1.3 by SpiKe^^ (5July2021)

# 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


# set default ban/mute times (in minutes) #
#   0 = this script doesn't remove bans/mutes #
set pkb(kb_bantime) 60
set pkb(b_bantime)  5
set pkb(m_mutetime) 60


# set mask type for bans and mutes #
# https://docs.eggheads.org/mainDocs/tcl-commands.html#maskhost-nick-user-host-masktype #
set pkb(ban_masktype)  2
set pkb(mute_masktype) 4

set pkb(mute_maskpre) "~q:"

# protected hosts #
# set only username bans on these domains (ex. *!uid123457@*) #
set pkb(phosts) "*.irccloud.com *.mibbit.com *.kiwiirc.com *.8C39393E.IP"


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


bind pub -|- !k pub:kick
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
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
bind pub -|- .m pub:muteban
proc pub:muteban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx m  }

bind pub -|- !ub pub:unban
bind pub -|- .ub pub:unban
proc pub:unban {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx ub  }

bind pub -|- !um pub:unmute
bind pub -|- .um pub:unmute
proc pub:unmute {nk uh hn ch tx} {  pub:kickban $nk $uh $hn $ch $tx um  }

bind pub -|- !kb pub:kickban
bind pub -|- .kb pub:kickban
proc pub:kickban {nk uh hn ch tx {do kb} } {
  global pkb storehosts

  if {$uh ne "Timer"} {
    if {![isop $nk $ch] && ![ishalfop $nk $ch] && ![matchattr $hn o|o $ch]} {
      return 0
    }
  }

  if {[string match u* $do]} {
    set plus "-"
    set nickls [split [string trim $tx]]
  } else {
    set plus "+"
    set reason [join [lrange [split $tx "."] 1 end] "."]
    if {$reason eq ""} { set reason "Please change your behaviour thank you." }
    set nickls [split [string trim [lindex [split $tx "."] 0]]]
  }


  set seconds 0
  if {[string is digit [lindex $nickls end]]} {
    if {[string match {[bm]} $do] || ($do eq "kb")} {
      set seconds [expr {[lindex $nickls end] * 60}]
    }
    set nickls [lrange $nickls 0 end-1]
  } elseif {$do eq "m"} {  set seconds [expr {$pkb(m_mutetime) * 60}]
  } elseif {$do eq "b"} {  set seconds [expr {$pkb(b_bantime) * 60}]
  } elseif {$do eq "kb"} { set seconds [expr {$pkb(kb_bantime) * 60}]  }

  set masktype $pkb(ban_masktype)
  if {[string match *m $do]} {  set masktype $pkb(mute_masktype)  }


  foreach nick $nickls {
    if {$nick eq ""} { continue }

    if {[string match u* $do] && [string match *!*@* $nick]} {
      set bmask $nick
      if {($do eq "um") && ![string match $pkb(mute_maskpre)* $bmask]} {
        set bmask $pkb(mute_maskpre)$bmask
      }
      if {[ischanban $bmask $ch]} {  lappend bmasks $bmask
      } elseif {$uh ne "Timer"} {
        putserv "NOTICE $nk :$bmask is not a current ban on $ch"
      }
      continue
    }

    set aname [string tolower "$nick@$ch"]

    if {[onchan $nick $ch]} {
      set hand [nick2hand $nick]
      if {![string match u* $do]} {
        if {[isop $nick $ch] || [ishalfop $nick $ch]} { continue }
        if {[matchattr $hand o|o $ch]} { continue }
      }
      set chost [getchanhost $nick $ch]

      if {[string match {*[bm]} $do]} {

        set bmask [mask:host $nick $chost $masktype $do]

        if {[string match u* $do] && ![ischanban $bmask $ch]} {
          putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
          continue
        }
        lappend bmasks $bmask

        if {($do ne "kb") && ![string match u* $do] && [isvoice $nick $ch]} {
          lappend dvnicks $nick
        }
      }

      if {[string match k* $do]} {  lappend knicks $nick  }

    } elseif {[info exists storehosts($aname)] && ($do ne "k")} {
      if {![string match u* $do]} {
        if {[matchattr [lindex $storehosts($aname) 2] o|o $ch]} { continue }
      }

      set chost [lindex $storehosts($aname) 0]

      set bmask [mask:host $nick $chost $masktype $do]

      if {[string match u* $do] && ![ischanban $bmask $ch]} {
        putserv "NOTICE $nk :$bmask \[$nick\] is not a current ban on $ch"
        continue
      }
      lappend bmasks $bmask

    } 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]} {

    if {$seconds > 0} {
      utimer $seconds [list pub:kickban $nk Timer $hn $ch [join $bmasks] ub]
    }

    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 $plus$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"
    }
  }
}


#### protected hosts code

set pkb(phosts) [split [string trim $pkb(phosts)]]

proc mask:host {nick chost masktype do} {
  set bmask [maskhost "$nick!$chost" $masktype]
  foreach phost $::pkb(phosts) {
    if {[string match -nocase $phost $chost]} {
      set bmask "*![lindex [split $chost @] 0]@*"
      break
    }
  }
  if {[string match *m $do]} { set bmask $::pkb(mute_maskpre)$bmask }
  return $bmask
}

#### stored nicks & uhosts code

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]+900}] $hn]
}

bind kick - * store:kick

proc store:kick {nk uh hn ch target reason} {
  set uhost [getchanhost $target $ch]
  set hand [finduser $target!$uhost]
  store:hosts $target $uhost $hand $ch pkb.tcl
}

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
.
G
Gulio
Halfop
Posts: 73
Joined: Sun Nov 01, 2020 11:53 am

Hello

Post by Gulio »

Spike^^ now i tested the Kick and KB from CS and from my script Mirc and is work saves the kick , this is great , thx a lot again .
Post Reply