mIRC Home    About    Download    Register    News    Help

Print Thread
Updated !uptime command for Twitch #265979 28/08/19 01:15 PM
Joined: Jan 2018
Posts: 23
R
Ryntovy Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2018
Posts: 23
Hello,

Was wondering if anyone has a working !uptime script for Twitch.
Mine is outdated.

Thank you,
Ryn

Re: Updated !uptime command for Twitch [Re: Ryntovy] #265980 28/08/19 01:17 PM
Joined: Jan 2018
Posts: 23
R
Ryntovy Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2018
Posts: 23
I tried to put something together but doesn't work.

Code
ON *:TEXT:!uptime:#CHANNELNAME: {
  if ((%flood_uptime) || ($($+(%,flood_uptime_,$nick),2))) { return }
  set -eu0 %flood_uptime On
  set -eu0 %flood_uptime_ $+ $nick On
  
  if ($regex($msgtags(display-name).key, /^[a-z\d_]+$/ig)) { set %output msg #CHANNELNAME /me @ $+ $msgtags(display-name).key }
  else { set %output msg #CHANNELNAME /me @ $+ $nick }
 
  $urlget(https://decapi.me/twitch/uptime?channel=monstercat,gb,&url,if ($bvar(&url,1).text) %output channel has been live for $v1)
  noop $urlget(https://decapi.me/twitch/uptime?channel=monstercat,gb,&url,handle_output)
  
  alias handle_output {
  if ($bvar(&url,1).text) { %ouput channel is online for $v1 }
  else { %output channel if offline }
  
}

Re: Updated !uptime command for Twitch [Re: Ryntovy] #265981 28/08/19 03:00 PM
Joined: Sep 2010
Posts: 12
Matt5150 Offline
Pikka bird
Offline
Pikka bird
Joined: Sep 2010
Posts: 12
I didn't test the code, but there are at least 3 (4?) errors I think.
1) missing a bracket } before "alias"
2) there is a typo in the variable name %output in the "alias handle_output", it's called %ouput
3) $bvar(&url,1).text will return ONLY the first character I think, maybe something $bvar(&url,1-300).text will fix it

and one last question, why use 2 $urlget?
I mean, if you copy a code from someone else, be more careful. Where do you get it?

Maybe this should work, I didn't try it and I don't want to.
Code
ON *:TEXT:!uptime:#CHANNELNAME: {
  if ((%flood_uptime) || ($($+(%,flood_uptime_,$nick),2))) { return }
  set -eu0 %flood_uptime On
  set -eu0 %flood_uptime_ $+ $nick On

  if ($regex($msgtags(display-name).key, /^[a-z\d_]+$/ig)) { set %output msg #CHANNELNAME /me @ $+ $msgtags(display-name).key }
  else { set %output msg #CHANNELNAME /me @ $+ $nick }

  noop $urlget(https://decapi.me/twitch/uptime?channel=monstercat,gb,&url,handle_output)
}
alias handle_output {
  if ($bvar(&url,1-300).text) { %output channel is online for $v1 }
  else { %output channel if offline }
}

Re: Updated !uptime command for Twitch [Re: Ryntovy] #265982 28/08/19 03:47 PM
Joined: Apr 2010
Posts: 923
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 923
If you have my JSON for mIRC script its as simple as:


Code
on *:TEXT:!uptime:#:{
    if ((%flood_uptime) || ($($+(%,flood_uptime_,$nick),2))) {
        return
    }
    set -eu1 %flood_uptime On
    set -eu1 %flood_uptime_ $+ $nick On

    jsonopen -Ud https://decapi.me/twitch/uptime?channel= $+ $chan
    if (!$jsonerror) {
        describe $chan @ $+ $iif($msgtags(display-name).key != $null, @ $+ $v1, $nick) Channel has been live for $json(uptime).HttpBody
    }
}



Quote
3) $bvar(&url,1).text will return ONLY the first character I think, maybe something $bvar(&url,1-300).text will fix it
You can use $bvar(&bvar_name, 1-).text to retrieve the entire contents of a bvar as text


Using urlget as you have it:
Code
ON *:TEXT:!uptime:#: {
  ;; ignore command if:
  ;; global flood protection is enabled
  ;; per-user flood proection is enabled
  ;; an uptime request is currently pending
  if (%flood_uptime || $($+(%, flood_uptime_, $nick), 2) || %uptime_output) {
    return
  }

  ;; !uptime can only be used every 30s
  set -eu30 %flood_uptime On

  ;; !uptime can only be used by the same user every 5minutes
  set -eu300 % $+ flood_uptime_ $+ $nick On

  ;; set output command for web request
  set -e %uptime_output msg $chan /me @ $+ $iif($msgtags(display-name).key !== $nick && $v1 != $null, $v1, $nick)

  noop $urlget(https://decapi.me/twitch/uptime?channel= $+ $chan, gb, &uptime_body, handle_output)
}

alias -l handle_output {
  if ($bvar(&uptime_body, 1-).text) {
    %uptime_output Channel has been online for $v1
  }
  else {
    %uptime_output channel if offline
  }
  unset %uptime_output
}

Last edited by FroggieDaFrog; 28/08/19 03:57 PM.

I am SReject
My Stuff
Re: Updated !uptime command for Twitch [Re: FroggieDaFrog] #265984 28/08/19 05:55 PM
Joined: Jan 2018
Posts: 23
R
Ryntovy Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2018
Posts: 23
Got it, thank you! smile