mIRC Home    About    Download    Register    News    Help

Print Thread
[Twitch] Bot reacts to stream status. #259716 16/01/17 06:45 PM
Joined: Sep 2016
Posts: 11
P
Pie Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: Sep 2016
Posts: 11
Hi there,

I was wondering if mIRC could react to the stream status, i.e: stream being online or offline.

I'd like to have it send a message to the channel when the stream goes online, and offline.

I.e:
(Stream online) Hi Streamer, Good to have you back!

(Stream offline) See you again tomorrow!

If anyone could help me out with this, I'd appreciate it a lot! laugh

Re: [Twitch] Bot reacts to stream status. [Re: Pie] #259717 16/01/17 07:58 PM
Joined: Apr 2010
Posts: 910
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 910
AFAIK, twitch doesn't tell chat when the stream goes online/offline.

You'd have to poll twitch's api for changes


I am SReject
My Stuff
Re: [Twitch] Bot reacts to stream status. [Re: FroggieDaFrog] #259718 16/01/17 08:09 PM
Joined: Sep 2016
Posts: 11
P
Pie Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: Sep 2016
Posts: 11
Yea i figured.
I couldn't find anything in the raw data as well so i guess i'll have to see how to pull data from the API with mIRC.

Thanks though! smile

Re: [Twitch] Bot reacts to stream status. [Re: Pie] #259719 16/01/17 08:37 PM
Joined: Feb 2015
Posts: 243
O
OrFeAsGr Offline
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
http://forums.mirc.com/ubbthreads.php/topics/254744/Re:_Command_for_making_bot_ret#Post254744
Check this post out.

Re: [Twitch] Bot reacts to stream status. [Re: OrFeAsGr] #259720 16/01/17 09:12 PM
Joined: Sep 2016
Posts: 11
P
Pie Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: Sep 2016
Posts: 11
Originally Posted By: OrFeAsGr
http://forums.mirc.com/ubbthreads.php/topics/254744/Re:_Command_for_making_bot_ret#Post254744
Check this post out.


That would output the text on that given website.
If im right, I cant modify the output of that which is what i would want.

I could be wrong ofcourse :P

Re: [Twitch] Bot reacts to stream status. [Re: Pie] #259721 16/01/17 10:08 PM
Joined: Feb 2015
Posts: 243
O
OrFeAsGr Offline
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Hey i was bored so i checked this out and edited a bit for you.
All you have to do is load this on mIRC and input your channel name where it says INPUT_CHAN_HERE
The script will start checking for stream state when mIRC starts and you can also use /decapi to toggle the checking on or off.
Code:
alias livestream {
  sockopen -e decapi decapi.me 443
}


alias decapi {
  if ($timer(decapi).secs) { .timerdecapi off | echo -at The Stream Checker is now off }
  elseif (!$timer(decapi).secs) { .timerdecapi 0 200 livestream | echo -at The Stream Checker is now on }
}

alias mytchan { return INPUT_CHAN_HERE }

on *:SOCKOPEN:decapi: {
  sockwrite -nt $sockname GET $+(/twitch/uptime.php?channel=,$mytchan) HTTP/1.1
  sockwrite -nt $sockname Host: decapi.me
  sockwrite $sockname $crlf
}

on *:SOCKREAD:decapi: {
  var %decapi
  sockread %decapi
  while ($sockbr) {
    sockread %decapi
  }
}

on *:sockclose:decapi: {
  var %decapi
  sockread -f %decapi
  if (*not live* iswm %decapi) {
    if (!%streamisoff) {
      set -e %streamisoff 1
      msg $+($chr(35),$mytchan) Stream is now off...
      unset %streamison
    }
  }
  else { 
    if (!%streamison) {
      set -e %streamison 1
      msg $+($chr(35),$mytchan) Stream is now on!
      unset %streamisoff
    }
  }
}


ON *:START: { .timerdecapi 0 200 livestream }

I tested it and it works! smile
Enjoy!

Re: [Twitch] Bot reacts to stream status. [Re: OrFeAsGr] #259724 17/01/17 05:40 PM
Joined: Sep 2016
Posts: 11
P
Pie Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: Sep 2016
Posts: 11
Holy crap! That's really generous of you! shocked

Im gonna put this to the test today, But i'll take your word for it that it will work! grin

Thank you so much! Saves me a bit of a headache whistle
Really appreciate it! blush

EDIT: Yep, It works perfectly! laugh
I assume setting the timer to 0 60 wont be too much of a problem, Right?

Thank you again!

Last edited by Pie; 17/01/17 05:51 PM.