mIRC Home    About    Download    Register    News    Help

Print Thread
#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

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Do you keep mIRC online after you're done streaming?

Joined: Nov 2013
Posts: 5
Atomic Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Joined: Nov 2013
Posts: 5
yes



Thanks
Atomicfirepit
Joined: Sep 2014
Posts: 259
S
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

Joined: Jan 2014
Posts: 107
M
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
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
}

Joined: Jun 2014
Posts: 248
B
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.

Joined: Jun 2014
Posts: 248
B
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.

Joined: Dec 2013
Posts: 779
N
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
Joined: Jun 2014
Posts: 248
B
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.

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
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
Joined: Jun 2014
Posts: 248
B
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.


Link Copied to Clipboard