Skip to content

Commit

Permalink
Twitter status produces only one message per channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaysoro committed Nov 7, 2019
1 parent dcf85b5 commit 70b67ad
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/finders/TwitterFinder.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package finders;

import discord4j.core.object.util.Snowflake;
import enums.Language;
import listeners.TwitterListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;
import twitter4j.FilterQuery;
import util.ClientConfig;
import util.Connexion;
Expand All @@ -16,7 +14,6 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

Expand All @@ -25,10 +22,12 @@
*/
public class TwitterFinder{
private final static Logger LOG = LoggerFactory.getLogger(TwitterFinder.class);
protected static Map<Long, TwitterFinder> twitterChannels;
private static boolean isReady = false;
private static Map<Long, TwitterFinder> twitterChannels;
private long guildId;
private long channelId;


public TwitterFinder(long guidId, long channelId) {
this.guildId = guidId;
this.channelId = channelId;
Expand Down Expand Up @@ -101,15 +100,16 @@ public Long getGuildId(){
return guildId;
}

public static void start() {
if (ClientConfig.TWITTER() != null) {
public static synchronized void start() {
if (ClientConfig.TWITTER() != null && !isReady) {
ClientConfig.TWITTER().addListener(new TwitterListener());

long[] twitterIDs = new long[Language.values().length];
int i = 0;
for(Language lg : Language.values())
twitterIDs[i++] = Long.parseLong(Translator.getLabel(lg, "twitter.id"));
ClientConfig.TWITTER().filter(new FilterQuery(0, twitterIDs, new String[]{}));
isReady = true;
}
}
}

0 comments on commit 70b67ad

Please sign in to comment.