All pastes #415589 Raw Edit

Something

public text v1 · immutable
#415589 ·published 2007-03-29 19:04 UTC
rendered paste body
alias UBW_DEFAULT       return I am the bone of my ¤n1¤.\¤n2¤ is my body, and ¤n3¤ is my blood.\I have ¤v4¤ over a thousand ¤n5¤.\Unknown to ¤n6¤.\Nor known to ¤n7¤.\Have withstood pain to ¤v8¤ many ¤n9¤.\Yet, these ¤n10¤ will never ¤v11¤ anything.\So as I pray, "Unlimited ¤n12¤ Works."
alias UBW_TOKENS        return n n n v n n n v n n v n
alias UBW_CHANS         return #machogang
alias UBW_TIMEOUT       return 4
alias UBW_DELAY_NICK    return 300
alias UBW_DELAY_GLOBAL  return 10
alias UBW_ENABLED       return 0

on *:text:!ubw*:$($UBW_CHANS): {
  if ($UBW_ENABLED == 1 && (%ubw_next <= $ctime || %ubw_next == $null)) {
    if ($eval($+(%,ubw_next_,$nick),2) <= $ctime || $eval($+(%,ubw_next_,$nick),2) == $null) {
      var %i = 1
      while (%i <= 12) {
        if ($eval($+($,$calc(%i + 1)),2) == $null) {
          set $+(%,word,%i) $null
        }
        else {
          set $+(%,word,%i) $eval($+($,$calc(%i + 1)),2)
        }
        inc %i
      }

      var %text = $ubw_translate( %word1 , %word2 , %word3 , %word4 , %word5 , %word6 , %word7 , %word8 , %word9 , %word10 , %word11 , %word12 )

      if (%ubw_inprog == 1) {
        .timer 1 $UBW_TIMEOUT ubw_domsg $chan $nick %text
        set %ubw_inprog 1
      }
    }
  }
}

on *:text:I am the bone of my*:$($UBW_CHANS): {
  if ($nick != $me) {
    set %ubw_other 1
    .timer 1 10 set %ubw_other 0
  }
}

alias ubw_domsg {
  if (%ubw_other == 1) {
    set %ubw_other 0
  }
  else {
    var %i = 1, %chan = $1, %nick = $2, %text = $3-

    set $+(%,ubw_next_,%nick) $calc($ctime + $UBW_DELAY_NICK)
    set %ubw_next $calc($ctime + $UBW_DELAY_GLOBAL)

    while (%i <= $gettok(%text,0,92)) {
      msg %chan $gettok(%text,%i,92)
      inc %i
    }
  }

  set %ubw_inprog 0
  ubw_unset
}

alias ubw_translate {
  var %i = 1, %word, %text = $UBW_DEFAULT

  while (%i <= 12) {
    %word = $null

    if ($eval($+($,%i),2) == $null) {
      %word = $read(ubw\ $+ $+($iif($gettok($UBW_TOKENS,%i,32) == n, nouns, verbs),.txt))
    }
    else {
      %word = $eval($+($,%i),2)
    }

    %text = $replace(%text,$+(¤,$gettok($UBW_TOKENS,%i,32),%i,¤),%word)
    inc %i
  }

  return %text
}

alias ubw_echo {
  var %i = 1
  while (%i <= 12) {
    if ($eval($+($,%i),2) == $null) {
      set $+(%,word,%i) $null
    }
    else {
      set $+(%,word,%i) $eval($+($,%i),2)
    }
    inc %i
  }

  var %text = $ubw_translate( %word1 , %word2 , %word3 , %word4 , %word5 , %word6 , %word7 , %word8 , %word9 , %word10 , %word11 , %word12 )

  %i = 1
  while (%i <= $gettok(%text,0,92)) {
    echo -a $gettok(%text,%i,92)
    inc %i
  }

  ubw_unset
}

alias ubw_unset {
  unset %word1 %word2 %word3 %word4 %word5 %word6 %word7 %word8 %word9 %word10 %word11 %word12
}