mIRC Homepage

!uptime command

Posted By: Khonor

!uptime command - 18/06/15 02:39 AM

I have this script and I was wondering if someone could help me, because from one moment to the other I leave to function the command and not know why.





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 %target has been online for $1- }
elseif (%data == The channel is not live.) msg %channel %target is currently not online/streaming.

}

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


Any help is appreciated!
Posted By: westor

Re: !uptime command - 18/06/15 10:35 PM

Try use this code: http://hawkee.com/snippet/16314/
Posted By: Khonor

Re: !uptime command - 20/06/15 11:22 PM

If I seen this script but I need for multiple channels.
Posted By: Khonor

Re: !uptime command - 21/06/15 02:28 AM

I have this script that is yours and it works very well, but need to work on multiple channels, you can do?

PS: And in the part where it says: "The streaming is currently offline." He it repeats twice in chat.



alias uptime_chan return

ON *:TEXT:!uptime:#: {
var %c = $chr(35) $+ $uptime_chan
if (%c == $chan) { 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= $+ $uptime_chan HTTP/1.1
sockwrite -n $sockname Host: $sock($sockname).addr
sockwrite -n $sockname $crlf
}

ON *:SOCKREAD:uptime: {
if ($sockerr) { sockclose $sockname }
var %data
sockread %data
if ($gettok(%data,1,32) isnum) && ($gettok(%data,2,32)) {
var %c = $chr(35) $+ $uptime_chan
if ($me !ison %c) { return }
.msg %c The streaming is up for $qt(%data) $+ .
}
elseif (*not live.* iswm %data) {
var %c = $chr(35) $+ $uptime_chan
if ($me !ison %c) { return }
.msg %c The streaming is currently offline.
}
}
Posted By: westor

Re: !uptime command - 21/06/15 02:35 AM

Try use this code:

Code:
ON *:TEXT:!uptime:#: { 
  var %s = uptime_ $+ $ticks $+ $rand(1,10000)
  sockopen %s nightdev.com 80
  sockmark %s $mid($chan,2-)
}

ON *:SOCKOPEN:uptime_*: {
  if ($sockerr) { sockclose $sockname | return }
  sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ $sock($sockname).mark HTTP/1.1
  sockwrite -n $sockname Host: $sock($sockname).addr
  sockwrite -n $sockname $crlf
}

ON *:SOCKREAD:uptime_*: {
  if ($sockerr) { sockclose $sockname | return }
  var %data
  sockread %data
  if ($gettok(%data,1,32) isnum) && ($gettok(%data,2,32)) {
    var %c = $chr(35) $+ $sock($sockname).mark
    if ($me !ison %c) { return }
    .msg %c The streaming is up for $qt(%data) $+ .
  }
  elseif (*not live.* iswm %data) {
    var %c = $chr(35) $+ $sock($sockname).mark
    if ($me !ison %c) { return }
    .msg %c The streaming is currently offline.
  }
}
Posted By: Khonor

Re: !uptime command - 21/06/15 02:57 AM

It does not work. [img]http://prntscr.com/7jfgoq[/img] cry
Posted By: westor

Re: !uptime command - 21/06/15 03:41 AM

Of course and is working, probably you did something wrong on copy/paste, or you had place it into an wrong place.

Paste the code into the Remotes tab into the Script Editor into a new file and try again.
Posted By: Khonor

Re: !uptime command - 21/06/15 03:50 AM

I do not change anything. [img]http://prntscr.com/7jfthz[/img]
Posted By: westor

Re: !uptime command - 21/06/15 04:12 AM

If you are not getting any command response thats not code fault but you have probably did not add support for CAP (new twitch protocol) so try use this code:

NOTE: After you paste the code, restart the bot to apply.

Code:
ON *:TEXT:!uptime:#: { 
  var %s = uptime_ $+ $ticks $+ $rand(1,10000)
  sockopen %s nightdev.com 80
  sockmark %s $mid($chan,2-)
}

ON *:SOCKOPEN:uptime_*: {
  if ($sockerr) { sockclose $sockname | return }
  sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ $sock($sockname).mark HTTP/1.1
  sockwrite -n $sockname Host: $sock($sockname).addr
  sockwrite -n $sockname $crlf
}

ON *:SOCKREAD:uptime_*: {
  if ($sockerr) { sockclose $sockname | return }
  var %data
  sockread %data
  if ($gettok(%data,1,32) isnum) && ($gettok(%data,2,32)) {
    var %c = $chr(35) $+ $sock($sockname).mark
    if ($me !ison %c) { return }
    .msg %c The streaming is up for $qt(%data) $+ .
  }
  elseif (*not live.* iswm %data) {
    var %c = $chr(35) $+ $sock($sockname).mark
    if ($me !ison %c) { return }
    .msg %c The streaming is currently offline.
  }
}

ON *:CONNECT: {
  if ($server == tmi.twitch.tv) {
    /raw CAP REQ :twitch.tv/membership
    /raw CAP REQ :twitch.tv/commands
  }
}
Posted By: Khonor

Re: !uptime command - 21/06/15 03:03 PM

It does not work, do not understand why this does not work and the other happens to the principle itself.
Posted By: westor

Re: !uptime command - 21/06/15 04:12 PM

I cannot understand why is not working into your bot, i had try it 100 times and everything working..
Posted By: Khonor

Re: !uptime command - 21/06/15 10:25 PM

I do not understand because they do not work, but if I use your other script that is only for my channel if it works.
Posted By: westor

Re: !uptime command - 21/06/15 10:30 PM

Give a try this one:

Code:
ON *:TEXT:!uptime:#: { 
  var %s = uptime_ $+ $ticks $+ $rand(1,10000)
  sockopen %s nightdev.com 80
  sockmark %s $mid($chan,2-)
}

ON *:SOCKOPEN:uptime_*: {
  if ($sockerr) { sockclose $sockname | return }
  sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ $sock($sockname).mark HTTP/1.1
  sockwrite -n $sockname Host: $sock($sockname).addr
  sockwrite -n $sockname $crlf
}

ON *:SOCKREAD:uptime_*: {
  if ($sockerr) { sockclose $sockname | return }
  var %data
  sockread %data
  if ($gettok(%data,1,32) isnum) && ($gettok(%data,2,32)) {
    var %c = $chr(35) $+ $sock($sockname).mark
    .msg %c The streaming is up for $qt(%data) $+ .
  }
  elseif (*not live.* iswm %data) {
    var %c = $chr(35) $+ $sock($sockname).mark
    .msg %c The streaming is currently offline.
  }
}

ON *:CONNECT: {
  if ($server == tmi.twitch.tv) {
    /raw CAP REQ :twitch.tv/membership
    /raw CAP REQ :twitch.tv/commands
  }
}
Posted By: Khonor

Re: !uptime command - 21/06/15 10:55 PM

Still does not work, but good no matter thank you very much for all your help equal Westor.
Posted By: Majeye

Re: !uptime command - 23/06/15 05:04 AM

Mine works just fine. Just tested it in my own channel.

Here you go:

https://github.com/Majeye/MajeyeBot/blob/master/streamer_uptime

!uptime is the command

You can also do !uptime <Streamer Name> and it'll tell you someone elses uptime, even in your own channel.

Posted By: Khonor

Re: !uptime command - 23/06/15 02:49 PM

If this used to work, but in the last few weeks it stopped. confused
Posted By: keyeslol

Re: !uptime command - 23/06/15 04:51 PM

You need to send this:

/raw CAP REQ :twitch.tv/membership
/raw CAP REQ :twitch.tv/commands
Posted By: bl968

Re: !uptime command - 21/01/16 03:13 AM

Recently nightbot added a spam to the command. I dealt with it by changing....

Quote:
if ($1 isnum) && ($2) { msg %channel %target has been online for $1- }

to
Quote:
if ($1 isnum) && ($2) {
/msg %channel %target has been streaming for $gettok($1-,1,45)
}



Posted By: x3pos

Re: !uptime command - 30/01/16 03:34 PM

bot saying

"1 hour, 32 minutes - Oh hey, you're using an API meant for Nightbot, not for whatever you're using. Maybe you'd want to try out the new Nightbot beta: https://beta.nightbot.tv".

can i delete other words.i want to only "hours and minutes"
Posted By: Sissou

Re: !uptime command - 30/01/16 08:45 PM

Originally Posted By: x3pos
bot saying

"1 hour, 32 minutes - Oh hey, you're using an API meant for Nightbot, not for whatever you're using. Maybe you'd want to try out the new Nightbot beta: https://beta.nightbot.tv".

can i delete other words.i want to only "hours and minutes"




I use this and it works

Quote:

on *:text:!uptime*:#:{
if (!$2) { set %target $remove($chan,$chr(35)) }
else 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
var %delmessage = $deltok($1-, 5-30, 32)
var %online $remove(%delmessage,- Oh)
if ($1 isnum) && ($2) { msg %channel %target has been online for %online }
elseif (%data == The channel is not live. - Oh hey, you're using an API meant for Nightbot, not for whatever you're using. Maybe you'd want to try out the new Nightbot beta: https://beta.nightbot.tv) msg %channel %target is currently not online.
}

on *:sockclose:uptime:{
unset %channel
unset %target
}
Posted By: Blas

Re: !uptime command - 31/01/16 10:11 AM

I find this is easier by using SReject's JSON script. I had to edit his code found here in order to have it work properly for me.

Code:
ON *:TEXT:!uptime*:#: {
  VAR %stream $IIF($2,$2,$remove(#,$chr(35)))
  jsonopen -ud uptime https://api.twitch.tv/kraken/streams/ $+ %stream
  IF ($JSONError) MSG $chan Error.
  ELSEIF ($regex($JSON(uptime, stream, created_at), /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/)) MSG $chan %stream has been streaming for $duration($calc($ctime - ($ctime($gettok(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec, $regml(2), 32) $regml(3) $regml(1) $regml(4) $+ : $+ $regml(5) $+ : $+ $regml(6)) - 18000)),2) $+ .
  ELSE MSG $chan %stream is not online.
}
Posted By: x3pos

Re: !uptime command - 31/01/16 11:49 AM

Code:
on *:text:!uptime*:#:{
if (!$2) { set %target $remove($chan,$chr(35)) }
else 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
var %delmessage = $deltok($1-, 5-30, 32)
var %online $remove(%delmessage,- Oh)
if ($1 isnum) && ($2) { msg %channel $nick %target has been online for %online }
elseif (%data == $nick The channel is not live. - Oh hey, you're using an API meant for Nightbot, not for whatever you're using. Maybe you'd want to try out the new Nightbot beta: https://beta.nightbot.tv) msg %channel %target is currently not online.
}

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


Code:
add "$nick" but channelbot saying this;
channelbot streamer has been online for 4 minutes 4 seconds.
Posted By: Y4kuzi

Re: !uptime command - 31/01/16 05:20 PM

$nick does not evaluate inside a sockread.
© 2020 mIRC Discussion Forums