Monitor for JSON array increase? [Streamtip APi] - 25/04/16 06:04 PM
I'm working with Streamtip's APi to check for new donations and have mIRC post a simple "thanks for donating <user> !". The only way I believe I can track for a new donation is to see if the array increased. How do I monitor the array increase safely without causing an endless loop?
The current code i've tried doesn't seem to understand that the number has stayed the same and will post "thanks for the support" over and over again. I have alias "CheckNewDonations" on a timer that repeats every 15 seconds to comply with Nightdev's rate limit.
Streamtip APi Documentation:
https://streamtip.com/api#get_tips
The current code i've tried doesn't seem to understand that the number has stayed the same and will post "thanks for the support" over and over again. I have alias "CheckNewDonations" on a timer that repeats every 15 seconds to comply with Nightdev's rate limit.
Streamtip APi Documentation:
https://streamtip.com/api#get_tips
Code:
alias CheckNewDonations { //echo checking for new tips from streamtip! var %lasttipURL = E:\Other Files\Google Drive\Public\projects\twitch\bot\private\streamtip_checkerURL.txt var %link = $read(%lasttipURL) var %v = twc_ $+ $ticks JSONOpen -ud %v %link var %currentTipCount = $JSON(%v,_count) var %currentTipID = $JSON(%v,tips,0,_id) var %previousTipID = %currentTipID var %tipName = $JSON(%v,tips,0,username) var %tipCount = $JSON(%v,tips,0,amount) var %tipSymbol = $JSON(%v,tips,0,currencySymbol) var %tipDate = $JSON(%v,tips,0,date) if (%currentTipCount != %previousTipID) { msg $chan /me %tipName just tipped %tipSymbol $+ %tipCount $+ . thanks for the support! <3 <3 return } else if (%currentTipCount == %previousTipID) { return } :end JSONClose %v }