on *:TEXT:!uptime*:#: {
var %json = streamuptime, %stream = $iif(#* iswm $iif($2,$2,#), $mid($v2, 2-), $v2), %time
jsonopen -ud %json https://api.twitch.tv/kraken/streams?channel= $+ $lower(%stream)
if ($JSONError) {
msg # Unable to retrieve the state of %stream
}
elseif ($regex($JSON(%json, streams, 0, created_at), /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/)) {
%time = $calc($ctime($+($gettok(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec, $regml(2), 32) $ord($base($regml(3), 10, 10)), $chr(44) $regml(1) $regml(4), :, $regml(5), :, $regml(6))) + ( $time(z) * 3600))
msg # %stream has been online for $duration(%time)
}
else {
msg # %stream is currently not online.
}
}