All pastes #629439 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-07-22 09:15 UTC
rendered paste body
alias realm-ip { return %realm.ip }
alias login-ip { return %login.ip }
alias login-port { return %login.port }
alias realm-port { return %realm.port }
;Basic configuration alias's, they return values.
alias setup-status {
  %realm.ip = $?="Please enter in the realm servers ip"
  %login.ip = $?="Please enter in the login servers ip"
  %realm.port = $?="Please enter in the realm servers port"
  %login.port = $?="Please enter in the login servers port"
  echo -a Status checking should now be set up
}
;Asks for a value, then once a user puts it in, it saves to that variable name

on *:load:{
  wow-config
}
alias status-check {
  if $realm-ip = $null { return }
  else {
    sockopen status_Realm $+ $ctime $realm-ip $realm-port
    sockopen status_login $+ $ctime $login-ip $login-port
  }
}
;opens up socket connections to the realm and login server
on *:sockopen:status_realm*: {
  if ($sockerr != 0) {
    ;If there is an error while connecting, we assume the server is down
    if (%wow.status != 4Offline) {
      ;ok, the server has just gone down, so lets set the time it went down, and tell everyone it died
      msg #global [Status]: The realm server is now 4offline 
      %realm.status.time = $ctime
      %wow.status = 4Offline
      ;Set the server status to down
    }
  }
  if (!$sockerr) {
    ;ok connection established fine, assuming server is online
    if (%wow.status != 3Online) {
      ;Server was down before, setting it to online now, all is well, letting everyone know
      msg #global [Status]: The realm server is now 3online 
      %realm.status.time = $ctime
      %wow.status = 3Online
    }
  }
  ;some thing weird happened, and neither event triggered. happens sometimes for some strange reason
  else { %wow.status = 8Unkown error }
  sockclose $sockname
  ;closed the socket, we dont want hundreds of connections open now do we 
}
;this is the same, its just for the login server
on *:sockopen:status_login*: {
  if ($sockerr > 0) && (%status.login != 4Offline) {
    msg #global [Status]: The login server is now 4offline 
    %login.status.time = $ctime
    %status.login = 4Offline
    halt
  }
  elseif (!$sockerr) && (%status.login != 3Online) { 
    msg #global [Status]: The login server is now 3online 
    %login.status.time = $ctime 
    %status.login = 3Online 
    halt
  }
  else { %status.login = 8Unkown error }
  sockclose $sockname
}