This is a quick edit of what I have written for my own bot, hopefully it helps you. You just need to change #channelname on line 1 with your own channel name. It should be noted that this script (and any scripts using Twitch API v3 or v5) will stop working on 12/31/18.

Required: JSON For mIRC

Code:
ON *:TEXT:!uptime:#channelname: {
  IF (!%CD_twitch_uptime) {
    SET -eu30 %CD_twitch_uptime $true
    IF ($get_twitch_uptime) MSG $chan Channel has been live for $v1 $+ .
    ELSE MSG $chan Channel is not live at the moment! (at least that's what the Twitch API is telling me)
  }
}

alias get_twitch_uptime {
  VAR %result
  JSONOpen -uw uptime https://api.twitch.tv/kraken/streams?channel= $+ $remove($chan,$chr(35)) $+ &nocache= $+ $ticks
  JSONHttpHeader uptime Client-ID avm4vi7zv0xpjkpi3d4x0qzk8xbrdw8
  JSONHttpFetch uptime
  VAR %result $json(uptime, streams, 0, created_at).value
  JSONClose uptime
  IF (%result) RETURN $duration($calc($ctime - $TwitchTime(%result)))
  RETURN $false
}

; TwitchTime alias written by SReject and friends
alias TwitchTime {
  if ($regex($1-, /^(\d\d(?:\d\d)?)-(\d\d)-(\d\d)T(\d\d)\:(\d\d)\:(\d\d)(?:(?:Z$)|(?:([+-])(\d\d)\:(\d+)))?$/i)) {
    var %m = $Gettok(January February March April May June July August September October November December, $regml(2), 32), %d = $ord($base($regml(3),10,10)), %o = +0, %t
    if ($regml(0) > 6) %o = $regml(7) $+ $calc($regml(8) * 3600 + $regml(9))
    %t = $calc($ctime(%m %d $regml(1) $regml(4) $+ : $+ $regml(5) $+ : $+ $regml(6)) - %o)
    if ($asctime(zz) !== 0 && $regex($v1, /^([+-])(\d\d)(\d+)$/)) {
      %o = $regml(1) $+ $calc($regml(2) * 3600 + $regml(3))
      %t = $calc(%t + %o )
    }
    return %t
  }
}

Last edited by Blas; 17/03/18 04:25 AM.