mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2015
Posts: 26
O
obee Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Jul 2015
Posts: 26
Hello, I'd like an automated message to be sent every hour or so that shows how long i've been streaming. This site connects to twitch's api i believe and should be able to extract the text and put it into a message.

https://decapi.me/twitch/uptime.php?channel=obeewnn
I would also like to have the uptime displayed on command, !uptime

This is another script I was using that didn't work out for me:

Code:
[script]
n0=; --- settings ------
n1=
n2=alias uptime_chan return obeewnn
n3=; change this to your twitch channel (without # in front of the name)
n4=; example: starladder5
n5=
n6=alias uptime_offline_info return 1
n7=; if you change the 1 to 0 then when the stream of the channel that you set is offline the bot will not give any uptime message.
n8=
n9=alias uptime_check_secs return 5400
n10=; change this if you want to increase/decrease the checking uptime for you channel.
n11=; 900 seconds = 10 minutes
n12=
n13=; --- end of settings ----
n14=
n15=ON *:CONNECT: { .timer[UPTIME] 0 $iif($uptime_check_secs,$v1,900) uptime }
n16=
n17=alias uptime {
n18=  sockclose uptime
n19=  sockopen uptime nightdev.com 80
n20=}
n21=
n22=ON *:SOCKOPEN:uptime: {
n23=  if ($sockerr) { sockclose $sockname | halt }
n24=  sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ $uptime_chan HTTP/1.1
n25=  sockwrite -n $sockname Host: $sock($sockname).addr
n26=  sockwrite -n $sockname $crlf
n27=}
n28=
n29=ON *:SOCKREAD:uptime: {
n30=  if ($sockerr) { sockclose $sockname }
n31=  var %data
n32=  sockread %data
n33=  if ($gettok(%data,1,32) isnum) && ($gettok(%data,2,32)) {
n34=    var %c = $chr(35) $+ $uptime_chan
n35=    if ($me !ison %c) { return }
n36=    .msg %c oBeE has been streaming for $qt(%data) $+ .
n37=  }
n38=  elseif (*not live.* iswm %data) {
n39=    if ($uptime_offline_info) {
n40=      var %c = $chr(35) $+ $uptime_chan
n41=      if ($me !ison %c) { return }
n42=      .msg %c The streaming is currently offline.
n43=    }
n44=  }
n45=}

Joined: Nov 2009
Posts: 295
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
I'll be happy to help out, I'll just need to know what the web api returns when a stream is happening. So if you could post the source of the webpage when a stream is running I can whip up a script.


http://scripting.pball.win
My personal site with some scripts I've released.
Joined: May 2015
Posts: 249
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249


Dont give a fish - teach to fish!
Joined: Nov 2009
Posts: 295
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
Thanks splinny for the other link.

obee I couldn't get the website you posted to return a result, don't know if it's the https or what. So I used the website the script you posted uses. When you join your channel the script will check every hour and post saying you aren't streaming or how long you've been streaming.

Code:
on *:join:#pball: .timertuptime 0 3600 tuptime
on *:part:#pball: .timertuptime off

alias tuptime {
  sockopen tuptime nightdev.com 80
}

on *:sockopen:tuptime: {
  sockwrite -nt $sockname GET /hosted/uptime.php?channel=obeewnn HTTP/1.1
  sockwrite -nt $sockname Host: nightdev.com
  sockwrite -n $sockname 
}

on *:sockread:tuptime: {
  sockread %tuptime.result
  while ($sockbr) {
    if (not live isin %tuptime.result) msg #pball The streaming is currently offline.
    elseif (minute isin %tuptime.result) msg #pball oBeE has been streaming for %tuptime.result
    sockread %tuptime.result
  }
}



http://scripting.pball.win
My personal site with some scripts I've released.
Joined: Jul 2015
Posts: 26
O
obee Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Jul 2015
Posts: 26
Awesome thanks pball. would you be able to add !uptime command on top of the 60 minute timer?

Joined: Nov 2009
Posts: 295
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
Done and there is a 10 second cool down period to stop trigger spam.

Code:
on *:join:#pball: .timertuptime 0 3600 tuptime
on *:part:#pball: .timertuptime off

on *:text:!uptime:#pball: tuptime

alias tuptime {
  if (%tuptimespam) halt
  else set -u10 %tuptimespam 1
  sockopen tuptime nightdev.com 80
}

on *:sockopen:tuptime: {
  sockwrite -nt $sockname GET /hosted/uptime.php?channel=obeewnn HTTP/1.1
  sockwrite -nt $sockname Host: nightdev.com
  sockwrite -n $sockname 
}

on *:sockread:tuptime: {
  sockread %tuptime.result
  while ($sockbr) {
    if (not live isin %tuptime.result) msg #pball The streaming is currently offline.
    elseif (minute isin %tuptime.result) msg #pball oBeE has been streaming for %tuptime.result
    sockread %tuptime.result
  }
}



http://scripting.pball.win
My personal site with some scripts I've released.
Joined: Jul 2015
Posts: 26
O
obee Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Jul 2015
Posts: 26
I tested !uptime and it didn't say stream is offline. I have yet to test it when I'm live, but it should work when I'm offline right?

Joined: Nov 2009
Posts: 295
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
Did you try the !uptime trigger from the same mirc you have the script loaded on? It will only work when someone else types it.

If you add this to the script it will respond when you type the command.

Code:
on *:input:*: if (!$ctrlenter) && (!$inpaste) && ($left($1,1) != $readini(mirc.ini,text,commandchar) || $1 != /msg || $1 != /me) && ($1 == !uptime) tuptime



http://scripting.pball.win
My personal site with some scripts I've released.
Joined: Jul 2015
Posts: 26
O
obee Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Jul 2015
Posts: 26
Awesome PBall another great script!!!


Link Copied to Clipboard