Project

General

Profile

[Script] Twitch follower command

Added by Per Amundsen about 4 years ago

Simple script to show how long a nick has been following your twitch channel.

on *:TEXT:!follow *:#:{
  follow $2
}

alias follow {
  var %ticks $ticks
  sockopen follow [ $+ [ %ticks ] ] api.newtimenow.com 80
  sockmark follow [ $+ [ %ticks ] ] $1 #
}

on *:sockopen:follow*:{
  var %chan $gettok($sock($sockname).mark,2,32)
  var %nick $gettok($sock($sockname).mark,1,32)
  sockwrite -nt $sockname GET /follow-length/?channel= $+ $replace(%chan,$chr(35),) $+ &user= $+ %nick HTTP/1.0
  sockwrite -nt $sockname Host: api.newtimenow.com $+ $str($crlf,2)
}

on *:sockread:follow*:{
  sockread %text

  var %nick $gettok($sock($sockname).mark,1,32)  
  var %chan $gettok($sock($sockname).mark,2,32)

  if (%text == Not following...) {
    msg %chan %nick isn't following
  }
  else if ($left(%text,4) isnum) {
    msg %chan %nick has been following my stream since $asctime($ctime(%text), mmmm oo $+ $chr(44) yyyy)
  }
}