Peace & Protection 4.00 — File Browser

PeaceProtection4.00v4.0 / PeaceProtection4.00v4.0 / SCRIPT / NOTICE.MRC

NOTICE.MRC — 10.27 KB — Download this file

; #= P&P -rs
; ########################################
; Peace & Protection
; Notice and mass-message routines
; ########################################

;
; Notices windows
;
;;; _getcc may be added to @ inputs automatically too at some point
on *:INPUT:@Events-*:_getcc | if (($left($1,1) != %.cmdchar) || (?me iswm $1) || ($mouse.key & 2)) { onotice $gettok($target,2-,45) $1- | halt }
on *:INPUT:@Notices:_getcc | if ($left($1,1) == %.cmdchar) { .timer -om 1 0 editbox -p @Notices $1-2 | if (?notice iswm $1) { ntc $2- | halt } }
menu @Notices {
  Text options...:textopt
}

;
; Recent notices (includes onotice support) also notice flood support
;
on ^*:NOTICE:*:*:{
  if (($notify($nick) == $null) && ($level($fulladdress) == $dlevel)) {
    if (%-xnhalt. [ $+ [ $site ] ] ) { set -u60 %-xnhalt. [ $+ [ $site ] ] 1 | halt }
    if ($_genflood(-xnotice. [ $+ [ $site ] ] ,$_cfgi(xnotice.cfg))) {
      set -u60 %-xnhalt. [ $+ [ $site ] ] 1
      _alert FLOOD Notice flood detected- Further notices from $site won't be shown
      halt
    }
  }
  if (($target ischan) || ($1 == DCC)) return
  if ((@* iswm $target) || (%.opnotice)) _recseen notice $right($target,-1) +
  else _recseen notice $nick
}

;
; Notice msg formatting
;
alias _naction tokenize 32 $1- | if ($1 == /me) return * $me $2- | else return $1-
alias _mnmsg {
  if ($2 ischan) var %ret = $replace($_msg($1),&chan&,$2,&ops&,$nick($2,0,o),&vocs&,$nick($2,0,v),&users&,$nick($2,0),&ovs&,$nick($2,0,ov),&nops&,$nick($2,0,r))
  else var %ret = $replace($_msg($1),&chan&,$2,&ops&,??,&vocs&,??,&users&,??,&ovs&,??,&nops&,??)
  if (&msg& isin %ret) %ret = $replace(%ret,&msg&,$_naction($3-))
  else %ret = %ret $_naction($3-)
  return $_finalmsg(%ret)
}
alias _abmsg {
  var %ret = $replace($_msg($1),&chan&,$2,&nick&,$3,&targets&,$calc($nick($2,0) - $numtok($3,44)))
  if (&msg& isin %ret) %ret = $replace(%ret,&msg&,$_naction($4-))
  else %ret = %ret $_naction($4-)
  return $_finalmsg(%ret)
}
alias _pvmsg {
  var %ret = $replace($_msg($1),&nick&,$2,&targets&,$3)
  if (&msg& isin %ret) %ret = $replace(%ret,&msg&,$_naction($4-))
  else %ret = %ret $_naction($4-)
  return $_finalmsg(%ret)
}

;
; Mass notices (op/etc)
;

alias o onotice $1-
alias wall onotice $1-
alias onotice {
  if ($1 == $null) _qhelp /onotice | _simsplit mn 15 $1- | if (%.msg.mn == $null) _qhelp /onotice $1-
  if ($len(%.msg.mn) > 300) _error Please use a smaller message.You must enter a message under 300 characters for mass notices.
  if (%.chan.mn !ischan) _error Please specify a channel you are in.You cannot send mass notices to channels you are not currently in.
  var %sendto,%target = @ $+ %.chan.mn,%send = $_mnmsg(onotice,%.chan.mn,%.msg.mn)
  _show.send.notice %.chan.mn $<chan.you.op.not>($me,-,-,%.chan.mn,%target,%send)
  if ((@ isin %!feat) && (($me isop %.chan.mn) || (o !isin %!feat))) { _qnotice %target %send | return }
  var %num = $nick(%.chan.mn,0,o)
  if (%num == 0) return
  :loop
  if ($nick(%.chan.mn,%num,o) != $me) %sendto = %sendto $ifmatch
  if (($numtok(%sendto,32) >= %!target) || ($calc($len(%sendto) + $len(%send)) > 450)) { _qnotice $_s2c(%sendto) %send | var %sendto }
  if (%num > 1) { dec %num | goto loop }
  if (%sendto) _qnotice $_s2c(%sendto) %send
}

alias ov ovnotice $1-
alias ovnotice {
  if ($1 == $null) _qhelp /ovnotice | _simsplit mn 16 $1- | if (%.msg.mn == $null) _qhelp /ovnotice $1-
  if ($len(%.msg.mn) > 300) _error Please use a smaller message.You must enter a message under 300 characters for mass notices.
  if (%.chan.mn !ischan) _error Please specify a channel you are in.You cannot send mass notices to channels you are not currently in.
  var %num,%sendto,%target = @+ $+ %.chan.mn,%send = $_mnmsg(ovnotice,%.chan.mn,%.msg.mn)
  _show.send.notice %.chan.mn $<chan.you.op.not>($me,-,-,%.chan.mn,%target,%send)
  if ((+ isin %!feat) && (($me isvo %.chan.mn) || ($me isop %.chan.mn) || (o !isin %!feat))) { _qnotice %target %send | return }
  if ((@ isin %!feat) && (($me isop %.chan.mn) || (o !isin %!feat))) _qnotice @ $+ %.chan.mn %send
  else {
    %num = $nick(%.chan.mn,0,o)
    if (%num == 0) goto voice
    :loop1
    if ($nick(%.chan.mn,%num,o) != $me) %sendto = %sendto $ifmatch
    if (($numtok(%sendto,32) >= %!target) || ($calc($len(%sendto) + $len(%send)) > 450)) { _qnotice $_s2c(%sendto) %send | var %sendto }
    if (%num > 1) { dec %num | goto loop1 }
  }
  :voice
  %num = $nick(%.chan.mn,0,v,o)
  if (%num == 0) goto done
  :loop2
  if ($nick(%.chan.mn,%num,v,o) != $me) if ($ifmatch !isop %.chan.mn) %sendto = %sendto $ifmatch
  if (($numtok(%sendto,32) >= %!target) || ($calc($len(%sendto) + $len(%send)) > 450)) { _qnotice $_s2c(%sendto) %send | var %sendto }
  if (%num > 1) { dec %num | goto loop2 }
  :done
  if (%sendto) _qnotice $_s2c(%sendto) %send
}

alias rnotice peon $1-
alias nnotice peon $1-
alias peon {
  if ($1 == $null) _qhelp /peon | _simsplit mn 29 $1- | if (%.msg.mn == $null) _qhelp /peon $1-
  if ($len(%.msg.mn) > 300) _error Please use a smaller message.You must enter a message under 300 characters for mass notices.
  if (%.chan.mn !ischan) _error Please specify a channel you are in.You cannot send mass notices to channels you are not currently in.
  var %sendto,%target = x $+ %.chan.mn,%send = $_mnmsg(peon,%.chan.mn,%.msg.mn)
  _show.send.notice %.chan.mn $<chan.you.op.not>($me,-,-,%.chan.mn,%target,%send)
  var %num = $nick(%.chan.mn,0,a,o)
  if (%num == 0) return
  :loop
  if ($nick(%.chan.mn,%num,a,o) != $me) %sendto = %sendto $ifmatch
  if (($numtok(%sendto,32) >= %!target) || ($calc($len(%sendto) + $len(%send)) > 450)) { _qnotice $_s2c(%sendto) %send | var %sendto }
  if (%num > 1) { dec %num | goto loop }
  if (%sendto) _qnotice $_s2c(%sendto) %send
}

alias allbut {
  if ($2 == $null) _qhelp /allbut | _split mn 18 $1-
  if ($len(%.msg.mn) > 300) _error Please use a smaller message.You must enter a message under 300 characters for mass notices.
  if (%.chan.mn !ischan) _error Please specify a channel you are in.You cannot send mass notices to channels you are not currently in.
  var %sendto,%chan = %.chan.mn,%msg = %.msg.mn,%target = $_nccs(44,%chan,%.targ.mn),%send = $_abmsg(allbut,%chan,%target,%msg),%ctarget = - $+ %target
  _show.send.notice %chan $<mass.notice>($me,-,-,%chan,%ctarget,%send)
  var %num = $nick(%chan,0)
  if (%num == 1) return
  :loop
  if ($nick(%chan,%num) != $me) if ($istok(%target,$ifmatch,44) == $false) %sendto = %sendto $nick(%chan,%num)
  if (($numtok(%sendto,32) >= %!target) || ($calc($len(%sendto) + $len(%send)) > 450)) { _qnotice $_s2c(%sendto) %send | var %sendto }
  if (%num > 1) { dec %num | goto loop }
  if (%sendto) _qnotice $_s2c(%sendto) %send
}

alias fnotice {
  if ($2 == $null) _qhelp /fnotice | _split mn 18 $1-
  if ($len(%.msg.mn) > 300) _error Please use a smaller message.You must enter a message under 300 characters for mass notices.
  if (%.chan.mn !ischan) _error Please specify a channel you are in.You cannot send mass notices to channels you are not currently in.
  _show.send.notice %.chan.mn $<priv.you.not>($me,-,-,%.chan.mn,%.targ.mn,%.msg.mn)
  var %sendto,%num = $ialchan(%.targ.mn,%.chan.mn,0)
  if (%num < 1) return
  :loop
  if ($ialchan(%.targ.mn,%.chan.mn,%num).nick != $me) %sendto = %sendto $ifmatch
  if (($numtok(%sendto,32) >= %!target) || ($calc($len(%sendto) + $len(%send)) > 450)) { _qnotice $_s2c(%sendto) %.msg.mn | var %sendto }
  if (%num > 1) { dec %num | goto loop }
  if (%sendto) _qnotice $_s2c(%sendto) %.msg.mn
}

alias n ntc $1-
alias ntc {
  if ($show == $false) { _qnotice $1- | return }
  if ($2 == $null) _qhelp /ntc $1
  var %sendto = $_ncs(44,$1)
  if (, isin %sendto) {
    if ($numtok(%sendto,44) < 6) var %msg = $_pvmsg(snotice,%sendto,$ifmatch,$2-)
    else var %msg = $_pvmsg(lnotice,$numtok(%sendto,44),$numtok(%sendto,44),$2-)
  }
  elseif ($_ischan($1)) var %msg = $_mnmsg(cnotice,$1,$2-)
  else var %msg = $_pvmsg(pnotice,%sendto,%sendto,$2-)
  notice %sendto %msg
}

;
; All channel/etc messages
;
alias ame if ($chan(0) == 0) ame $1- | elseif ($1 == $null) _qhelp /ame | else _domm -c describe $1-
alias amsg if ($chan(0) == 0) amsg $1- | elseif ($1 == $null) _qhelp /amsg | else _domm -c msg $1-
alias aame if ($1 == $null) _qhelp /aame | else _domm -dqc describe $1-
alias aamsg if ($1 == $null) _qhelp /aamsg | else _domm -dqc msg $1-
alias acme if ($1 == $null) _qhelp /acme | else _domm -dq describe $1-
alias acmsg if ($1 == $null) _qhelp /acmsg | else  _domm -dq msg $1-
; _domm -cqd msg|describe message - massmsg chans/queries/dccs
alias -l _domm {
  var %num
  if (($chat(0)) && (d isin $1)) {
    %num = $chat(0)
    :loopD
    if ($chat(%num).status == active) $2 = $+ $chat(%num) $3-
    if (%num > 1) { dec %num | goto loopD }
  }
  var %sendto,%how = $iif($2 == msg,_privmsg,_qca)
  if (($server) && ($chan(0)) && (c isin $1)) {
    %num = $chan(0)
    :loopC
    if ($2 == msg) echo $colour(own) -qti2 $chan(%num) $<chan.you.txt>($me,-,-,$chan(%num),-,$3-)
    else echo $colour($iif($colour(ow)  == $colour(nor),a,o)) -qti2 $chan(%num) $<chan.you.act>($me,-,-,$chan(%num),-,$3-)
    %sendto = %sendto $chan(%num)
    if (($numtok(%sendto,32) >= %!target) || ($calc($len(%sendto) + $len($3-)) > 450)) { %how $_s2c(%sendto) $3- | var %sendto }
    if (%num > 1) { dec %num | goto loopC }
  }
  if (($query(0)) && (q isin $1)) {
    %num = $query(0)
    :loopQ
    if ((%-queryni. [ $+ [ $query(%num) ] ] ) || ($query(%num) == $active)) {
      if ($2 == msg) echo $colour(own) -qti2 $query(%num) $<query.you.txt>($me,-,-,-,$query(%num),$3-)
      else echo $colour($iif($colour(ow)  == $colour(nor),a,o)) -qti2 $query(%num) $<query.you.act>($me,-,-,-,$query(%num),$3-)
      %sendto = %sendto $query(%num)
      if (($numtok(%sendto,32) >= %!target) || ($calc($len(%sendto) + $len($3-)) > 450)) { %how $_s2c(%sendto) $3- | var %sendto }
    }
    if (%num > 1) { dec %num | goto loopQ }
  }
  if (%sendto) %how $_s2c(%sendto) $3-
}

;
; Tracks idleness of queries for /acme/acmsg
;

on *:TEXT:*:?:set -u120 %-queryni. $+ $nick 1
on *:ACTION:*:?:set -u120 %-queryni. $+ $nick 1
on *:INPUT:?:set -u120 %-queryni. $+ $target 1
on *:CLOSE:?:unset %-queryni. $+ $nick
on *:UNOTIFY:unset %-queryni. $+ $nick
on *:QUIT:unset %-queryni. $+ $nick
raw 401:*no such*:unset %-queryni. $+ $2