diff --git a/.classpath b/.classpath
index 6f3769e..7e04485 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,9 @@
+
-
-
-
-
-
-
+
+
diff --git a/lib/.gitignore b/lib/.gitignore
deleted file mode 100644
index 93813ca..0000000
--- a/lib/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/commons-io-2.5.jar
-/twitch-api-wrapper-0.3-jar-with-dependencies.jar
diff --git a/lib/commons-io-2.5.jar b/lib/commons-io-2.5.jar
new file mode 100644
index 0000000..1234918
Binary files /dev/null and b/lib/commons-io-2.5.jar differ
diff --git a/lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar b/lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar
new file mode 100644
index 0000000..8a269a4
Binary files /dev/null and b/lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar differ
diff --git a/projectBuilder.xml b/projectBuilder.xml
index 2be4de0..601f13f 100644
--- a/projectBuilder.xml
+++ b/projectBuilder.xml
@@ -13,8 +13,8 @@
-
-
+
+
diff --git a/sigIRCv2.jar b/sigIRCv2.jar
index 9d1ba96..989a8ac 100644
Binary files a/sigIRCv2.jar and b/sigIRCv2.jar differ
diff --git a/src/sig/ScrollingText.java b/src/sig/ScrollingText.java
index 2925ec6..082beeb 100644
--- a/src/sig/ScrollingText.java
+++ b/src/sig/ScrollingText.java
@@ -239,16 +239,25 @@ public class ScrollingText {
if (space>0) {
String word = basemsg.substring(marker+1, space);
//System.out.println("Word is '"+word+"'");
-
+ sigIRC.emoticons.addAll(sigIRC.emoticon_queue);
+ sigIRC.emoticon_queue.clear();
for (Emoticon e : sigIRC.emoticons) {
+ //System.out.println("Checking for emoticon "+e.getEmoteName());
if (e.getEmoteName().equals(word)) {
+ if (e instanceof SubEmoticon) {
+ SubEmoticon se = (SubEmoticon)e;
+ if (!se.canUserUseEmoticon(username)) {
+ //System.out.println("User "+username+" is not subscribed to "+se.channelName+"'s channel!");
+ break;
+ }
+ }
+ //System.out.println(" Found one!");
basemsg = TextUtils.replaceFirst(basemsg, e.getEmoteName(), e.getSpaceFiller());
GenerateEmoticon(marker+1, basemsg, e);
space = basemsg.indexOf(" ", marker+1);
break;
}
}
-
marker=space;
} else {
break;
diff --git a/src/sig/SubEmoticon.java b/src/sig/SubEmoticon.java
new file mode 100644
index 0000000..f24fb79
--- /dev/null
+++ b/src/sig/SubEmoticon.java
@@ -0,0 +1,67 @@
+package sig;
+
+import java.net.URL;
+
+import com.mb3364.twitch.api.handlers.ChannelResponseHandler;
+import com.mb3364.twitch.api.handlers.ChannelSubscriptionResponseHandler;
+import com.mb3364.twitch.api.handlers.UserSubscriptionResponseHandler;
+import com.mb3364.twitch.api.models.Channel;
+import com.mb3364.twitch.api.models.ChannelSubscription;
+import com.mb3364.twitch.api.models.UserSubscription;
+
+public class SubEmoticon extends Emoticon{
+ String channelName = "";
+ static boolean userCanUseEmoticon=false;
+
+ public SubEmoticon(String emoteName, String fileName, String channelName) {
+ super(emoteName, fileName);
+ this.channelName=channelName;
+ }
+ public SubEmoticon(String emoteName, URL onlinePath, String channelName) {
+ super(emoteName,onlinePath);
+ this.channelName=channelName;
+ }
+
+ public boolean canUserUseEmoticon(String username) {
+ userCanUseEmoticon=false;
+ /*System.out.println("User: "+username+", Channel: "+channelName+"|");
+ sigIRC.manager.channels().getSubscription(username.trim(), channelName.trim(), new ChannelSubscriptionResponseHandler() {
+
+ @Override
+ public void onFailure(Throwable arg0) {
+ System.out.println(arg0.getMessage());
+ }
+
+ @Override
+ public void onFailure(int arg0, String arg1, String arg2) {
+ System.out.println(arg0+","+arg1+","+arg2);
+ }
+
+ @Override
+ public void onSuccess(ChannelSubscription arg0) {
+ System.out.println("User is subscribed to channel "+channelName+"!");
+ userCanUseEmoticon=true;
+ }
+
+ });*/
+ /*sigIRC.manager.users().getSubscription( new UserSubscriptionResponseHandler() {
+
+ @Override
+ public void onFailure(Throwable arg0) {
+ System.out.println(arg0.getMessage());
+ }
+
+ @Override
+ public void onFailure(int arg0, String arg1, String arg2) {
+ System.out.println(arg0+","+arg1+","+arg2);
+ }
+
+ @Override
+ public void onSuccess(UserSubscription arg0) {
+ System.out.println("User is subscribed to channel "+channelName+"!");
+ userCanUseEmoticon=true;
+ }
+ });*/
+ return true;
+ }
+}
diff --git a/src/sig/UpdateEvent.java b/src/sig/UpdateEvent.java
index c17b8f1..49a619a 100644
--- a/src/sig/UpdateEvent.java
+++ b/src/sig/UpdateEvent.java
@@ -32,7 +32,7 @@ public class UpdateEvent implements ActionListener{
sigIRC.playedoAuthSoundOnce=true;
}
} else {
- sigIRC.panel.addMessage("SYSTEM: This is a test message for your testing convenience. Kappa",!sigIRC.playedoAuthSoundOnce);
+ sigIRC.panel.addMessage("SYSTEM: This is a test message for your testing convenience. mikansBox",!sigIRC.playedoAuthSoundOnce);
}
}
if (last_autosave follows) {
//System.out.println("Successfully found followers for channel "+sigIRC.channel+". Total: "+total);
@@ -280,7 +277,7 @@ public class TwitchModule extends Module{
}
private boolean isStreamOnline() {
- manager.streams().get(TextUtils.getActualChannelName(), new StreamResponseHandler() {
+ sigIRC.manager.streams().get(TextUtils.getActualChannelName(), new StreamResponseHandler() {
@Override
public void onFailure(Throwable arg0) {
diff --git a/src/sig/sigIRC.java b/src/sig/sigIRC.java
index b906bad..a723b95 100644
--- a/src/sig/sigIRC.java
+++ b/src/sig/sigIRC.java
@@ -3,12 +3,20 @@ package sig;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
+import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import com.mb3364.twitch.api.Twitch;
+import com.mb3364.twitch.api.handlers.ChannelResponseHandler;
+import com.mb3364.twitch.api.handlers.StreamResponseHandler;
+import com.mb3364.twitch.api.models.Channel;
+import com.mb3364.twitch.api.models.Stream;
+
import sig.modules.TouhouMotherModule;
import sig.modules.TwitchModule;
import sig.utils.FileUtils;
+import sig.utils.TextUtils;
import java.awt.Color;
import java.awt.Dimension;
@@ -25,6 +33,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
import java.net.UnknownHostException;
@@ -41,6 +50,7 @@ public class sigIRC{
public static List textobj = new ArrayList();
public static List rowobj = new ArrayList();
public static List emoticons = new ArrayList();
+ public static List emoticon_queue = new ArrayList();
public static List twitchemoticons = new ArrayList();
public static List customsounds = new ArrayList();
public static List modules = new ArrayList();
@@ -97,9 +107,11 @@ public class sigIRC{
public static int twitchmodule_newfollowerImgLogoSize=32;
public static boolean testMode=false;
public final static String TWITCHEMOTEURL = "https://static-cdn.jtvnw.net/emoticons/v1/";
+ public static long channel_id = -1;
+
+ public static Twitch manager = new Twitch();
public static void main(String[] args) {
-
config = InitializeConfigurationFile();
server = config.getProperty("server");
@@ -139,6 +151,8 @@ public class sigIRC{
touhoumothermodule_width = config.getInteger("TOUHOUMOTHER_module_width",320);
touhoumothermodule_height = config.getInteger("TOUHOUMOTHER_module_height",312);
hardwareAcceleration = config.getBoolean("hardware_acceleration",true);
+ manager.setClientId("o4c2x0l3e82scgar4hpxg6m5dfjbem");
+ //System.out.println(manager.auth().hasAccessToken());
DownloadAllRequiredDependencies();
@@ -172,12 +186,13 @@ public class sigIRC{
ConfigFile.setAllDefaultProperties(conf);
conf.saveProperties();
}
- return conf;
+ return conf;
}
public static void DownloadAllRequiredDependencies() {
FileManager manager = new FileManager("sigIRC/oauthToken.txt"); manager.verifyAndFetchFileFromServer();
manager = new FileManager("sigIRC/Emotes/",true); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("sigIRC/Emotes/subscribers.txt"); manager.verifyAndFetchFileFromServer();
manager = new FileManager("sigIRC/logs/",true); manager.verifyAndFetchFileFromServer();
manager = new FileManager("sigIRC/sounds/",true); manager.verifyAndFetchFileFromServer();
manager = new FileManager("sigIRC/sounds/Glaceon_cry.wav"); manager.verifyAndFetchFileFromServer();
@@ -260,6 +275,43 @@ public class sigIRC{
}
}
+ private static void downloadSubEmotes(JSONObject emotes, String channelName) {
+ manager.channels().get(channelName, new ChannelResponseHandler() {
+
+ @Override
+ public void onFailure(Throwable arg0) {
+ }
+
+ @Override
+ public void onFailure(int arg0, String arg1, String arg2) {
+ }
+
+ @Override
+ public void onSuccess(Channel arg0) {
+ if (arg0!=null) {
+ channel_id=arg0.getId();
+ JSONObject channel = emotes.getJSONObject(Long.toString(channel_id));
+ JSONArray arr = channel.getJSONArray("emotes");
+ //System.out.println("Channel: "+channel);
+ for (int i=0;i0) {
+ s=s.trim();
+ //System.out.println("Got sub emote info for "+s);
+ downloadSubEmotes(subemotes,s);
+ }
+ }
/*JSONObject emotelist = twitchemotes.getJSONObject("emotes");
JSONObject templatelist = twitchemotes.getJSONObject("template");
String templateurl = templatelist.getString("small");