I got it working by adding some variables. It works for being online for less than an hour and more than an hour, and for being offline without the message from nightdev.com.

Code:
  var %delmessage = $deltok($1-, 5-30, 32)
  var %online $remove(%delmessage,- Oh)


Code:
on *:text:!uptime*:#:{
  if (!$2) { set %target $remove($chan,$chr(35)) }
  else set %target $iif($2,$2,$mid(#,2-))
  set %channel #
  uptime
}

alias uptime {
  sockclose uptime
  sockopen uptime nightdev.com 80
}

on *:sockopen:uptime:{
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ %target HTTP/1.1
  sockwrite -n $sockname Host: www.nightdev.com 
  sockwrite -n $sockname $crlf
}

on *:sockread:uptime:{
  if ($sockerr) { sockclose $sockname | halt }
  var %data
  sockread %data
  tokenize 32 %data
  var %delmessage = $deltok($1-, 5-30, 32)
  var %online $remove(%delmessage,- Oh)
  if ($1 isnum) && ($2) { msg %channel %target has been online for %online }
  elseif (%data == The channel is not live. - Oh hey, you're using an API meant for Nightbot, not for whatever you're using. Maybe you'd want to try out the new Nightbot beta: https://beta.nightbot.tv) msg %channel %target is currently not online.
}

on *:sockclose:uptime:{ 
  unset %channel
  unset %target
}