All pastes #373295 Raw Edit

Untitled

public text v1 · immutable
#373295 ·published 2007-02-26 18:27 UTC
rendered paste body
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Support script version 1.0 ;;
;; - By skauert © 2007        ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


; SETUP - Change variables
; ------------------------

alias hqsetup {
  ; Enable script
  set %hqon 1

  ; Channel
  set %hqchannel #support

  ; Command char
  set %hqcommand .

  ; Remove from queue if kicked
  set %hqkick 0

  ; Notice when moved up in queue
  set %hqnotice 1
}


; REMOTE COMMANDS
; ---------------

on *:notice:$(%hqcommand $+ help):?: {
  if (%hqon == 1) {
    if ($hqcheck($nick) == 0) {
      hqueue $nick
    }
  }
}

on *:text:$(%hqcommand $+ *):%hqchannel: {
  if (%hqon == 1) {
    var %cmd = $mid($$1, 2)

    if (%cmd == next) {
      if ($nick isop %hqchannel) {
        hqnext
      }
    }
  }
}

on *:nick: {
  if (%hqon == 1) {
    if ($hqcheck($nick) == 1) {
      hqchange $nick $newnick
    }
  }
}

on *:quit: {
  if (%hqon == 1) {
    if ($hqcheck($nick) == 1) {
      hqdel $nick
    }
  }
}

on *:part:%hqchannel: {
  if (%hqon == 1) {
    if ($hqcheck($nick) == 1) {
      hqdel $nick
    }
  }
}

on *:kick:%hqchannel: {
  if (%hqon == 1) {
    if ($hqcheck($knick) == 1 && %hqkick == 1) {
      hqdel $knick
    }
  }
}


; ALIASES
; -------

alias hqueue {
  var %nick = $$1

  if ($hqcheck(%nick) == 0) {
    if (%hqnum == $null) {
      %hqnum = 0
    }

    inc %hqnum
    set %hq- [ $+ [ %hqnum ] ] %nick
    .notice %nick You are now number %hqnum in the queue.
    msg %hqchannel %nick has requested help and is number %hqnum in the queue.
  }
}

alias hqnext {
  if (%hqnum == 0) {
    if (%hqcur isvoice %hqchannel) { 
      mode %hqchannel -v %hqcur
    }

    unset %hqcur
    msg %hqchannel Queue is empty.
  }
  else {
    set %hqcur %hq-1
    hqdel %hq-1

    if (%hqcur !ison %hqchannel) {
      msg %hqchannel %hqcur is up next but is not present in the channel.
    }
    else {
      mode %hqchannel +v %hqcur
      msg %hqchannel Next up is %hqcur $+ .
      .notice %hqcur You are now free to state your question.
    }
  }
}

alias hqcheck {
  var %nick = $$1
  var %i = 1

  while (%i <= %hqnum) {
    if ($eval($+(%,hq-,%i),2) == %nick) {
      return 1
    }

    inc %i
  }

  return 0
}

alias hqdel {
  var %nick = $$1
  var %i = 1

  while (%i <= %hqnum) {
    if ($eval($+(%,hq-,%i),2) == %nick) {
      var %j = %i
      while (%j <= %hqnum) {
        set %hq- [ $+ [ %j ] ] $eval($+(%,hq-,$calc(%j + 1)),2)

        if (%hqnotice == 1) {
          if (%j != %hqnum) {
            .notice $eval($+(%,hq-,%j),2) You have moved up to number %j in the queue.
          }
        }

        inc %j
      }

      unset %hq- [ $+ [ %hqnum ] ]
      dec %hqnum

      break
    }

    inc %i
  }
}

alias hqchange {
  var %nick = $$1
  var %newnick = $$2
  var %i = 1

  while (%i <= %hqnum) {
    if ($eval($+(%,hq-,%i),2) == %nick) {
      %hq- [ $+ [ %i ] ] = %newnick
    }

    inc %i
  }
}