mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2018
Posts: 23
R
Ryntovy Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2018
Posts: 23
Hello,

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
or
"Channel" is not live.

Thank you very much for reading this.

With kind regards,
Ry

Joined: Jan 2017
Posts: 57
Babel fish
Offline
Babel fish
Joined: Jan 2017
Posts: 57
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.

https://decapi.me/twitch/uptime?channel=CHANNELNAME

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
or
channelname is offline

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

Joined: Jan 2018
Posts: 23
R
Ryntovy Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2018
Posts: 23
I don't know how to do that frown

Joined: Oct 2015
Posts: 112
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
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.
Joined: Jan 2018
Posts: 23
R
Ryntovy Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2018
Posts: 23
It's working, thank you! laugh


Link Copied to Clipboard