mIRC Homepage

[help] Twitch !uptime script

Posted By: Ryntovy

[help] Twitch !uptime script - 01/03/18 07:39 PM


I have been looking for a working !uptime script for a while now and I tried to make one myself but without succes.
Unfortunatly I cannot find a good script that is working correctly and that is mIRC based only.
This forum is potentially my last chance at achieving this goal.

So my question is, do you have a !uptime script that is working or are you able to write one? smile

The script should respond to !uptime with either:
"Channel" has been live for x hours, x minutes
"Channel" is not live.

Thank you very much for reading this.

With kind regards,
Posted By: KubosKube

Re: [help] Twitch !uptime script - 03/03/18 01:46 PM

I've never gotten this to work(Because I'm bad at sockets) but here's a really simple link that displays the uptime of a channel.


It makes a plain-text webpage that only contains the time that the channel has been live for.

It will either say
4 hours and 56 minutes
channelname is offline

So once you figure out how to read the sockets from decapi.me, you can format it however you like.
Posted By: Ryntovy

Re: [help] Twitch !uptime script - 17/03/18 12:09 AM

I don't know how to do that frown
Posted By: Blas

Re: [help] Twitch !uptime script - 17/03/18 04:24 AM

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

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
Posted By: Ryntovy

Re: [help] Twitch !uptime script - 17/03/18 03:56 PM

It's working, thank you! laugh
© 2020 mIRC Discussion Forums