package be.isach.samaritan.stream;

import com.mb3364.twitch.api.models.Channel;
import net.dv8tion.jda.JDA;
import net.dv8tion.jda.entities.TextChannel;

import java.util.Map;
import java.util.TimerTask;
import java.util.stream.Collectors;

/**
 * Created by sacha on 07-11-16.
 */
public abstract class StreamModule extends TimerTask {

    protected enum Status {
        ONLINE, OFFLINE
    }

    protected Map<String, Status> streamersMap;
    protected JDA jda;

    public StreamModule(JDA jda, StreamData streamData) {
        this.jda = jda;

        streamData.getStreamers().forEach(s -> streamersMap.put(s, null));
        streamersMap.keySet().forEach(this::initialize);
    }

    abstract public void initialize(String channel);

    abstract void check(String channel);

    abstract void broadcastLive(StreamerChannel channel);

    @Override
    public void run() {
        streamersMap.keySet().stream().filter(streamer -> streamer != null).forEach(this::check);
    }

    public final void removeChannel(String channel) {
        streamersMap.remove(channel);
    }

    protected final void sendMessage(String... messages) {
        TextChannel textChannel = jda.getTextChannelById("242305313527562240");
        for (String message : messages) {
            textChannel.sendMessage(message);
        }
    }
}

@@ -148,16 +148,42 @@
 annel;%0A%0A
+import java.util.HashMap;%0A
 import j
@@ -566,24 +566,69 @@
 s.jda = jda;
+%0A        this.streamersMap = new HashMap%3C%3E();
 %0A%0A        st

Support for Beam added