mIRC Home    About    Download    Register    News    Help

Print Thread
[Twitch] Auto de-host ? #251356 16/02/15 12:50 PM
Joined: Nov 2013
Posts: 5
Atomic Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Joined: Nov 2013
Posts: 5
Hi everyone,

I need help with a script and have no clue where to start. I want to be able to auto de-host a channel when it goes offline. So for example after I end my stream I type /host <channel name> and when they go offline it will type /unhost. I guess with the API I could get it to check the status every 15~30 min, but as I said I have no clue where to start. Any and all help would be amazing.

Thankyou
Atomic

Re: [Twitch] Auto de-host ? [Re: Atomic] #251370 16/02/15 06:04 PM
Joined: Nov 2014
Posts: 79
N
Newbie Offline
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Do you keep mIRC online after you're done streaming?

Re: [Twitch] Auto de-host ? [Re: Newbie] #251374 16/02/15 06:57 PM
Joined: Nov 2013
Posts: 5
Atomic Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Joined: Nov 2013
Posts: 5
yes



Thanks
Atomicfirepit
Re: [Twitch] Auto de-host ? [Re: Atomic] #251382 17/02/15 02:51 AM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Well, you pretty much described how to do it by yourself laugh...

Make an alias consisting of an IF statement that checks the API if the stream is online. There are probably multiple things in it that will indicate it's offline. If it is offline, then msg # /dehost stream_name (or whatever the command is)

Then just put that alias on a timer

Re: [Twitch] Auto de-host ? [Re: Sakana] #251385 17/02/15 06:36 AM
Joined: Jan 2014
Posts: 101
M
Majeye Offline
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 101
Here is my code for an !uptime command. I'm sure you could modify it to do what you want.

Code:
on *:text:!uptime*:#:{
  if ((%flooduptime) || ($($+(%,flooduptime.,$nick),2))) { return }
  set -u5 %flooduptime On
  set -u10 %flooduptime. $+ $nick On
  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
  if ($1 isnum) && ($2) { msg %channel $upper(%target) has been online/streaming for $1- }
  elseif (%data == The channel is not live.) msg %channel $upper(%target) is currently not online/streaming.

}

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

Re: [Twitch] Auto de-host ? [Re: Majeye] #251386 17/02/15 08:03 AM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
This has bugged me for some time, why does everyone seem to use a 3rd party to read the api for an uptime command? Makes no sense.

Re: [Twitch] Auto de-host ? [Re: Belhifet] #251387 17/02/15 08:15 AM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Here, assuming you use the nice json parser
Code:
alias twitch_uptime {
  JSONOpen -ud Twitch_Uptime https://api.twitch.tv/kraken/streams/ $+ $mid($1,2)  
  return $json(Twitch_Uptime,stream,created_at)
}


You can $twitch_uptime(#channelname) and format the response however you like.

Re: [Twitch] Auto de-host ? [Re: Belhifet] #251389 17/02/15 09:54 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
That script is very old, and at the time when I made it I didn't have access to the current popular json parser Froggie made.
(Even if I'd have had one, I probably wouldn't know how to use it at the time... but let's keep that quiet)


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: [Twitch] Auto de-host ? [Re: Nillen] #251390 17/02/15 10:24 AM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Oh duh..Someone posted a piece of mirc code with the word twitch in it. Of course everyone uses it.

Re: [Twitch] Auto de-host ? [Re: Nillen] #251391 17/02/15 10:29 AM
Joined: Apr 2010
Posts: 938
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 938
At least its getting the mileage I hopped it would.

(I still have plans to update it to make error handling easier)

Last edited by FroggieDaFrog; 17/02/15 10:31 AM.

I am SReject
My Stuff
Re: [Twitch] Auto de-host ? [Re: FroggieDaFrog] #251392 17/02/15 10:32 AM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Its very handy. Json is so common now, its really nice to have a way to handle it. I wouldn't have been able to create that code myself.