mIRC Home    About    Download    Register    News    Help

Topic Options
#259562 - 27/12/16 03:04 AM Followage Twitch
apoio82 Offline
Pikka bird

Registered: 27/12/16
Posts: 11
My question is about the twitch's interaction with mirc if it is possible to make a script command to know how long a particular person follows a certain channel. I have seen in some forum no more works.
Even here in the mirc forum there is no command that works currently
Thank you.

Top
#259563 - 27/12/16 06:18 AM Re: Followage Twitch [Re: apoio82]
Blas Offline
Babel fish

Registered: 27/10/15
Posts: 87
You can edit the following URL in a command to do that. https://api.rtainc.co/twitch/channels/CHANNELNAME/followers/USERNAME

Alternatively, I wrote a script for mIRC that basically does the same. You can find it here.
_________________________
My Twitch mIRC Bot Games and Stuff

Top
#259616 - 03/01/17 10:22 PM Re: Followage Twitch [Re: Blas]
apoio82 Offline
Pikka bird

Registered: 27/12/16
Posts: 11
Sorry, I can not follow your directions on replacing the command line bhbbEven found a api more like the command, but did not succeed successfully replace frown Could anyone help me?

Simpler api:
https://beta.decapi.me/twitch/followage/channel/user
or
https://api.rtainc.co/twitch/channels/CHANNELNAME/followers/USERNAE

command:
ON $*:TEXT:/^!date(\s@?\w+)?$/iS:#: {
IF ($nick isop $chan) {
IF (!$2) MSG $chan $followdate($nick)
ELSE MSG $chan $IIF($twitch_name($remove($2,@)) != $null,$followdate($v1),$nick $+ $chr(44) $remove($2,@) is not a valid user on Twitch. FailFish)
}
ELSEIF ((!$($+(%,followdate_CD.,$nick),2)) && (!$2)) {
SET -eu60 %followdate_CD. $+ $nick On
MSG $chan $followdate($nick)
}
}

alias followdate {
IF (%fd == 1000) %fd = 0
INC %fd
VAR %nick $1
JSONOpen -uw date $+ %fd https://api.twitch.tv/kraken/users/ $+ %nick $+ /follows/channels/ $+ %streamer $+ ?nocache= $+ $ticks
JSONUrlHeader date $+ %fd Client-ID avm4vi7zv0xpjkpi3d4x0qzk8xbrdw8
JSONUrlGet date $+ %fd
VAR %time $JSON(date $+ %fd, created_at)
IF ($v1 != $null) VAR %date $TwitchTime(%time)
VAR %x %nick $IIF(%time != $null,has been following this channel for $duration($calc($ctime - %date),2) since $asctime(%date,mmm dd yyyy) $+ .,is not following the channel.)
JSONClose date $+ %fd
RETURN %x
}

alias -l TwitchTime {
if ($regex($1-, /^(\d\d(?:\d\d)?)-(\d\d)-(\d\d)T(\d\d)\:(\d\d)\:(\d\d)(?:(?:Z$)|(?:([+-])(\d\d)\:(\d+)))?$/i)) {
var %m = $Gettok(January February March April May June July August September October November December, $regml(2), 32), %d = $ord($base($regml(3),10,10)), %o = +0, %t
if ($regml(0) > 6) %o = $regml(7) $+ $calc($regml(8) * 3600 + $regml(9))
%t = $calc($ctime(%m %d $regml(1) $regml(4) $+ : $+ $regml(5) $+ : $+ $regml(6)) - %o)
if ($asctime(zz) !== 0 && $regex($v1, /^([+-])(\d\d)(\d+)$/)) {
%o = $regml(1) $+ $calc($regml(2) * 3600 + $regml(3))
%t = $calc(%t + %o )
}
return %t
}
}

Top
#259617 - 04/01/17 05:33 AM Re: Followage Twitch [Re: apoio82]
FroggieDaFrog Offline
Hoopy frood

Registered: 16/04/10
Posts: 825
Loc: USA
Cleaned up your code, but it appears you are missing an alias from here "$twitch_name". You will also need to install My json parser v0.2.41
Code:
on $*:TEXT:/^!date(\s@?\w+)?$/iS:#: {
  if ($nick isop $chan) {
    if (!$2) {
      msg $chan $followdate($nick)
    }
    elseif ($twitch_name($remove($2, @))) {
      msg $chan $followdate($v1)
    }
    else {
      msg $chan $nick $+ $chr(44) $remove($2, @) is not a valid user on Twitch. FailFish
    }
  }
  elseif (!$($+(%, followdate_CD., $nick), 2) && !$2) {
    set -eu60 %followdate_CD. $+ $nick On
    msg $chan $followdate($nick)
  }
}

alias followdate {
  var %json = json $+ $ticks, %time, %date
  JSONOpen -uw  %json https://api.twitch.tv/kraken/users/ $+ $1 $+ /follows/channels/ $+ $mid($chan, 2-)
  JSONUrlHeader %json Client-ID avm4vi7zv0xpjkpi3d4x0qzk8xbrdw8
  JSONUrlGet    %json
  %time = $JSON(%json, created_at)
  JSONClose     %json
  if (%time) {
    %date = $TwitchTime(%time)
    return $1 has been following this channel for $duration($calc($ctime - %date), 2) since $asctime(%date, mm dd yy) $+ .
  }
  return $1 is not following the channel.
}


alias -l TwitchTime {
  if ($regex($1-, /^(\d\d(?:\d\d)?)-(\d\d)-(\d\d)T(\d\d)\:(\d\d)\:(\d\d)(?:(?:Z$)|(?:([+-])(\d\d)\:(\d+)))?$/i)) {
    var %m = $Gettok(January February March April May June July August September October November December, $regml(2), 32), %d = $ord($base($regml(3),10,10)), %o = +0, %t
    if ($regml(0) > 6) %o = $regml(7) $+ $calc($regml(8) * 3600 + $regml(9))
    %t = $calc($ctime(%m %d $regml(1) $regml(4) $+ : $+ $regml(5) $+ : $+ $regml(6)) - %o)
    if ($asctime(zz) !== 0 && $regex($v1, /^([+-])(\d\d)(\d+)$/)) {
      %o = $regml(1) $+ $calc($regml(2) * 3600 + $regml(3))
      %t = $calc(%t + %o)
    }
    return %t
  }
}


Edited by FroggieDaFrog (04/01/17 05:59 AM)
_________________________
I am SReject
My Stuff

Top
#259684 - 11/01/17 12:32 AM Re: Followage Twitch [Re: apoio82]
Blas Offline
Babel fish

Registered: 27/10/15
Posts: 87
The $twitch_name is to simply check the Twitch API to see if the target username is valid and to get the proper display name to make it look nicer.

Code:
alias twitch_name {
  IF (%tn == 1000) %tn = 0
  INC %tn
  JSONOpen -uw twitch_name $+ %tn https://api.twitch.tv/kraken/channels/ $+ $1
  JSONUrlHeader twitch_name $+ %tn Client-ID avm4vi7zv0xpjkpi3d4x0qzk8xbrdw8
  JSONUrlGet twitch_name $+ %tn
  VAR %x $json(twitch_name $+ %tn $+ , display_name)
  JSONClose twitch_name $+ %tn
  RETURN %x
}

The reason that I don't use $ticks in this code is because sometimes I need $twitch_name multiple times on one line, and when using $ticks it will not work.

Example using $ticks:
Code:
$twitch_name(Tom) $twitch_name(Dick) $twitch_name(Harry)
will return
Quote:
Tom Tom Tom
most of the time.
_________________________
My Twitch mIRC Bot Games and Stuff

Top