mIRC Homepage

[DecAPI] Twitch Follower Help

Posted By: Bramzee

[DecAPI] Twitch Follower Help - 31/03/17 09:06 PM

So, after a little bit work I realized that using the new "decapi" is a bit simpler. However, I still don't know what I should be pulling from the link

Code:
 https://decapi.me/twitch/followers?channel=CHANNELNAMEHERE 


It shows the last follower, so I know that I would have to:

-Repeatedly check the site (every 10-20 seconds if possible)
-Save the name/follower to a variable (probably a text/ini file as well to prevent spamming)
-Check the variable (%recentfollow) return
-Check the file ($readini(followers.ini,n,#,%newfollower)) return
-if neither of those are true then msg $chan with that user being the new follower

My problem is mainly that I get frustrated quickly trying to learn this stuff... I know most of the basic stuff, but sockets and everything just, get to me.

Posted By: Bramzee

Re: [DecAPI] Twitch Follower Help - 01/04/17 05:37 AM

For anyone in the future that cares or needs this...


Code:
 on *:text:!alerts*:#: {
  if ($nick == OWNER) {
    if ($2 == on) {
      .timerFollowAlert 0 60 followalert
      msg # In chat alerts have been started.
      set %AlertsOn 1
      unset %AlertsOff
    }
    if ($2 == off) {
      .timerFollowAlert off
      msg # In chat alerts have been stopped.
      set %AlertsOff 1
      unset %AlertsOn
    }
    else return
  }
  else return
}

alias followalert {
  sockopen -e newfollower decapi.me 443
}


on *:SOCKOPEN:*: {
  if ($sockname == newfollower) {
    sockwrite -nt $sockname GET /twitch/followers.php?channel=CHANNEL_NAME_HERE HTTP/1.1
    sockwrite -nt $sockname Host: decapi.me
    sockwrite $sockname $crlf
  }
}

on *:SOCKREAD:*: {
  if ($sockname == newfollower) {
    var %newfollower
    sockread %newfollower
    while ($sockbr) {
      sockread %newfollower
    }
  }
  else return
}

on *:sockclose:*: {
  if ($sockname == newfollower) {
    var %newfollower
    sockread -f %newfollower
    if ($readini(followers.ini,#CHANNEL_NAME_HERE,%newfollower)) {
      return
    }
    else {
      msg #CHANNEL_NAME_HERE Welcome to the the family, %newfollower $+ !!!
      /writeini followers.ini #CHANNEL_NAME_HERE %newfollower 1
    }
  }
} 



Also, that being said... If any of the more experienced users have ways of making this cleaner/better let me know. I'm not gonna lie, I got the script from OrFeAsGr - HERE and switched things out to get followers rather than uptime. Thanks OrFeAsGr.
Posted By: Bramzee

Re: [DecAPI] Twitch Follower Help - 02/04/17 07:18 PM

Is there a way to have this update/send the message automatically rather than using a timer to check the site?

ie: decapi.me/twitch/followers.php?channel=Channel
originally set to -> follower1
someone new follows, updates to -> follower2
msg channel new follower welcome follower2
end until site updates again

If it's not possible, that's fine. I'm just curious. Every now and then someone will follow at just the right time causing a 60 second delay on the alert to trigger.
© 2020 mIRC Discussion Forums