Tried to reduce frequency of Twitch API pulls

dev
sigonasr2 7 years ago
parent 967c66040c
commit 3eb312abf8
  1. BIN
      sigIRCv2.jar
  2. 78
      src/sig/modules/TwitchModule.java

Binary file not shown.

@ -138,6 +138,7 @@ public class TwitchModule extends Module{
lastFollowerCheck = FOLLOWERCHECKTIMER; lastFollowerCheck = FOLLOWERCHECKTIMER;
getFollowers(false); getFollowers(false);
popFollowerFromQueue(); popFollowerFromQueue();
isStreamOnline(true);
} }
if (lastFollowerAnnouncement>0) { if (lastFollowerAnnouncement>0) {
lastFollowerAnnouncement--; lastFollowerAnnouncement--;
@ -280,48 +281,55 @@ public class TwitchModule extends Module{
} }
} }
} }
private boolean isStreamOnline() { private boolean isStreamOnline() {
sigIRC.manager.streams().get(TextUtils.getActualChannelName(), new StreamResponseHandler() { return isStreamOnline(false);
}
@Override
public void onFailure(Throwable arg0) {
TwitchModule.streamOnline=false;
}
@Override
public void onFailure(int arg0, String arg1, String arg2) {
System.out.println(arg0+","+arg1+","+arg2);
TwitchModule.streamOnline=false;
}
@Override private boolean isStreamOnline(boolean update) {
public void onSuccess(Stream arg0) { if (update) {
//System.out.println("Stream data is available! "+arg0); sigIRC.manager.streams().get(TextUtils.getActualChannelName(), new StreamResponseHandler() {
if (arg0==null) {
@Override
public void onFailure(Throwable arg0) {
TwitchModule.streamOnline=false; TwitchModule.streamOnline=false;
} else {
TwitchModule.streamOnline=true;
UpdateAllStreamStatistics(arg0);
} }
}
@Override
private void UpdateAllStreamStatistics(Stream data) { public void onFailure(int arg0, String arg1, String arg2) {
if (data!=null) { System.out.println(arg0+","+arg1+","+arg2);
if (data.getGame()!=null && data.getGame().length()>0) { TwitchModule.streamOnline=false;
currentlyPlaying = data.getGame(); }
@Override
public void onSuccess(Stream arg0) {
//System.out.println("Stream data is available! "+arg0);
if (arg0==null) {
TwitchModule.streamOnline=false;
} else {
TwitchModule.streamOnline=true;
UpdateAllStreamStatistics(arg0);
} }
if (data.getCreatedAt()!=null) { }
uptime = data.getCreatedAt();
private void UpdateAllStreamStatistics(Stream data) {
if (data!=null) {
if (data.getGame()!=null && data.getGame().length()>0) {
currentlyPlaying = data.getGame();
}
if (data.getCreatedAt()!=null) {
uptime = data.getCreatedAt();
}
viewers_numb.updateValue(data.getViewers());
views_numb.updateValue((int)data.getChannel().getViews());
followers_numb.updateValue(data.getChannel().getFollowers());
} }
viewers_numb.updateValue(data.getViewers());
views_numb.updateValue((int)data.getChannel().getViews());
followers_numb.updateValue(data.getChannel().getFollowers());
} }
}
});
}); return TwitchModule.streamOnline;
return TwitchModule.streamOnline; } else {
return TwitchModule.streamOnline;
}
//TwitchModule.streamOnline=true; //TwitchModule.streamOnline=true;
//return true; //return true;
} }

Loading…
Cancel
Save