mIRC Home    About    Download    Register    News    Help

Print Thread
#256206 29/12/15 07:11 PM
Joined: Jun 2015
Posts: 84
F
Babel fish
OP Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
This one is hard to explain for me.
I want to run something in multiple channels.

I have a timer list that'd activate on load or on connect (if a disconnect happens).

Code:
on *:LOAD: {
  timer_streamStatus 0 120 streamStatus
}

on *:CONNECT: {
  timer_streamStatus 0 120 streamStatus
}


I have an alias I'd want to use for all channels I'm joined up with, but would like to manage the variables properly.

Code:
alias streamStatus {
  var %j = streamStat
  JSONOpen -u %j https://api.twitch.tv/kraken/streams/ $+ $mid(#,2) $+ ?= $+ $rand(1,1000000)
  var %status = $json(%j,status)
  if (%status == $null) {
    set %status_ [ $+ [ $mid(#,2) ] ] Offline
  }
  else {
    set %status_ [ $+ [ $mid(#,2) ] ] Online
  }
  JSONClose %j
}


Is there a way to make it where it would check all channels I'm joined on?

Just needing a nudge in the right direction.

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Try to use this code (remove the old) :

Code:
alias streamstatus {
  if (!$1) { return }
  if ($me !ison $1) { return }
  var %j = stream_ $+ $ticks $+ $ctime
  JSONOpen -ud %j https://api.twitch.tv/kraken/streams/ $+ $mid($1,2) $+ ?= $+ $ticks
  var %status = $json(%j,status)
  if (!%status) { set %status_ [ $+ [ $mid($1,2) ] ] Offline }
  else { set %status_ [ $+ [ $mid($1,2) ] ] Online }
}

ON *:JOIN:#: {
  if ($nick == $me) { .timer[STREM_CHECK_ $+ $chan $+ ] 0 120 streamstatus $chan | streamStatus $chan }
}

Last edited by westor; 29/12/15 07:25 PM.

Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Jun 2015
Posts: 84
F
Babel fish
OP Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
I got it to make a %status_ $+ $mid(#,2)
Yet it comes up always offline, even with a confirmed online channel I'm in.

Joined: Sep 2014
Posts: 52
Babel fish
Offline
Babel fish
Joined: Sep 2014
Posts: 52
You are checking for something that is not there. Replace:
Code:
var %status = $json(%j,status)

with:
Code:
var %status = $json(%j,stream,_id)

If _id exists, then the stream is online, otherwise it is offline.

Joined: Jun 2015
Posts: 84
F
Babel fish
OP Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
Indeed I am.
I keep making these overly simple errors and not even noticing.

Thanks to both of you for pointing out my flaws there and helping me fix them.

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
He asked about the multichannel so i re-wrote it supporting multichannels i didn't saw the other if is vaild and i didn't tested.


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Jun 2015
Posts: 84
F
Babel fish
OP Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
It's fine westor, you helped me get the multi-channel part working and paper0rplastic helped me fix the JSON part I overlooked.

I very much appreciate the help.


Link Copied to Clipboard