All pastes #274751 Raw Edit

Seykron

public text v1 · immutable
·published 2006-12-10 23:03 UTC
rendered paste body
alias /notifyhdr {

  ;
  ; Notifies handler
  ;
  var %notifycnt = $readini(%se_configfile, notify, 0)
  var %notiftype = $null, %notifname = $null
  var %sline = $null, %snet = $null
  var %snotiflst = $null, %snotifitem = $null
  var %i = 1, %ind = 1
  var %seccnt = $null, %iexist = 0

  ;
  ; $1 = { get; check; type; add; del; count }, $2 = $network, $3 = $nick / ID
  ;

  while (%i <= %notifycnt) {
    ;
    ; Lee la lista de Notify
    ;
    %sline = $readini(%se_configfile, notify, %i)

    %snet = $gettok(%sline, 1, 33)

    if ( $2 == %snet ) {
      %snotiflst = $gettok(%sline, 2, 33)
      %iexist = %i

      ;
      ; Recorre la lista de notify.
      ;
      %seccnt = $numtok(%snotiflst, 59)

      if ( $1 == count ) { return %seccnt }

      while (%ind <= %seccnt) {
        %snotifitem = $gettok( %snotiflst, %ind, 59 )
        %notifname = $gettok( %snotifitem, 1, 58 )
        %notiftype = $gettok( %snotifitem, 2, 58 )

        if ( ($1 == get) && (%ind == $3) ) {
          ;
          ; Devuelve el nombre de un user de la lista.
          ;
          return %notifname
        }
        elseif ( ($1 == check) && ($3 == %notifname) ) {
          ;
          ; Devuelve 1 si el usuario especidicado existe en la lista.
          ;
          return 1
        }
        elseif ( ($1 == type) && (($3 == %ind) || ($3 == %notifname)) ) {
          ;
          ; Devuelve el tipo de usuario.
          ;
          if (%notiftype == 0) {
            return lord
          }
          else {
            return miss
          }
        }
        elseif ( ($1 == del) && ($3 == %notifname) ) {
          %snotiflst = $remtok(%snotiflst, %snotifitem, 1, 59)
          %snotiflst = %snet $+ ! $+ %snotiflst

          writeini %se_configfile notify %i %snotiflst

          if ( $5 == 1 ) {
            if ( %notiftype == 0) {
              %notiftype = Miss
            }
            else {
              %notiftype = Lord
            }

            echo 7 $chan * %notiftype $3 ha sido exiliado del clan.
          }

          return 1
        }
        elseif ( ($1 == add) && ($3 == %notifname) ) {
          %iexist = 1337
        }

        inc %ind

      }
    }

    inc %i
  }

  if ($1 = add) {

    if ( ($4 == $null) || ($4 == miss) || ($4 == 0) ) {
      %snotifitem = $3 $+ :1
      %notiftype = Miss
    }
    else {
      %snotifitem = $3 $+ : $+ $4
      %notiftype = Lord
    }

    if ( %iexist == 1337 ) {
      if ( $5 == 1) { echo 7 $chan * %notiftype $3 ya es miembro ilustre del clan. }

      return 0
    }

    if ( %iexist == 0 ) {
      ;
      ; La red no existe en la lista, así que la agrega.
      ;
      %snotiflst = $2 $+ ! $+ $3 $+ : $+ $4
      %iexist = %i

      if ( %iexist >= 1337 ) echo 7 -a * Che, q´ onda vo´ locoouuu, recatate´, anda´ en mucha rede´ vo´ viteh | return 0

      writeini %se_configfile notify 0 %iexist

    }
    else {
      ;
      ; Agrega el user de la red ya existente.
      ;
      %snotiflst = $addtok(%snotiflst, %snotifitem, 59 )
      %snotiflst = %snet $+ ! $+ %snotiflst
    }

    if ( $5 == 1 ) {
      echo 7 $chan * %notiftype $3 ha sido nombrado nuevo miembro del clan.
    }

    writeini %se_configfile notify %iexist %snotiflst
    return 1

  }

  return 0
}