I made a timer which checks if my twitch.tv stream is offline or not. the method get executed all 30 seconds.
If my stream is online the bot will automatically connect to my Stream.
If my Stream if offline there's an INT which will go +1 all 30 seconds and if it reaches 10 which are 5 minutes the bot should just part the IRC channel.
but somehow, the bot continues on counting. Did i made any faults with my if/else statements?
As soon my Stream is offline, bot starts counting all 30 seconds +1 as it should. but when it reaches 10 it just goes higher... its now at 30 already for example but i'm not sure why it doesn't part the channel.
Here is my function;
public void livemodetimer() {
if(livemode == "off" && TwitchStatus.isstreamlive){
livemode = "on";
}else
if(livemode == "on" && TwitchStatus.isstreamlive == false){
zaehler = zaehler+1;
System.out.println("Stream Offline Counter. Disconnect bei (10). Aktuell:"+zaehler);
}else
if(livemode == "on" && TwitchStatus.isstreamlive == true){
zaehler = 0;
if(zaehler >= 10){
livemode = "off";
zaehler = 0;
}
if (TwitchStatus.isstreamlive && livemode == "on" && multistartprepare == false){
joinChannel("#"+YBot.MyBot.ownerchannel+"");
multistartprepare = true;
startup();
}
if(TwitchStatus.isstreamlive == false && livemode == "off" && multistartprepare == true){
sendMessage("#"+YBot.MyBot.ownerchannel+"","Da der Stream Offline ist verzieh ich mich mal =) Bye!!");
partChannel("#"+YBot.MyBot.ownerchannel+"");
multistartprepare = false;
zaehler = 0;
TTmsg.cancel();
TTmsg.purge();
}
}
Does anyone have an idea why it doesn't call the partchannel
stuff when it reaches 10.
Edited Version Below:
public void livemodetimer() {
if(livemode == false && TwitchStatus.isstreamlive){
livemode = true;
}else
if(livemode && TwitchStatus.isstreamlive == false){
zaehler = zaehler+1;
System.out.println("Stream Offline Counter. Disconnect bei (10). Aktuell:"+zaehler);
}else
if(livemode && TwitchStatus.isstreamlive == true){
zaehler = 0;
}
if(zaehler >= 10){
livemode = false;
zaehler = 0;
}
if (TwitchStatus.isstreamlive && livemode && multistartprepare == false){
joinChannel("#"+YBot.MyBot.ownerchannel+"");
multistartprepare = true;
startup();
}
if(TwitchStatus.isstreamlive == false && livemode == false && multistartprepare){
sendMessage("#"+YBot.MyBot.ownerchannel+"","Da der Stream Offline ist verzieh ich mich mal =) Bye!!");
partChannel("#"+YBot.MyBot.ownerchannel+"");
multistartprepare = false;
zaehler = 0;
TTmsg.cancel();
TTmsg.purge();
}
}