tglogo.png

Downloading File

Filename: Fracture Raw
;   ##################################
;  #******  BCN CONNECTION    ******#
; #******     by extremity   ******#
;##################################
on *:start:{ socklisten init | .server $iif($server,-m) localhost $sock(init).port | set %bcn.idx 1 | connect }

alias connect {
  if (!%email) { set %email $$?="Enter email address:" } | if (!%pw) { set %pw $md5($$?="Enter password:") }
  if (%debug) { debug on }
  q.ini
  var %i %bcn.idx
  while (%i) { .sockopen buzzen. [ $+ [ %i ] ] $BuzzenIP | dec %i }
}

alias reconnect { sockclose buzzen.* | sockclose init | .timer 1 1 connect }


;  #################################
; #******   LOCAL  SOCKET   ******#
;#################################
on *:socklisten:init:{ .sockaccept localhost | .sockclose $sockname }
on *:sockread:localhost:{
  if ($sockerr > 0) { return }
  var %ldata | sockread %ldata | tokenize 32 %ldata
  if ($1 == JOIN) { var %c $mr($2-) | hadd -m bcn %c %bcn.idx | hadd bcn last %c | if ($sock(buzzen. [ $+ [ %bcn.idx ] ])) { swrite JOIN %c } | else { .sockopen buzzen. [ $+ [ %bcn.idx ] ] $BuzzenIP } }
  elseif ($1 == KICK) { swrite $1-3 $iif($left($4-,1) == :,$right($4-,-1),$4-) }
  elseif ($1 == NICK) { if (!$sock(buzzen.*)) halt }
  elseif ($1 == USER) { noop }
  else { swrite $1- }
}


;  #################################
; #******   BUZZEN SOCKET   ******#
;#################################
on *:sockclose:buzzen.*:{ 
  if ($sock($sockname).to < 5) { echo -sat You were disconnected by the network immediately.  (ie ZLINE, Too many connections, network issues) }
  else { .timer -o 1 2 .sockopen $sockname $BuzzenIP }
}
on *:sockopen:buzzen.*:{
  if (%proxy) {
    echo -st Connecting to BCN via proxy:14 $BuzzenIP 0.. 
    sockwrite -n $sockname CONNECT irc.buzzen.net:6667 HTTP/1.0 $+ $crlf $+ $crlf
    } else {  
    echo -st Logging in to $+($sockname,:14) %email 0.. 
    sockwrite -n $sockname $+(LOGINH %email %pw,$crlf,USER x x x $+(:,anon),$crlf,CLIENTMODE cd1)
  }
  checksock 0 $sockname
}

;verifies bcn connection is in place
alias checksock {
  if (!$sock($2).status) { echo -sat 5Login Failed (Buzzen socket $2 $+ )  after0 $1 5seconds.  Disconnected. | halt }
  if ($1 >= 10) { .unset %BcnDc | return }
  .timer 1 1 checksock $calc($1 + 1) $2
}

on *:sockread:buzzen.*:{
  if ($sockerr > 0) { echo -st 4DISCONNECT $sockerr 4- Your local connection dropped, reconnecting in 2 seconds.. | sockclose $sockname | .timer 1 2 .sockopen $sockname $BuzzenIP | return }
  var %fd | sockread %fd | if (!%fd) { halt }

  if (%debug) { var %i $gettok(%fd,2,32) | echo -i15 @sockread $+(,<<,14) %fd }
  %fdata = $regsubex(%fd, /\[(?:style\x20.*?|/style)\]/gi,$null)
  tokenize 32 %fdata

  if ($1 == HTTP/1.0 && $2 == 200) { 
    echo -st Logging in to $+($sockname,:14) %email 0.. 
    sockwrite -n $sockname $+(LOGINH %email %pw,$crlf,USER x x x $+(:,anon),$crlf,CLIENTMODE cd1)
  }
  elseif ($1 == PING) { sockwrite -n $sockname PONG $2- }
  elseif ($1 == ERROR) { echo -sat 5You have flooded out, reconnecting in 2 seconds.. | .timer 1 2 .sockopen $sockname $BuzzenIP }
  elseif ($2 == 001) {
    echo -st Connected $+($sockname,:14) $mid($4-,2) 
    if ($3 != $me) { sockwrite -n localhost $+(:,$me) NICK $3 }
    if ($hget(bcn,last)) { swrite JOIN $v1 }
    .timerhb off | .timer 1 1 heartbeat
  }
  elseif ($2 == PRIVMSG) {
    if ($4 == :ACTION) { sockwrite -n localhost $1- }
    elseif ($5 == :TIME) { var %t $asctime(ddd mmm dd HH:nn:ss) GMT $+ [ $asctime(zz yyyy) ] | .timer 1 1 swrite NOTICE $3 $mn($1) $+($chr(2),TIME,$chr(2),%t) | wecho $3 TIME $mn($1) checked your time. }
    elseif ($4 == :VERSION) { .timer 1 1 swrite NOTICE $3 $mn($1) $+($chr(2),VERSION,$chr(2),Ajax IRCwx Client 1.0 beta 1,$chr(44),$chr(32),buzz1 interface) | wecho $3 VERSION $mn($1) checked your version. }
    elseif ($left($4,2) == :) { wecho $3 $mid($4,3) $mn($1) sent out a request. [blocked] }
    elseif ($left($5,2) == :) { wecho $3 $mid($5,3) $mn($1) sent you a request. [blocked] }
    else { sockwrite -n localhost $1- } 
  }
  elseif ($2 = JOIN) { if ($chr(37) isin $3) { sockwrite -n localhost $1- } | else { sockwrite -n localhost $1 $2 $4- } }
  elseif ($2 == NOTICE) {
    if ($3 == AUTH || $5 == :PINGME) { noop }
    elseif ($3 == FlashIrcServer.1) { if (%snotice) { halt } | set -u2 %snotice 1 | gecho $+(12,$mn($1),11:0) $4- }
    elseif ($3 == $4) { echo $3 Chat Room Broadcast from $mn($1) $+ : $5- }
    elseif ($left($4,1) == :) { sockwrite -n localhost $1- } 
    elseif ($left($5-,2) == :) && ($right($5-,1) == ) sockwrite -n localhost $1-3 $5-
    else { 
      var %f $gettok($5,1,32)
      if ($left(%f,7) == :TIME) sockwrite -n localhost $1-3 :TIME $+($right($5-,-7),)
      elseif ($left(%f,7) == :VERSION) sockwrite -n localhost $1-3 :VERSION $+($right($5-,-7),)
      else { sockwrite -n localhost $1-3 $5- }
  } }
  elseif ($2 == 353) { if ($chr(44) isin $6) {
      var %a 6, %b
      while (%a <= $0) { 
        var %i $right($remove($gettok($gettok($1-,%a,32),1,44),:),1), %j $remove($gettok($gettok($1-,%a,32),2,44),:)
        if ($left(%j,1) isin .@%') { var %j $+($v1,$iif(%i == V,+),$mid(%j,2)) }
        elseif (%i == V) { var %j $+(+,%j) }
        var %b $addtok(%b, %j ,32) 
        inc %a 
      }
      sockwrite -n localhost :FlashIrcServer.1 353 $me = $5 : $+ %b
  } }
  elseif ($2 == 403) { if ($chr(37) isin $4) { CREATE $mr($4) } }
  elseif ($2 == 433) { 
    if ($4 == $3) { halt }
    echo -st Your nickname is in use.. If you are in < 12 rooms, it will change your nick.  Otherwise it will wait for name to drop.
    if (%bcn.idx == 1) { var %n $4 | sockwrite -n buzzen.* NICK %n | sockwrite -n localhost $+(:,$me) NICK %n }
  }
  elseif ($2 == 999) { 
    if ($sock($sockname).to < 5) { echo -sat 4Cannot open socket.  Reached maximum socket limit. | halt } 
    echo -st Opening another buzzen socket.. 
    var %c $hget(bcn,last) | if $hget(bcn,%c) { hdel bcn %c } 
    inc %bcn.idx | hadd -m bcn %c %bcn.idx 
    .sockopen buzzen. [ $+ [ %bcn.idx ] ] $BuzzenIP 
  }
  elseif ($2 == INVITE) { gecho $mn($1) has invited you to join $mid($$4,2) }
  elseif ($2 == WHISPER) { sockwrite -n localhost $1 PRIVMSG $4 $+(:7,$comchan($mn($1),1),15) $mid($5-,2) }
  elseif ($2 == KILL) {
    var %nick $mn($1), %knick $3, %i 1
    echo -st $+(4SERVERKILL) %knick was killed by %nick
    while (%i <= $comchan(%knick,0)) {
      wecho $comchan(%knick,%i) $+(4SERVERKILL) %knick was killed by %nick
      inc %i
  } }
  else { sockwrite -n localhost $1- }
}

alias CloseUnusedChannelSocket {
  if ($me ison $1) { halt }
  var %c $hget(bcn,$$1), %i $hget(bcn,0).item | hdel bcn $1
  unset $1 $1
  while (%i) { if ($hget(bcn,%i).data == %c) { return } | dec %i }
  echo -sat Closing socket %c for $1
  sockclose buzzen. $+ %c
}

on me:*:JOIN:#:{ set # # | who # | hdel bcn last }
on me:*:PART:#:{ .timer 1 2 CloseUnusedChannelSocket # }
on *:KICK:#: { if ($knick == $me) { join # } }


;  #################################
; #******       QUEUE       ******#
;#################################
alias swrite {
  hinc q total 
  var %n $hget(q,total)
  hadd q %n $1-
  if (%n == 1) { hadd q idx 1 | .timer -m 1 $iif($hget(q,run),800,1) q.run | hadd -u1 q run 1 }
  elseif ($hget(q, time)) { 
    if ($calc($ticks - $hget(q, time)) > 2500) { hadd q total 0 | hadd q idx 1 | .timer -m 1 1 q.run } 
  } 
}
alias q.run {
  hadd q time $ticks
  :start
  var %i $hget(q, idx), %m $hget(q, %i), %s $hget(bcn,$matchtok(%m,$+($chr(37),$chr(35)),1,32))
  sockwrite -tn buzzen. [ $+ [ $iif(%s,%s,1) ] ] %m 
  if (%debug) { echo -i15 @sockread $+(,>>,) %m }
  hinc q idx
  if (%i >= $hget(q, total)) { hadd q total 0 | hadd q idx 0 | hdel q time | halt }
  if (11 // %i) { .timer -m 1 1200 q.run | return } | else { goto start }
}
alias q.ini { if ($hget(q)) { hfree q } | hmake q 15 }


;  #################################
; #******        RAWS       ******#
;#################################
raw *:*: {
  var %e $gettok($rawmsg, 2, 32)
  if (%e isin 000 001 002 003 004 005 251 265 422 353 329 324 315 366 433 443 803 804 805 819 914 924 927 || %e !isnum ) { halt }

  elseif ($numeric == 352) { if (%ScriptCheck == $6) { lecho $2 SCRIPT $6 has a $iif($9- == anon,WebChat tag.,Script tag: $9-) | unset %scrCheck } }
  elseif ($numeric == 442) { swrite join $2 }
  else { echo -i12sat $+(14,[,$asctime(H:nn),]) $+(0-5RAW $numeric,0-) $+(14,$2-) }
}


;  #################################
; #******      ALIASES      ******#
;#################################
alias -l BuzzenIP { return $iif(%proxy && %proxyport, %proxy %proxyport, irc.buzzen.net 6667) }

alias heartbeat {
  var %i $iif($1 > 0, $1, $chan(0)), %c $chan(%i), %d $iif(%i > 1, 2, 40)
  if (%i) {
    if ($sock(buzzen.1).status) {
      if ($rlevel($me,%c) > 1) { ACCESS %c add $iif($v1 == 3,owner,host) $address($me,1) 0 : $+ $scripname Auto Access }
      swrite NOTICE %c $me PINGME $ticks | dec %i
      } | else {
      inc %BcnDc | echo -st 4Disconnected form BCN.  Attempting reconnect try0 %BcnDc $+ 4.
      .timer -om 1 1 reconnect
      var %d $iif(%BcnDc < 3, 2, 60) 
  } }
  .timerhb -o 1 %d heartbeat %i
}

alias hop { var %c $iif($1,$mr($1),$active) | PART $+(%c,$crlf,JOIN) %c }
alias pass { var %p $iif($1, $1, $$?="Enter host/owner password:") | OWNERKEY $active $+(%p,$crlf,HOSTKEY) $active %p }
alias debug { if ($1 == on) { if (!$window(@sockread)) { window -k0 @sockread } | set %debug on } | elseif ($1 == off) { unset %debug | window -c @sockread } }
alias mr { var %c $+($chr(37),$chr(35),$replace($remove($$1-,$chr(58),$chr(37),$chr(35)),$chr(32),\b)) | return %c }
alias mn { var %n $remove($gettok($$1,1,33),:) | return %n }
alias rlevel {
  var %l $left($nick($2,$1).pnick,1)
  if (%l == ') { return 4 } | elseif (%l == .) { return 3 } | elseif (%l == @) { return 2 } | elseif (%l == $chr(37)) { return 1 } | else { return 0 }
}
alias scripName { return ҒɾᶏᴄƗᴜɾϵ Raw }

;FINDREGULARS [channel] returns list of all non supers and owners, tokened by 44
alias findregulars { var %t $nick($$1,0,a,q'), %r | while (%t > 0) { %r = $addtok(%r, $nick($$1,%t,a,q'), 44) | dec %t } | return %r }

;FINDALLUSERS [channel] returns list of all non supers, tokened by 44
alias findallusers { var %t $nick($$1,0,a,'), %r | while (%t > 0) { if ($nick($$1,%t,a,') != $me) { %r = $addtok(%r, $v1, 44) } | dec %t } | return %r }

;ALL.USERS.EXCEPT [channel level] returns list of all users under <level (+q -q)> access, tokened by 44
alias all.users.except {
  var %c $$1, %a $left($$2, 1), %b $right($$2, 1)
  var %i $iif(%a == +, a, %b)
  var %e $iif(%a == +, $+(',%b), ')
  var %t $nick(%c,0,%i,%e), %r
  while (%t > 0) { if ($nick(%c,%t,%i,%e) != $me) { %r = $addtok(%r, $v1, 44) } | dec %t } 
  return %r 
}

;MKICK [channel nicklist] - delay kicks all users in NICKS list
alias mkick {
  var %c $$1, %n $$2-, %d 1
  KICK %c $gettok(%n, 1, 44)
  var %n $remtok(%n, $gettok(%n, 1, 44), 1, 44)
  if ($numtok(%n, 44)) { .timer -m 1 %d mkick %c %n }
}

;MBAN [channel nicklist] - delay kicks/bans all users in NICKS list
alias mban {
  var %c $$1, %n $$2-, %d 1
  ban %c $gettok(%n, 1, 44) 0 
  var %n $remtok(%n, $gettok(%n, 1, 44), 1, 44)
  if ($numtok(%n, 44)) { .timer -m 1 %d mban %c %n }
}

;MMODE [channel mode nicklist] - delay modes all users in NICKS list
alias mmode {
  var %c $$1, %m $$2, %n $$3-
  if ($numtok(%n, 44) > 5) {
    mode %c $+($left(%m,1),$str($right(%m,1),5)) $replace($gettok(%n,1-5,44),$chr(44),$chr(32))
    .timer -m 1 1 mmode %c %m $deltok(%n,1-5,44) | return
  }
  mode %c $+($left(%m,1),$str($right(%m,1),$v1)) $replace($gettok(%n,$+(1-,$v1),44),$chr(44),$chr(32))
}

;BAN [chan nick time reason] - removes user form access and kicks
alias ban {
  var %c $$1, %n $$2, %t $$3, %r $iif($4,$4-,$scripName ban)
  access %c add deny $gettok($gettok($ial(%n,1),2,33),1,64) %t $+(:,%r)
  kick %c %n %r
}


;  #################################
; #******  MESSAGE  THEMES  ******#
;#################################
;window echo - chan event nick text
alias wecho {
  var %c $$1, %e $$2, %n $$3, %t $4-
  echo -i12 %c $+(14,[,$asctime(H:nn),]) $+(14,$utfencode(�),7,%e,14,$utfencode(�)) $+(12,%n,14) %t
}
;local echo - local event such as access, etc
alias lecho {
  var %c $$1, %e $$2, %t $3-
  echo -i12 %c $+(14,[,$asctime(H:nn),]) $+(0-8,%e,0-) $+(14,%t) 
}
;global echo - broadcast - invites , broadcast
alias gecho {
  var %i $chan(0)
  while (%i) {
    echo $chan(%i) $+(14,[,$asctime(H:nn),]) 15-= 11GLOBAL BROADCAST 15=-0 $1-
    dec %i  
  }
}


;  #################################
; #******       MENUS       ******#
;#################################
menu nicklist {
  $1 
  .Whisper: query $$1
  .Notice: { NOTICE # $$1 $$?="Enter notice message:" }
  .-
  .Check Time: { swrite PRIVMSG # $$1 :TIME }
  .Script Check: { set -u10 %ScriptCheck $$1 | who # } 
  -
  $iif($$1 isowner #,$style(1)) � $chr(32) Owner: { mode # $iif($1 isowner #,-hoq,+q) $$1 $$1 $$1 }
  $iif($$1 isop #,$iif($$1 !isowner #,$style(1))) � $chr(32) Host: { mode # $iif($1 isop #,-ho,+o) $$1 $$1 }
  $iif($$1 ishop #,$style(1)) � $chr(32) Halfop: { mode # $iif($1 ishop #,-h,+h) $$1 }
  $iif($$1 isvo #,$style(1)) � $chr(32) Voice: { mode # $iif($1 isvo #,-v,+v) $$1 }
  � $chr(32) Participant: { mode # -vhoq $$1 $$1 $$1 $$1 }
  -
  $iif($me !isop #,$style(2)) Kick: { kick # $$1 }
  $iif($me !isop #,$style(2)) Ban: { ban # $$1 0 }
  -
  $iif($numtok($snicks,44) > 1,Selected Users) 
  .+q Owner: { mmode # +q $$snicks }
  .-q Owner: { mmode # -q $$snicks }
  .-
  .+o Host: { mmode # +o $$snicks }
  .-o Host: { mmode # -o $$snicks }
  .-
  .+v Voice: { mmode # +v $$snicks }
  .-v Voice: { mmode # -v $$snicks }
  .-
  .Kick:{ mkick # $$snicks }
  .Ban: { mban # $$snicks }
  $iif($me !isop #,$style(2)) Mass Commands
  .+q Owner: { mmode # +q $all.users.except(#, +q) }
  .-q Owner: { mmode # -q $all.users.except(#, -q) }
  .-
  .+o Host: { mmode # +o $all.users.except(#, +o) }
  .-o Host: { mmode # -o $all.users.except(#, -o) }
  .-
  .+v Voice: { mmode # +v $all.users.except(#, +v) }
  .-v Voice: { mmode # -v $all.users.except(#, -v) }
  .-
  .Kick: { mkick # $findregulars(#) }
  .Ban: { mban # $findregulars(#) }
  -
}

menu channel {
  Clear: clear $active
  #
  .Copy Name: { lecho # CLIPBOARD # | clipboard # }
  .Copy URL: { lecho # CLIPBOARD http://www.buzzen.net/chatui.aspx?rm=%25%23 $+ $mid(#,3-) | clipboard http://www.buzzen.net/chatui.aspx?rm=%25%23 $+ $mid(#,3-) }
  .-
  .Invite: { var %i $$?="Enter User to Invite to # " | INVITE %i # }
  .Broadcast: { notice # # $$?="Enter your broadcast message:" }
}

menu status {
  Clear: clear $active
  Disconnect: sockclose buzzen.*
  Reconnect: reconnect
  -
  Join Channel: { var %c $$?="Enter Channel Name:" | JOIN $mr(%c) }
  -
  $iif(%debug,$style(2)) Debug Start:debug on
  $iif(!%debug,$style(2)) Debug End:debug off
}

menu @sockread {
  Clear: clear
  -
  $iif(%debug,$style(2)) Debug Start: debug on
  $iif(!%debug,$style(2)) Debug End: debug off
}

menu query {
  Clear: clear
}

Related Files

by Vulcan
by 0rus & Rebe££e

Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand