mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Re: !uptime command [Re: Sissou] #256596 31/01/16 10:11 AM
Joined: Oct 2015
Posts: 112
B
Blas Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
I find this is easier by using SReject's JSON script. I had to edit his code found here in order to have it work properly for me.

Code:
ON *:TEXT:!uptime*:#: {
  VAR %stream $IIF($2,$2,$remove(#,$chr(35)))
  jsonopen -ud uptime https://api.twitch.tv/kraken/streams/ $+ %stream
  IF ($JSONError) MSG $chan Error.
  ELSEIF ($regex($JSON(uptime, stream, created_at), /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/)) MSG $chan %stream has been streaming for $duration($calc($ctime - ($ctime($gettok(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec, $regml(2), 32) $regml(3) $regml(1) $regml(4) $+ : $+ $regml(5) $+ : $+ $regml(6)) - 18000)),2) $+ .
  ELSE MSG $chan %stream is not online.
}

Re: !uptime command [Re: Khonor] #256597 31/01/16 11:49 AM
Joined: Jan 2016
Posts: 79
X
x3pos Offline
Babel fish
Offline
Babel fish
X
Joined: Jan 2016
Posts: 79
Code:
on *:text:!uptime*:#:{
if (!$2) { set %target $remove($chan,$chr(35)) }
else set %target $iif($2,$2,$mid(#,2-))
set %channel #
uptime
}

alias uptime {
sockclose uptime
sockopen uptime nightdev.com 80
}

on *:sockopen:uptime:{
if ($sockerr) { sockclose $sockname | halt }
sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ %target HTTP/1.1
sockwrite -n $sockname Host: www.nightdev.com 
sockwrite -n $sockname $crlf
}

on *:sockread:uptime:{
if ($sockerr) { sockclose $sockname | halt }
var %data
sockread %data
tokenize 32 %data
var %delmessage = $deltok($1-, 5-30, 32)
var %online $remove(%delmessage,- Oh)
if ($1 isnum) && ($2) { msg %channel $nick %target has been online for %online }
elseif (%data == $nick The channel is not live. - Oh hey, you're using an API meant for Nightbot, not for whatever you're using. Maybe you'd want to try out the new Nightbot beta: https://beta.nightbot.tv) msg %channel %target is currently not online.
}

on *:sockclose:uptime:{ 
unset %channel
unset %target
}


Code:
add "$nick" but channelbot saying this;
channelbot streamer has been online for 4 minutes 4 seconds.

Last edited by x3pos; 31/01/16 11:49 AM.
Re: !uptime command [Re: x3pos] #256598 31/01/16 05:20 PM
Joined: Feb 2015
Posts: 19
Y
Y4kuzi Offline
Pikka bird
Offline
Pikka bird
Y
Joined: Feb 2015
Posts: 19
$nick does not evaluate inside a sockread.


ProvisionIRCd - advanced mIRC based IRC daemon.
http://www.provisionircd.tk
Page 2 of 2 1 2