All pastes #440418 Raw Edit

Blinkenlights

public text v1 · immutable
·published 2007-04-15 00:50 UTC
rendered paste body
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    I'm not responsible (with what you do with this)   ;;
;;     The Beekins will kill me for this. It's okay.     ;;
;;             Blinkenlights v0.0.0.0.0.1-m              ;;
;;               Free for everyone to use.               ;;
;;                     Love, Kawinma.                    ;;
;;                       Backend                         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Use an alias to open the socket for easy access

alias furc.sopen {
  ;; Yes, we're using the good port, sorry. You can change it here, though.
  sockopen a lightbringer.furcadia.com 80
  timer 1 3 furccmd init
}

;; Use a simple way to send commands to all the bots.

alias furccmd {
  if ($1 == move) { sockwrite -n a m $2 }
  if ($1 == whis) { sockwrite -n a wh $2 $3- }
  if ($1 == asay) { sockwrite -n a " $+ $2- }
  if ($1 == actn) { sockwrite -n a ; $+ $2- }
  if ($1 == sraw) { sockwrite -n a $2- }
  if ($1 == gfdl) { sockwrite -n a fdl furc:// $+ $2- | sockwrite -n a vascodagama }
  if ($1 == gmap) { sockwrite -n a gomap $2- | sockwrite -n a vascodagama }
  if ($1 == init) { 
    sockwrite -n a iamhere
    sockwrite -n a connect Blinkenlights facesplaces
    sockwrite -n a color t88*=*:::::%##
    sockwrite -n a desc .
    sockwrite -n a vascodagama
    sockwrite -n a wh Kawinma iah
  }
}

;; Clean up after ourselves

alias furclnslf { 
  unset %furc.read.tmp
  unset %furc.parse.tmp
  unset %furc.cmd.tmp
}

;; Parse any information to see if our admin commanding us.

on 1:sockread:a:{
  if ($sockerr) { echo Blinkenlights error - mIRC decided to slit. | halt }
  else {
    var %furc.read.tmp
    sockread %furc.read.tmp
    ;; Let's see first if our admin whispered us.
    if (<font color='whisper'> isin %furc.read.tmp) { 
      set %furc.parse.tmp %furc.read.tmp
      set %furc.cmd.tmp $remove(%furc.parse.tmp,<font color='whisper'>,[ <name shortname=',' src='whisper-from'>,</name> whispers,",,to you. ]</font>)
      did -a furc.ctrl 9 WH: %furc.cmd.tmp
    furcparsexec %furc.cmd.tmp }
    ;; Let's check if someone summmoned us?
    elseif (join isin %furc.read.tmp) {
      set %furc.parse.tmp %furc.read.tmp
    furcparsumn %furc.parse.tmp }
    ;; And moreover, if someone wants to lead us
    ;; Also, check to see if we're in chain mode to automatically let people lead us
    elseif (lead isin %furc.read.tmp) {
      if (%followchain == 1) { furccmd sraw follow }
      elseif (Kawinma isin %furc.read.tmp) { furccmd sraw follow }
    }
    else { halt } 
  }
}

;; Parse aliases, we're using specific code for each as not to complicate things

alias furcparsumn {
  if (Kawinma isin $1-) {
    furccmd sraw join
  furccmd sraw vascodagama }
}

alias furcparsexec {
  if (kawinmaKawinma isin $1) { 
    furccmd $2-
  furclnslf }
}