aIRC — File Browser

aIRCv0.8.69 / aIRCv0.8.69 / addons / irc4.mrc

irc4.mrc — 14.78 KB — Download this file

;/**********************************************************************
; *
; * aIRC
; * IRC Client file 4
; *
; **********************************************************************/
;
alias _irc.sr.raw {
  unset %::*
  tokenize 32 $_:($1) $_:($2) $_:($3) $_:($4) $_:($5) $_:($6) $_:($7) $_:($8-)
  if ($8- == $null) { tokenize 32 $1-7 }
  if ($7- == $null) { tokenize 32 $1-6 }
  if ($6- == $null) { tokenize 32 $1-5 }
  if ($5- == $null) { tokenize 32 $1-4 }
  if ($4- == $null) { tokenize 32 $1-3 }
  if ($3- == $null) { tokenize 32 $1-2 }
  %::nick        = $1
  %::fromserver  = $1
  %::numeric     = $2
  %::ircnum      = $remove($sockname,IRC)
  %::@status     = @Status $+ %::ircnum
  %::INWHOIS     = $_sockmark(4)
  tokenize 32 $3-

  _hook.call irc_onraw $1-

  if (%::numeric == 001) {
    sockmark $sockname $puttok($sock($sockname).mark,$strip($gettok($gettok($1-,-1,32),1,33)),1,9)
    _recent.add nick 10 $_irc.me
    _irc.sw MODE $_irc.me $_getsetup(script,_modes.default)
    _irc._notify.timer %::ircnum
    _irc.setidle %::ircnum
    .timer+irc.autoaway. $+ %::ircnum -o 0 1 _irc._autoaway %::ircnum
    %:echo = _irc.echo.s
    ^001 $1-
  }
  elseif (%::numeric == 002) {
    var %server = $gettok($left($5,$calc($len($5) - 1)),1,91)
    sockmark $sockname $puttok($sock($sockname).mark,%server,3,9)
    titlebar %::@status $_irc.me [+] on %server
    _recent.add server 10 %server $sock($sockname).port
    %:echo = _irc.echo.s
    ^002 $1-
  }
  elseif (%::numeric == 003) {
    %:echo = _irc.echo.s
    ^003 $1-
  }
  elseif (%::numeric == 004) {
    %:echo = _irc.echo.s
    ^004 $1-
  }
  elseif (%::numeric == 005) {
    %:echo = _irc.echo.s
    ^005 $1-
  }
  elseif ($istok(006 007 008,%::numeric,32)) { }
  elseif (%::numeric == 221) {
    var %umodes = $remove($2-,+)
    if (%umodes == $null) { var %umodes }
    titlebar %::@status $gettok($window(%::@status).title,1,32) [+ $+ %umodes $+ $chr(93) $gettok($window(%::@status).title,3-,32)
    %:echo = $_irc.echo.raw
    ^221 $1-
  }
  elseif (%::numeric == 250) {
    %:echo = $_irc.echo.raw
    ^250 $1-
  }
  elseif (%::numeric == 251) {
    unset %=lusers.*
    %=lusers.251 = $2-
    %=lusers.norm = $4
    if ($8 == services) { %=lusers.services = $7 }
    else { %=lusers.invisible = $7 }
    %=lusers.servers = $10
  }
  elseif (%::numeric == 252) {
    %=lusers.252 = $2-
    %=lusers.ircops = $2
  }
  elseif (%::numeric == 253) {
    %=lusers.253 = $2-
    %=lusers.unknown = $2
  }
  elseif (%::numeric == 254) {
    %=lusers.254 = $2-
    %=lusers.chans = $2
  }
  elseif (%::numeric == 255) {
    %=lusers.255 = $2-
    %=lusers.localusers = $4
    %=lusers.totalusers = %=lusers.norm + %=lusers.invisible
    if ($6 isnum) && ($9 isnum) {
      if (%=lusers.services == $null) { %=lusers.services = $6 }
      if (%=lusers.servers == $null) { %=lusers.servers = $9 }
    }
    elseif ($7 isnum) && (%=lusers.servers == $null) { %=lusers.servers = $7 }
    %=lusers.server = %::nick
    _lusers.varsnull2zero
    %:echo = $_irc.echo.rawstatus
    ^lusers
    unset %=lusers.*
  }
  elseif (%::numeric == 256) {
    unset %=admin.*
    %=admin.server = $5
  }
  elseif (%::numeric == 257) { %=admin.info1 = $2- }
  elseif (%::numeric == 258) { %=admin.info2 = $2- }
  elseif (%::numeric == 259) {
    %=admin.info3 = $2-
    %:echo = $_irc.echo.rawstatus
    ^admin
    unset %=admin.*
  }
  elseif (%::numeric == 263) {
    _irc.error.raw $1-
  }
  elseif (%::numeric == 265) {
    %:echo = $_irc.echo.rawstatus
    %::currlocalusers = $5
    %::maxlocalusers = $7
    ^265 $1-
  }
  elseif (%::numeric == 266) {
    %:echo = $_irc.echo.rawstatus
    %::currglobalusersmax = $5
    %::maxglobalusers = $7
    ^266 $1-
  }
  elseif (%::numeric == 271) {
    inc %=silencelist.t
    %=silencelist.nick = $1
    %=silencelist.mask = $2
    %:echo = $_irc.echo.rawstatus
    if (%=silencelist.t == 1) { ^silencelist.start }
    ^silencelist $1-
  }
  elseif (%::numeric == 272) {
    %=silencelist.nick = $1
    %:echo = $_irc.echo.rawstatus
    if (%=silencelist.t == $null) {
      %:echo = $_irc.echo.raw
      ^silencelist.nosilences $1-
    }
    else { ^silencelist.end $1- }
    unset %=silencelist.*
  }
  elseif (%::numeric == 298) {
    %:echo = _irc.lechol.s $colour(info)
    ^298 $1-
  }
  elseif (%::numeric == 301) {
    if (%=whois.nick != $null) { %=whois.away = $3- }
    elseif (%=whowas.nick != $null) { %=whowas.away = $3- }
    else {
      %:echo = _irc.lechol.s $colour(info)
      %::nick = $2
      %::reason = $3-
      ^away $1-
    }
  }
  elseif (%::numeric == 302) {
    var %i = 1,%a,%addr,%irco,%away
    while ($gettok($right($2-,-1),%i,32)) {
      %a = $gettok($2-,%i,32)
      %irco = $iif(* isin $gettok($right($2-,-1),%i,32),1,0)
      %away = $iif($left($gettok($gettok($2-,%i,32),2,61),1) == -,1,0)
      %addr = $remove($gettok(%a,1,61),*) $+ ! $+ $right($gettok(%a,2,61),$calc($len($gettok(%a,2,61)) - 1))
      _irc.echo.userhost $gettok(%addr,1,33) %addr %away %irco
      inc %i
    }
  }
  elseif (%::numeric == 303) {
    var %i = 1,%n = $numtok($2-,32),%nick
    while (%i <= %n) {
      %nick = $gettok($2-,%i,32)
      if ($istok($_irc._notify.current(%::ircnum),%nick,32) == $false) {
        unset %::address %::fulladdress %::site
        %::nick     = %nick
        %::network  = $_notify.get(%nick).net
        %::mask     = $_notify.get(%nick).mask
        %::verified = 0
        %::note     = $_notify.get(%nick).note
        _irc._notify.+ %::ircnum %nick
        %:echo = _irc.lechol.a $colour(notify)
        ^notify
      }
      inc %i
    }
    var %i = $numtok($_irc._notify.current(%::ircnum),32),%nick
    while (%i) {
      %nick = $gettok($_irc._notify.current(%::ircnum),%i,32)
      if ($istok($2-,%nick,32) == $false) {
        _irc._notify.- %::ircnum %nick
        unset %::address %::fulladdress %::site
        %::nick     = %nick
        %::network  = $_notify.get(%nick).net
        %::mask     = $_notify.get(%nick).mask
        %::verified = 0
        %::note     = $_notify.get(%nick).note
        %:echo = _irc.lechol.a $colour(notify)
        ^unotify
      }
      dec %i
    }
    if ($2- == $null) {
      if (%list != $null) { _irc.lechol.s $colour(info) $^*** No one in your notify list is on IRC }
    }
  }
  elseif (%::numeric == 305) {
    _irc.lechol.a $colour(info) $^*** You are no longer marked as being away
    var %t = $removecs($_sockmark(9),a,_),%t = _ $+ %t
    sockmark $sockname $puttok($sock($sockname).mark,%t,9,9)
    _irc.setidle %::ircnum
  }
  elseif (%::numeric == 306) {
    _irc.lechol.s $colour(info) $^*** You have been marked as being away
    var %t = $removecs($_sockmark(9),a,_),%t = _a $+ %t
    sockmark $sockname $puttok($sock($sockname).mark,%t,9,9)
    _irc.setidle %::ircnum
  }
  elseif (%::numeric == 311) {
    if (%=whois.nick != $null) {
      %:echo = $_irc.echo.whois
      ^whois 
    }
    unset %=whois.*
    %=whois.nick = $2
    %=whois.ident = $3
    %=whois.host = $4
    %=whois.name = $6-
    %=whois.fromserver = %::nick
    %=whois.fulladdress = $2 $+ ! $+ $3 $+ @ $+ $4
    %=whois.addy = $gettok(%=whois.fulladdress,2,33)
    %=whois.from = $_country(%=whois.fulladdress)
    %=whois.from2 = $_country(%=whois.fulladdress,1)
    sockmark $sockname $puttok($sock($sockname).mark,1,4,9)
  }
  elseif (%::numeric == 312) {
    if (%=whois.nick != $null) {
      %=whois.server = $3
      %=whois.servinf = $4-
    }
    else {
      %=whowas.server = $3
      %=whowas.signoff = $4-
    }
  }
  elseif (%::numeric == 313) { %=whois.ircop = $1- }
  elseif (%::numeric == 314) {
    %:echo = $_irc.echo.whois
    if (%=whowas.nick != $null) { ^whowas }
    unset %=whowas.*
    %=whowas.fulladdress = $2 $+ ! $+ $3 $+ @ $+ $4
    %=whowas.nick = $2
    %=whowas.addy = $gettok(%=whowas.fulladdress,2,33)
    %=whowas.name = $6-
  }
  elseif (%::numeric == 315) {
    %:echo = $_irc.echo.who
    %=whototal.t = $iif(%=whototal.t,%=whototal.t,0)
    ^who.end $1-
    unset %=whototal.t
  }
  elseif (%::numeric == 317) {
    %=whois.idle = $3
    %=whois.login = $4
    %=whois.317 = $1-
  }
  elseif (%::numeric == 318) {
    %:echo = $_irc.echo.whois
    if (%=whois.nick != $null) { ^whois }
    unset %=whois.*
    sockmark $sockname $puttok($sock($sockname).mark,0,4,9)
  }
  elseif (%::numeric == 319) {
    %:echo = $_irc.echo.whois
    if (%=whois.yataecho1 == $null) { ^whois.start }
    %=whois.yataecho1 = 1
    %=whois.channels = $3-
    %:echo = $_irc.echo.whois
    if (%=whois.channels != $null) { ^whois.channels }
  }
  elseif (%::numeric == 324) {
    %:echo = _irc.echo.w $colour(mode) $2
    ^324 $1-
    if ($_ischan($2)) {
      var %win = @CH_ $+ %::ircnum $+   $+ $2
      if ($window(%win)) {
        var %members,%modes,%tmodes = $3-5,%topic = $_irc.chan(%::ircnum,$2).topic
        %members = [[ $+ $line(%win,0,1) $+ ]]
        if ($remove(%tmodes,+) != $null) { %modes = [+ $+ $ifmatch $+ ] }
        if (%topic != $null) || ($len(%topic)) {
          if (%modes != $null) { %modes = %modes $+ : }
          else { %members = %members $+ : }
        }
        titlebar %win %members %modes %topic
      }
    }
    else { titlebar %::@status $gettok($window(%::@status).title,1,32) [+ $+ $3 $+ ] $gettok($window(%::@status).title,3-,32) }
  }
  elseif (%::numeric == 328) {
    %:echo = _irc.echo.w $colour(info) $2
    ^328 $1-
  }
  elseif (%::numeric == 329) {
    %:echo = _irc.echo.w $colour(info) $2
    ^329 $1-
  }
  elseif (%::numeric == 331) {
    %:echo = _irc.echo.w $colour(topic) $2
    ^331 $1-
  }
  elseif (%::numeric == 332) {
    var %win = @CH_ $+ %::ircnum $+   $+ $2
    %:echo = _irc.echo.w $colour(topic) $2
    ^332 $1-
    if ($window(%win)) {
      var %members,%modes,%tmodes = $_irc.chan(%::ircnum,$2).mode,%topic
      %members = [[ $+ $line(%win,0,1) $+ ]]
      if ($remove(%tmodes,+) != $null) { %modes = [+ $+ $ifmatch $+ ] }
      if ($3- != $null) || ($len($3-)) {
        %topic = $strip($3-)
        if (%modes != $null) { %modes = %modes $+ : }
        else { %members = %members $+ : }
      }
      titlebar %win %members %modes %topic
    }
  }
  elseif (%::numeric == 333) {
    %:echo = _irc.echo.w $colour(topic) $2
    ^333 $1-
  }
  elseif (%::numeric == 341) {
    if ($_ischan($3)) {
      %=341.chan = $3
      %=341.nick = $2
    }
    else {
      %=341.nick = $2
      %=341.chan = $3
    }
    %:echo = _irc.lechol.s $colour(invite)
    ^341 $1-
    unset %=341.*
  }
  elseif (%::numeric == 351) {
    %:echo = _irc.lechol.s $colour(info)
    %=351.version = $2
    %=351.server  = $3
    %=351.info    = $4-
    ^351 $1-
    unset %=351.*
  }
  elseif (%::numeric == 352) {
    inc %=whototal.t
    %:echo = $_irc.echo.who
    if (%=whototal.t == 1) { ^who.start $1- }
    ^who $1-
  }
  elseif (%::numeric == 353) {
    if (%=names.mm == $null) {
      %=names.t = 0
      %=names.@ = 0
      %=names.+ = 0
    }
    inc %=names.mm
    inc %=names.t $numtok($4-,32)
    inc %=names.@ $count($4-,@)
    inc %=names.+ $count($4-,+)
    %=names.chan = $3
    %=names.chantopic = $_irc.chan(%::ircnum,%chan).topic
    %:echo = _irc.echo.w $colour(info) $3
    if (%=names.mm == 1) { ^names.start $1- }
    %=names.names = $4-
    ^names $1-
    %=names.w = @CH_ $+ %::ircnum $+   $+ $3
    if ($window(%=names.w) != $null) {
      if (%=names.c == $null) { clear -l %=names.w }
      %=names.a = 1
      var %t
      while ($gettok($4-,%=names.a,32)) {
        %t = $ifmatch
        if (.* iswm %t) { aline -l %=names.w 1 $+ %t }
        elseif (@* iswm %t) { aline -l %=names.w 2 $+ %t }
        elseif (+* iswm %t) { aline -l %=names.w 3 $+ %t }
        else { aline -l %=names.w 4 $+ %t }
        inc %=names.a
      }
    }
    _irc.chanmembers2title %=names.w
    %=names.c = $3
  }
  elseif (%::numeric == 366) {
    var %synch = 0
    if ($_synchtime.get(%::ircnum,$2) == $null) {
      _synchtime.calc %::ircnum $2
      %synch = 1
    }
    %=names.showsynch = %synch
    %=names.synchtime = $_synchtime.get(%::ircnum,$2)
    %=names.n = $calc(%=names.t - %=names.@ - %=names.+)
    %:echo = _irc.echo.w $colour(info) $2
    if (%=names.t) { ^names.end $1- }
    elseif (%=names.mm) { ^names.invisible $1- }
    else { ^names.nousers $1- }
    if (%synch) { ^joinsynchtime $1- }
    _irc.chanmembers2title %=names.w
    unset %=names.*
  }
  elseif (%::numeric == 367) {
    inc %=banlist.t
    %=banlist.chan = $2
    %:echo = _irc.echo.w $colour(info) $2
    if (%=banlist.t == 1) { ^banlist.start $1- }
    ^banlist $1-
  }
  elseif (%::numeric == 368) {
    %:echo = _irc.echo.w $colour(info) $2
    %=banlist.chan = $2
    if (%=banlist.t == $null) { ^banlist.nobans }
    else { ^banlist.end }
    unset %=banlist.*
  }
  elseif (%::numeric == 369) {
    %:echo = $_irc.echo.whois
    if (%=whowas.nick != $null) { ^whowas }
    unset %=whowas.*
  }
  elseif (%::numeric == 371) {
    inc %=info.t
    %=info.server = %::nick
    %:echo = $_irc.echo.rawstatus
    if (%=info.t == 1) { ^info.start $1- }
    ^info $1-
  }
  elseif (%::numeric == 372) { echo2 -t %::@status $2- }
  elseif (%::numeric == 373) { unset %=info.* }
  elseif (%::numeric == 374) {
    %=info.server = %::nick
    %:echo = $_irc.echo.rawstatus
    ^info.end $1-
    unset %=info.*
  }
  elseif (%::numeric == 375) {
    linesep %::@status
    echo2 $colour(info) -t %::@status $^*** $2
  }
  elseif (%::numeric == 376) { echo2 $colour(info) -t %::@status $^*** End of MOTD }
  elseif (%::numeric == 381) {
    %:echo = _irc.lechol.s $colour(info)
    ^381 $1-
  }
  elseif (%::numeric == 382) { 
    %:echo = _irc.lechol.s $colour(info)
    ^382 $1-
  }
  elseif (%::numeric == 391) {
    %:echo = _irc.lechol.s $colour(info)
    ^391 $1-
  }
  elseif (4* iswm %::numeric) || (5* iswm %::numeric) || (9* iswm %::numeric) {
    if (%=whois.nick != $null) {
      %:echo = $_irc.echo.whois
      ^whois
    }
    if (%=whowas.nick != $null) {
      %:echo = $_irc.echo.whois
      ^whowas
    }
    unset %=whois.* %=whowas.*
    if (%::numeric == 432) {
      if ($1 == $_irc.me) { _irc.error.raw $1- }
      else { _timeremote _irc.badnick $sockname $2 }
    }
    elseif (%::numeric == 433) {
      if (*registered* iswm $3-) { _irc.error.raw $1- }
      elseif ($1 == $_irc.me) { _irc.error.raw $1- }
      else { _timeremote _irc.busynick $sockname $2 }
    }
    else { _irc.error.raw $1- }
  }
  elseif (%::INWHOIS) { _whoisextra.add %::numeric $2- }
  else {
    var %alias = ^ $+ %::numeric
    if ($isalias(%alias)) {
      %:echo = _irc.echo.s
      %alias $1-
    }
    else { _irc.echo.s $2- }
  }
  unset %::*
}