###############################################################################
# hybrid-6 script (c) 2000 Edward Brocklesby
# includes modified code rfrom da5id's newons.irc
#
# usage: (stuff in [] is optional)
#   /kline [time] <nick or user@host> [reason]   (add a tkline, defaults to 60)
#   /pkline <nick or user@host> [reason]         (add a kline)
#   /dline <IP or CIDR mask> [reason]            (add a dline)
#   /gline <user@host> [reason]                  (request a gline)
# (reason in the above commands defaults to 'No reason')
#
#   /unkline <user@host>               (remove a kline or tkline)
#   /operwall                          (send an Operwall)
#   /locops                            (send a locops)
#   /opermsg <server> <message>        (send 'message' to all opers on 'server'
#                      Note: only works if target server is running hybrid-6)
#
# mail bugs/fixes/feature requests to ejb@leguin.org.uk
###############################################################################

alias operwall quote operwall :$*
alias locops quote locops :$*
alias opermsg msg opers@$0 $1-

alias dline {
                {if ([$1-])
                        {quote dline $0 :[$N] $1-}
                        {quote dline $0 :[$N] No reason}}}

alias pkline {
                {if ([$1-])
                        {quote kline $0 :[$N] $1-}
                        {quote kline $0 :[$N] No reason}}}

alias kline {
        if (isnumber($0))
                {if ([$2-])
                        {quote kline $0 $1 :[$N] $2-}
                        {quote kline $0 $1 :[$N] No reason}}
                {if ([$1-])
                        {quote kline 60 $0 :[$N] $1-}
                        {quote kline 60 $0 :[$N] No reason}}}
alias unkline {
        quote unkline $*}

alias gline {
        if ([$1-])
                {quote gline $0 :$1-}
                {quote gline $0 :No reason}
}

on ^211 * {
        echo $cparse(%K[%w servstats%K]%n $[-40]1%K%K: %wS%K:%W$[4]{[$4]/1024} %
wR%K:%n$[4]{[$6]/1024} %wQ%K:%n$2 %wT%K:%n$[12]tdiff2($7) %wI%K:%n$[3]8 %K[%w$9-
%K])}

on ^249 * {
        echo $cparse(%K[%w servstats%K]%n $1-)}

on ^kill "% % % *" echo $cparse(%K[%w  operkill%K]%n $2 killed $1 reason: $4-)
on ^kill "% % %.% *" echo $cparse(%K[%w  servkill%K]%n $2 killed $1)

on ^351 "*" echo $fmt.num.ver($*)
on ^oper_notice "* unauthori%ed client connection *" echo $fmt.snot.ucon($*)
on ^oper_notice "* client connecting% *" echo $fmt.snot.con($*)
on ^oper_notice "* client exit% *" echo $fmt.snot.disco($*)
on ^oper_notice "* stats *" echo $fmt.snot.stats($*)
on ^oper_notice "* links *" echo $fmt.snot.links($*)
on ^oper_notice "* % added k-line *" echo $fmt.snot.kline($*)
on ^oper_notice "* % added d-line *" echo $fmt.snot.dline($*)
on ^oper_notice "* %-line active *" echo $fmt.snot.active($*)
on ^server_notice "% % added %line *" echo $fmt.snot.addline($*)
on ^server_notice "* %line for * removed" echo $fmt.snot.remline($*)
on ^oper_notice "* % has removed the K-Line*" echo $fmt.snot.unkline($*)
on ^oper_notice "* % has removed the temporary K-Line*" echo $fmt.snot.untkline(
$*)
on ^oper_notice "* * is doing a %whois *" echo $fmt.snot.whois($*)
on ^oper_notice "* Nick change: From*" echo $fmt.snot.nick($*)
on ^oper_notice "* * count off by %" echo $fmt.snot.count($*)
on ^oper_notice "* % added temp% *" echo $fmt.snot.tempk($*)
on ^oper_notice "* % is clearing temp *" echo $fmt.snot.rehash($*)
on ^oper_notice "* % is forcing %reading *" echo $fmt.snot.rehash($*)
on ^oper_notice "* % is rehashing server *" echo $fmt.snot.rehash($*)
on ^oper_notice "* got signal sighup% *" echo $fmt.snot.rehash($*)
on ^oper_notice "* % high-traffic *" echo $fmt.snot.htm($*)
on ^oper_notice "* resuming standard *" echo $fmt.snot.htm($*)
on ^oper_notice "* user % % tried to *" echo $fmt.snot.mflood($*)
on ^oper_notice "* MOTD requested *" echo $fmt.snot.motd($*)
on ^oper_notice "* Flooder * on * target: *" echo $fmt.snot.flood($*)
on ^oper_notice "* Possible Drone Flooder*" echo $fmt.snot.dflood($*)
on ^oper_notice "* % % is now operator %" echo $fmt.snot.oper($*)
on ^oper_notice "* Quarantined nick *" echo $fmt.snot.qline($*)
on ^oper_notice "* X-Line Warning *" echo $fmt.snot.xline($*)
on ^oper_notice "* X-Line Rejecting *" echo $fmt.snot.xline($*)
on ^oper_notice "* spoofing:* *as*" echo $fmt.snot.spoof($*)
on ^oper_notice "* POSSIBLE /names abuser *" echo $fmt.snot.names($*)
on ^oper_notice "* New Max Local Clients: *" echo $fmt.snot.maxcli($*)
on ^oper_notice "* server % being introduced by *" echo $fmt.snot.netjoin($*)
on ^oper_notice "*" echo $fmt.snot.onot($*)
on ^server_notice "*" echo $fmt.snot.gen($*)

@ opermotd = [NO]

on ^server_notice "*Start of OPER MOTD*" @ opermotd = [YES]
on ^server_notice "*End" @ opermotd = [NO]

alias fmt.num.ver return $cparse(%K[%w   version%K]%n) ^Bserver^B $2 ^Bversion^B
 $chop(1 $1) ^Bflags^B $3 $4

alias fmt.snot.gen {
         if (opermotd == [YES]) {
                return $cparse(%K[%w  opermotd%K]%n) $2-
        } else {
                return $cparse(%K[%w    server%K]%n) $1-
        }
}

alias fmt.snot.netjoin return $cparse(%K[%w   netjoin%K]%n) $2 -> $6
alias fmt.snot.maxcli return $cparse(%K[%wmaxclients%K]%n) $1-
alias fmt.snot.names return $cparse(%K[%w     names%K]%n) $1-
alias fmt.snot.spoof return $cparse(%K[%w     spoof%K]%n) $1 [$3] as $5
alias fmt.snot.qline return $cparse(%K[%w    q-line%K]%n) $2-
alias fmt.snot.xline return $cparse(%K[%w    x-line%K]%n) $2-
alias fmt.snot.con return $cparse(%K[%w   connect%K]%n) $3 $4
alias fmt.snot.ucon return $cparse(%K[%w    unauth%K]%n) $5 $6
alias fmt.snot.disco return $cparse(%K[%w      exit%K]%n) $3 $4 $5-
alias fmt.snot.stats return $cparse(%K[%w     stats%K]%n) $2 requested by $5 $6 
from $7
alias fmt.snot.links return $cparse(%K[%w     links%K]%n) $2 requested by $5 $6 
from $7
alias fmt.snot.kline return $cparse(%K[%w     kline%K]%n) $1 for $chop(1 $rest(1
 $5)) reason: $chop(1 $rest(1 $6-))
alias fmt.snot.dline return $cparse(%K[%w     dline%K]%n) $1 for $5 $6-
alias fmt.snot.active return $cparse(%K[%w    active%K]%n) $1-
alias fmt.snot.addline return $cparse(%K[%w     added%K]%n) $2 $3-
alias fmt.snot.remline return $cparse(%K[%w   removed%K]%n) $2 $3 $4
alias fmt.snot.unkline return $cparse(%K[%w   unkline%K]%n) $1 for $chop(1 $rest
(1 $7))
alias fmt.snot.untkline return $cparse(%K[%w   unkline%K]%n) $1 for $chop(1 $res
t(1 $8))
alias fmt.snot.whois return $cparse(%K[%w     whois%K]%n) $1-
alias fmt.snot.nick return $cparse(%K[%w      nick%K]%n) $[-9]4 to $[9]6 $7
alias fmt.snot.flood return $cparse(%K[%w   flooder%K]%n) $2-
alias fmt.snot.dflood return $cparse(%K[%w   flooder%K]%n) $1-
alias fmt.snot.count return $cparse(%K[%w    client%K]%n) $1-
alias fmt.snot.tempk return $cparse(%K[%w     tempk%K]%n) $1 for $8 lasting $4 m
ins reason: $chop(1 $rest(1 $9-))
alias fmt.snot.rehash return $cparse(%K[%w    rehash%K]%n) $1-
alias fmt.snot.htm return $cparse(%K[%w       htm%K]%n) $1-
alias fmt.snot.skill return $cparse(%K[%w  servkill%K]%n) $7 killed $3 $10-
alias fmt.snot.okill return $cparse(%K[%w  operkill%K]%n) $4 $5 $6 $7 $10-
alias fmt.snot.mflood return $cparse(%K[%w  msgflood%K]%n) $[-9]2 $3-
alias fmt.snot.motd return $cparse(%K[%w      motd%K]%n) requested by $4 $5 from
 $6
alias fmt.snot.oper return $cparse(%K[%w      oper%K]%n) $1-
alias fmt.snot.onot return $cparse(%K[%w    server%K]%n) $1-

on ^wallop "% *" {
        switch ($2) {
                (Received) {
                        xecho -level snote $fmt.wallops.squit($*)
                }
                (Remote) {
                        xecho -level snote $fmt.wallops.connect($*)
                }
                (WALLOPS) {
                        xecho -level snote $fmt.wallops.wallops($*)
                }
                (OPERWALL) {
                        xecho -level snote $fmt.wallops.operwall($*)
                }
                (LOCOPS) {
                        xecho -level snote $fmt.wallops.locops($*)
                }
                (*) {
                        xecho -level snote $fmt.wallops.none($*)
                }
        }
}

alias fmt.wallops.squit return $cparse(%K[%w  servwall%K]%n %r!%R$0%r!%n) $2-
alias fmt.wallops.connect return $cparse(%K[%w  servwall%K]%n %r!%R$0%r!%n) $2-
alias fmt.wallops.wallops return $cparse(%K[%w   wallops%K]%n %r!%R$0%r!%n) $4-
alias fmt.wallops.operwall return $cparse(%K[%w  operwall%K]%n %r!%R$0%r!%n) $4-
alias fmt.wallops.locops return $cparse(%K[%w    locops%K]%n %r!%R$0%r!%n) $4-
alias fmt.wallops.none return $cparse(%K[%w   wallops%K]%n %r!%R$0%r!%n) $2-

#ejb'y2k
