opers.tcl

opers.tcl

TCL Snippet that uses custom commands to give accesses to users or chan admins.

Postat de Copyright Categorie Review user Vizualizari Data
btc techie chanops Cod netestat 544 2023-12-25 10:30:48

# opers tcl version1.0
# techie
# http://www.linuxirc.com

bind pub o !h pub:h
bind pub o !c pub:c
bind pub o !op pub:op
bind pub o !vo pub:vo
bind pub o !devo pub:devo
bind pub o !k pub:kick
bind pub o !b pub:ban
bind pub o !ub pub:ub
bind pub o !kb pub:kb
bind pub o !hop pub:hop
bind pub o !dehop pub:dehop
bind pub o !t pub:topic
bind pub - !p pub:p
bind pub n !jump pub:jump
bind pub n !die pub:die
bind pub o !status pub:status
bind pub o !broadcast pub:broadcast
bind pub o !deop pub:deop
bind pub o !info pub:info

proc pub:h {nick uhost hand chan text} {
  puthelp "NOTICE $nick :!c !op !deop !hop !dehop !vo !devo !k !b !ub !kb !t !p !info !jump !die !status 
!broadcast"
}

proc pub:c {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[isop $nick $chan] == 1} { pushmode $chan -o $nick } else { pushmode $chan +o $nick }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:op {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[onchan $tnick $chan]} { pushmode $chan +o $tnick }
      } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !op <nick> -  ops a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}
proc pub:deop {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[onchan $tnick $chan]} { pushmode $chan -o $tnick }
      } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !deop <nick> - deop a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}


proc pub:vo {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[onchan $tnick $chan]} { pushmode $chan +v $tnick }
      } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !vo <nick> - voices a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:devo {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[onchan $tnick $chan]} { pushmode $chan -v $tnick }
      } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !devo <nick> - devoices a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:hop {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[onchan $tnick $chan]} { pushmode $chan +h $tnick }
      } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !hop <nick> - hop a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:dehop {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[onchan $tnick $chan]} { pushmode $chan -h $tnick }
      } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !dehop <nick> - dehop a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}



proc pub:kick {nick uhost hand chan text} {
  if {[botisop $chan]} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[string length [lindex $text 1]] == 0} { set reason kicked } else { set reason [lrange $text 1 end] }
      if {[onchan $tnick $chan]} { putkick $chan $tnick $reason } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !k <nick> reason - kicks a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:ban {nick uhost hand chan text} {
  if {[botisop $chan]} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[string length [lindex $text 1]] == 0} { set reason banned } else { set reason [lrange $text 1 end] }
        newchanban $chan *!*@[lindex [split [getchanhost $tnick $chan] @] 1] $nick $reason 10
      } else { puthelp "notice $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !b <nick> reason - bans a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:ub {nick uhost hand chan text} {
  if {[botisop $chan]} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[ischanban $tnick $chan]} { killchanban $chan $tnick } else { puthelp "NOTICE $nick :no such ban on $chan" }
    } else { puthelp "NOTICE $nick :usage !ub <nick!user@host> - unbans an address" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:kb {nick uhost hand chan text} {
  if {[botisop $chan]} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[string length [lindex $text 1]] == 0} { set reason banned } else { set reason [lrange $text 1 end] }
        newchanban $chan *!*@[lindex [split [getchanhost $tnick $chan] @] 1] $nick $reason 10
        utimer 5 [putkick $chan $tnick $reason]
      } else { puthelp "notice $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !kb <nick> reason - kicks and bans a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:topic {nick uhost hand chan text} {
  if {[botisop $chan]} { putserv "TOPIC $chan :$text" } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:p {nick uhost hand chan text} { putserv "PRIVMSG $chan :connected!" }

proc pub:jump {nick uhost hand chan text} { jump $text }

proc pub:die {nick uhost hand chan text} { die $text }

proc pub:info {nick uhost hand chan test} { putserv "PRIVMSG $chan :opers.tcl version 1.0" }


proc pub:status {nick uhost hand chan text} {
  global server botname version
  puthelp "PRIVMSG $chan :user records: [countusers], channels: [channels], date: [date], time: [time], os: [unames], server: $server, host: $botname,egg version: [lindex $version 0]"
}

proc pub:broadcast {nick uhost hand chan text} {
  if {[string length $text] > 0} {
    set text [string trim $text "{}"]
    foreach n [channels] { puthelp "PRIVMSG $n :$text" }
  } else { puthelp "NOTICE $nick :!broadcast <message> - sends message to all channels that the bot is" }
}

putlog "tcl: opers tcl loaded"