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 ($JSON(%json, streams, 0, created_at)) {
%time = $ctime($remove($replace($v1,T,$chr(32)),Z))
msg # %stream has been online for $duration($calc($gmt - %time))
}
else {
msg # %stream is currently not online.
}
}