mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2014
Posts: 8
M
MsDiz Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Oct 2014
Posts: 8
I'm trying to get an !uptime command running and it seems to work, except that it adds 4 hours to the uptime, consistently. If I pull the time directly from $ctime it is correct so I am just super confused. Any help please?

on *:text:!uptime:#:{
var %diff = $calc($ctime - %starttime)
var %format = $asctime(%diff, hh:nn:ss)
msg # the stream started %format
}

on *:text:!start:#: {
if ($nick isin $read(mod.txt, w, $nick)) {
set %starttime $ctime
msg $chan The stream start has been set
}
else {
msg $chan I'm sorry $nick $+ , I'm afraid I can't do that (Mod Command)
}
}


Total n00b smirk
Joined: Jun 2015
Posts: 84
F
Babel fish
Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
Hmm, I don't understand what's happening, though why not use the time generated via Twitch's API?

This is the code for my !uptime that I use.

Code:
 on *:text:!uptime*:#: {
  if (%flood_Uptime) && ($nick != $mid(#,2)) { halt }
  set -u30 %flood_Uptime On
  if ($0 == 2) {
    var %status = $startTime($2)
    var %displayName = $displayName($2)
    var %game = $followGame($2)
    if (%status == $null) {
      msg # /me - %displayName is currently offline.
    }
    else {
      msg # /me - %displayName $+ 's stream has been online with " $+ %game $+ " for $duration($calc($ctime - (%status - $timezone))) $+ !
    }
  }
  if ($0 == 1) {
    var %status = $startTime($mid(#,2))
    var %displayName = $displayName($mid(#,2))
    if (%status == $null) {
      msg # /me - %displayName is offline.
    }
    else {
      msg # /me - We've been live for $duration($calc($ctime - (%status - $timezone))) $+ !
    }
  }
}

alias startTime {
  var %j = streamUptime
  JSONOpen -ud %j https://api.twitch.tv/kraken/streams/ $+ $1 $+ ?= $+ $ticks
  var %uptime = $ctime($replace($json(%j,stream,created_at),T,$chr(32),Z,))
  return %uptime
}


This uses SReject's JSON Parser. Found here.

Returns are usually like this

<@fonic_artes> !uptime
> If Offline
<@bot> /me - Fonic_Artes is offline.
> If Online
<@bot> /me - We've been live for 8hrs 27mins 15secs!

<@fonic_artes> !uptime artesbot
> If Offline
<@bot> /me - Artesbot is currently offline.
> If Online
<@bot> /me - Artesbot's stream has been online with "Final Fantasy IV" for 1day 4hrs 13mins 59secs!


Link Copied to Clipboard