Include required dependencies in build project. Added capabilities of

whitelisted subscribers via editing sigIRC/Emotes/subscribers.txt.
Emotes will be downloaded automatically and will be usable and displayed
in the client.
dev
sigonasr2 7 years ago
parent 8924c55247
commit 35fbfa90e5
  1. 9
      .classpath
  2. 2
      lib/.gitignore
  3. BIN
      lib/commons-io-2.5.jar
  4. BIN
      lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar
  5. 4
      projectBuilder.xml
  6. BIN
      sigIRCv2.jar
  7. 13
      src/sig/ScrollingText.java
  8. 67
      src/sig/SubEmoticon.java
  9. 2
      src/sig/UpdateEvent.java
  10. 7
      src/sig/modules/TwitchModule.java
  11. 62
      src/sig/sigIRC.java

@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="lib"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry exported="true" kind="lib" path="D:/Downloads/commons-io-2.5.jar"> <classpathentry kind="lib" path="lib/commons-io-2.5.jar"/>
<attributes> <classpathentry kind="lib" path="lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/>
<attribute name="javadoc_location" value="jar:file:/D:/Data/commons-io-2.5-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="D:/Downloads/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

2
lib/.gitignore vendored

@ -1,2 +0,0 @@
/commons-io-2.5.jar
/twitch-api-wrapper-0.3-jar-with-dependencies.jar

Binary file not shown.

@ -13,8 +13,8 @@
<attribute name="Class-Path" value="."/> <attribute name="Class-Path" value="."/>
</manifest> </manifest>
<fileset dir="${dir.jarfile}/bin"/> <fileset dir="${dir.jarfile}/bin"/>
<zipfileset excludes="META-INF/*.SF" src="D:/Downloads/commons-io-2.5.jar"/> <zipfileset excludes="META-INF/*.SF" src="lib/commons-io-2.5.jar"/>
<zipfileset excludes="META-INF/*.SF" src="D:/Downloads/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/> <zipfileset excludes="META-INF/*.SF" src="lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/>
</jar> </jar>
</target> </target>
</project> </project>

Binary file not shown.

@ -239,16 +239,25 @@ public class ScrollingText {
if (space>0) { if (space>0) {
String word = basemsg.substring(marker+1, space); String word = basemsg.substring(marker+1, space);
//System.out.println("Word is '"+word+"'"); //System.out.println("Word is '"+word+"'");
sigIRC.emoticons.addAll(sigIRC.emoticon_queue);
sigIRC.emoticon_queue.clear();
for (Emoticon e : sigIRC.emoticons) { for (Emoticon e : sigIRC.emoticons) {
//System.out.println("Checking for emoticon "+e.getEmoteName());
if (e.getEmoteName().equals(word)) { 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()); basemsg = TextUtils.replaceFirst(basemsg, e.getEmoteName(), e.getSpaceFiller());
GenerateEmoticon(marker+1, basemsg, e); GenerateEmoticon(marker+1, basemsg, e);
space = basemsg.indexOf(" ", marker+1); space = basemsg.indexOf(" ", marker+1);
break; break;
} }
} }
marker=space; marker=space;
} else { } else {
break; break;

@ -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;
}
}

@ -32,7 +32,7 @@ public class UpdateEvent implements ActionListener{
sigIRC.playedoAuthSoundOnce=true; sigIRC.playedoAuthSoundOnce=true;
} }
} else { } 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<AUTOSAVETIMER) { if (last_autosave<AUTOSAVETIMER) {

@ -21,7 +21,6 @@ import java.util.List;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import com.mb3364.twitch.api.Twitch;
import com.mb3364.twitch.api.handlers.ChannelFollowsResponseHandler; import com.mb3364.twitch.api.handlers.ChannelFollowsResponseHandler;
import com.mb3364.twitch.api.handlers.StreamResponseHandler; import com.mb3364.twitch.api.handlers.StreamResponseHandler;
import com.mb3364.twitch.api.handlers.UserResponseHandler; import com.mb3364.twitch.api.handlers.UserResponseHandler;
@ -41,7 +40,6 @@ import sig.utils.TimeUtils;
public class TwitchModule extends Module{ public class TwitchModule extends Module{
public String console="Twitch module goes here."; public String console="Twitch module goes here.";
Twitch manager = new Twitch();
final public static String USERDIR = sigIRC.BASEDIR+"sigIRC/users/"; final public static String USERDIR = sigIRC.BASEDIR+"sigIRC/users/";
final public static String SOUNDSDIR = sigIRC.BASEDIR+"sigIRC/sounds/"; final public static String SOUNDSDIR = sigIRC.BASEDIR+"sigIRC/sounds/";
final public static String FOLLOWERQUEUEFILE = USERDIR+"followers.txt"; final public static String FOLLOWERQUEUEFILE = USERDIR+"followers.txt";
@ -82,7 +80,6 @@ public class TwitchModule extends Module{
if (firstTime) { if (firstTime) {
CreateFollowerQueueLog(); CreateFollowerQueueLog();
} }
manager.setClientId("o4c2x0l3e82scgar4hpxg6m5dfjbem");
/*manager.streams().get("theduckishot", new StreamResponseHandler() { /*manager.streams().get("theduckishot", new StreamResponseHandler() {
@Override @Override
@ -244,7 +241,7 @@ public class TwitchModule extends Module{
} }
private void getFollowers(boolean firstTime) { private void getFollowers(boolean firstTime) {
manager.channels().getFollows(TextUtils.getActualChannelName(), new ChannelFollowsResponseHandler() { sigIRC.manager.channels().getFollows(TextUtils.getActualChannelName(), new ChannelFollowsResponseHandler() {
@Override @Override
public void onSuccess(int total, java.util.List<ChannelFollow> follows) { public void onSuccess(int total, java.util.List<ChannelFollow> follows) {
//System.out.println("Successfully found followers for channel "+sigIRC.channel+". Total: "+total); //System.out.println("Successfully found followers for channel "+sigIRC.channel+". Total: "+total);
@ -280,7 +277,7 @@ public class TwitchModule extends Module{
} }
private boolean isStreamOnline() { private boolean isStreamOnline() {
manager.streams().get(TextUtils.getActualChannelName(), new StreamResponseHandler() { sigIRC.manager.streams().get(TextUtils.getActualChannelName(), new StreamResponseHandler() {
@Override @Override
public void onFailure(Throwable arg0) { public void onFailure(Throwable arg0) {

@ -3,12 +3,20 @@ package sig;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.Timer; import javax.swing.Timer;
import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; 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.TouhouMotherModule;
import sig.modules.TwitchModule; import sig.modules.TwitchModule;
import sig.utils.FileUtils; import sig.utils.FileUtils;
import sig.utils.TextUtils;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -25,6 +33,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.Socket; import java.net.Socket;
import java.net.URL; import java.net.URL;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -41,6 +50,7 @@ public class sigIRC{
public static List<ScrollingText> textobj = new ArrayList<ScrollingText>(); public static List<ScrollingText> textobj = new ArrayList<ScrollingText>();
public static List<TextRow> rowobj = new ArrayList<TextRow>(); public static List<TextRow> rowobj = new ArrayList<TextRow>();
public static List<Emoticon> emoticons = new ArrayList<Emoticon>(); public static List<Emoticon> emoticons = new ArrayList<Emoticon>();
public static List<Emoticon> emoticon_queue = new ArrayList<Emoticon>();
public static List<TwitchEmote> twitchemoticons = new ArrayList<TwitchEmote>(); public static List<TwitchEmote> twitchemoticons = new ArrayList<TwitchEmote>();
public static List<CustomSound> customsounds = new ArrayList<CustomSound>(); public static List<CustomSound> customsounds = new ArrayList<CustomSound>();
public static List<Module> modules = new ArrayList<Module>(); public static List<Module> modules = new ArrayList<Module>();
@ -97,9 +107,11 @@ public class sigIRC{
public static int twitchmodule_newfollowerImgLogoSize=32; public static int twitchmodule_newfollowerImgLogoSize=32;
public static boolean testMode=false; public static boolean testMode=false;
public final static String TWITCHEMOTEURL = "https://static-cdn.jtvnw.net/emoticons/v1/"; public final static String TWITCHEMOTEURL = "https://static-cdn.jtvnw.net/emoticons/v1/";
public static long channel_id = -1;
public static void main(String[] args) { public static Twitch manager = new Twitch();
public static void main(String[] args) {
config = InitializeConfigurationFile(); config = InitializeConfigurationFile();
server = config.getProperty("server"); server = config.getProperty("server");
@ -139,6 +151,8 @@ public class sigIRC{
touhoumothermodule_width = config.getInteger("TOUHOUMOTHER_module_width",320); touhoumothermodule_width = config.getInteger("TOUHOUMOTHER_module_width",320);
touhoumothermodule_height = config.getInteger("TOUHOUMOTHER_module_height",312); touhoumothermodule_height = config.getInteger("TOUHOUMOTHER_module_height",312);
hardwareAcceleration = config.getBoolean("hardware_acceleration",true); hardwareAcceleration = config.getBoolean("hardware_acceleration",true);
manager.setClientId("o4c2x0l3e82scgar4hpxg6m5dfjbem");
//System.out.println(manager.auth().hasAccessToken());
DownloadAllRequiredDependencies(); DownloadAllRequiredDependencies();
@ -178,6 +192,7 @@ public class sigIRC{
public static void DownloadAllRequiredDependencies() { public static void DownloadAllRequiredDependencies() {
FileManager manager = new FileManager("sigIRC/oauthToken.txt"); manager.verifyAndFetchFileFromServer(); FileManager manager = new FileManager("sigIRC/oauthToken.txt"); manager.verifyAndFetchFileFromServer();
manager = new FileManager("sigIRC/Emotes/",true); 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/logs/",true); manager.verifyAndFetchFileFromServer();
manager = new FileManager("sigIRC/sounds/",true); manager.verifyAndFetchFileFromServer(); manager = new FileManager("sigIRC/sounds/",true); manager.verifyAndFetchFileFromServer();
manager = new FileManager("sigIRC/sounds/Glaceon_cry.wav"); 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;i<arr.length();i++) {
JSONObject emote = arr.getJSONObject(i);
int id = emote.getInt("id");
String name = emote.getString("code");
//System.out.println("Emote "+(i+1)+" has id "+id+" and code "+name+".");
try {
emoticon_queue.add(new SubEmoticon(name, new URL(TWITCHEMOTEURL+id+"/1.0"), channelName));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
}
});
//TwitchModule.streamOnline=true;
//return true;
}
private static void performTwitchEmoteUpdate() { private static void performTwitchEmoteUpdate() {
try { try {
JSONObject twitchemotes = FileUtils.readJsonFromUrl("https://twitchemotes.com/api_cache/v3/global.json"); JSONObject twitchemotes = FileUtils.readJsonFromUrl("https://twitchemotes.com/api_cache/v3/global.json");
@ -270,6 +322,14 @@ public class sigIRC{
emoticons.add(new Emoticon(name, new URL(TWITCHEMOTEURL+id+"/1.0"))); emoticons.add(new Emoticon(name, new URL(TWITCHEMOTEURL+id+"/1.0")));
} }
JSONObject subemotes = FileUtils.readJsonFromUrl("https://twitchemotes.com/api_cache/v3/subscriber.json"); JSONObject subemotes = FileUtils.readJsonFromUrl("https://twitchemotes.com/api_cache/v3/subscriber.json");
String[] sub_emotes = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/Emotes/subscribers.txt");
for (String s : sub_emotes) {
if (s.length()>0) {
s=s.trim();
//System.out.println("Got sub emote info for "+s);
downloadSubEmotes(subemotes,s);
}
}
/*JSONObject emotelist = twitchemotes.getJSONObject("emotes"); /*JSONObject emotelist = twitchemotes.getJSONObject("emotes");
JSONObject templatelist = twitchemotes.getJSONObject("template"); JSONObject templatelist = twitchemotes.getJSONObject("template");
String templateurl = templatelist.getString("small"); String templateurl = templatelist.getString("small");

Loading…
Cancel
Save