Skip to content

Commit

Permalink
0.8.3b2, FFZ-WS improvements
Browse files Browse the repository at this point in the history
- Change version to 0.8.3b2
- Emoticon: Change single info to set of info strings
- Change VERSION constant to include beta versions (0.8.3b2)
  - Change Version checker accordingly to ignore everything after the b (for now at least)
- FFZ-WS: Enabled by default
- FFZ-WS: Change connecting/reconnecting to support choosing a random server when reconnecting
- FFZ-WS: Set Origin header to empty
- FFZ-WS: Add debug output for sent/received messages
- FFZ-WS: Add status command
- Add info of all sets to Event emote, so emotes are displayed correctly in the Emote Dialog if several sets contain the same emote
- Update help
- Add Tyrus library info to readme/help
  • Loading branch information
tduva committed May 25, 2016
1 parent 224b261 commit 0b78430
Show file tree
Hide file tree
Showing 21 changed files with 393 additions and 98 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ External Libraries/Resources
(for the license text see the APACHE_LICENSE file
or http://www.apache.org/licenses/LICENSE-2.0).

* Tyrus:
* Files: `assets/lib/tyrus-standalone-client-1.12.jar`
* Website: https://tyrus.java.net
* License: "CDDL 1.1" and "GPL 2 with CPE"
(see https://tyrus.java.net/license.html)

* Favorites Icon by Everaldo Coelho:
* File: `star.png`
* Source: https://www.iconfinder.com/icons/17999/bookmark_favorite_star_icon
Expand Down
5 changes: 5 additions & 0 deletions assets/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ External Libraries
License: "Apache License 2.0"
http://www.apache.org/licenses/LICENSE-2.0

* Tyrus [lib/tyrus-standalone-client-1.12.jar]
Website: https://tyrus.java.net
License: "CDDL 1.1" and "GPL 2 with CPE"
https://tyrus.java.net/license.html

* Favorites Icon [star.png] by Everaldo Coelho
Source: https://www.iconfinder.com/icons/17999/bookmark_favorite_star_icon
License: LGPL
Expand Down
16 changes: 16 additions & 0 deletions src/chatty/AddressManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
Expand Down Expand Up @@ -116,4 +117,19 @@ public static List<Integer> parsePorts(String ports) {
return parsedPorts;
}

// Testing stuff
public static void main(String[] args) {
AddressManager m = new AddressManager();
try {
for (int i=0;i<60;i++) {
InetSocketAddress addr = m.getAddress("irc.chat.twitch.tv", "6697,6667,443,80");
System.out.println(addr);
m.addError(addr);
}

} catch (UnknownHostException ex) {
Logger.getLogger(AddressManager.class.getName()).log(Level.SEVERE, null, ex);
}
}

}
6 changes: 4 additions & 2 deletions src/chatty/Chatty.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public class Chatty {
public static final String REDIRECT_URI = "http://127.0.0.1:61324/token/";

/**
* Version number of this version of Chatty
* Version number of this version of Chatty, consisting of numbers seperated
* by points. May contain a single "b" for beta versions, anything following
* it will be ignored for version checking.
*/
public static final String VERSION = "0.8.3b";
public static final String VERSION = "0.8.3b2";

/**
* Enable Version Checker (if you compile and distribute this yourself, you
Expand Down
8 changes: 8 additions & 0 deletions src/chatty/TwitchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,9 @@ else if (command.equals("ffz")) {
else if (command.equals("ffzglobal")) {
commandFFZ(null);
}
else if (command.equals("ffzws")) {
g.printSystem("[FFZ-WS] Status: "+frankerFaceZ.getWsStatus());
}
else if (command.equals("refresh")) {
commandRefresh(channel, parameter);
}
Expand Down Expand Up @@ -1832,6 +1835,11 @@ public void botNamesReceived(Set<String> botNames) {
botNameManager.addBotNames(null, botNames);
}
}

@Override
public void wsInfo(String info) {
g.printDebugFFZ(info);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/chatty/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ private void versionReceived(String newVersion) {
String currentVersion = VERSION;
// Check if current is beta version
boolean isBetaVersion = false;
if (currentVersion.endsWith("b")) {
currentVersion = currentVersion.substring(0, currentVersion.length() - 1);
if (currentVersion.contains("b")) {
currentVersion = currentVersion.substring(0, currentVersion.indexOf("b"));
isBetaVersion = true;
}
int compare = compareVersions(currentVersion, newVersion);
Expand Down
10 changes: 10 additions & 0 deletions src/chatty/gui/MainGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -2724,6 +2724,16 @@ public void run() {
}
}

public void printDebugFFZ(final String line) {
SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {
debugWindow.printLineFFZ(line);
}
});
}

/**
* Outputs a line to the debug window
*
Expand Down
12 changes: 12 additions & 0 deletions src/chatty/gui/components/DebugWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class DebugWindow extends JFrame {
private final JCheckBox logIrc = new JCheckBox("Irc log", false);
private final JTextArea text;
private final JTextArea textIrcLog;
private final JTextArea textFFZLog;

public DebugWindow(ItemListener listener) {
setTitle("Debug");
Expand All @@ -50,10 +51,17 @@ public DebugWindow(ItemListener listener) {
textIrcLog.setCaret(caret);
JScrollPane scrollIrcLog = new JScrollPane(textIrcLog);

// Irc log
textFFZLog = new JTextArea();
textFFZLog.setEditable(false);
textFFZLog.setCaret(caret);
JScrollPane scrollFFZLog = new JScrollPane(textFFZLog);

// Tabs
JTabbedPane tabs = new JTabbedPane();
tabs.addTab("Log", scroll);
tabs.addTab("Irc log", scrollIrcLog);
tabs.addTab("FFZ-WS", scrollFFZLog);

// Settings (Checkboxes)
logIrc.setToolTipText("Logging IRC traffic can reduce performance");
Expand All @@ -80,6 +88,10 @@ public void printLineIrc(String line) {
printLine(textIrcLog, line);
}

public void printLineFFZ(String line) {
printLine(textFFZLog, line);
}

private void printLine(JTextArea text, String line) {
try {
Document doc = text.getDocument();
Expand Down
54 changes: 42 additions & 12 deletions src/chatty/gui/components/EmotesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -701,33 +701,35 @@ protected void updateEmotes() {
} else {
// FFZ/BTTV
Set<Emoticon> channelEmotes = emoteManager.getEmoticons(stream);

// Split Event/Regular emotes into separate structures
Set<Emoticon> regular = new HashSet<>();
Map<String, Set<Emoticon>> event = new HashMap<>();

for (Emoticon emote : channelEmotes) {
if (emote.type == Emoticon.Type.FFZ
&& emote.subType == Emoticon.SubType.EVENT) {
String info = emote.info;
if (!event.containsKey(info)) {
event.put(info, new HashSet<Emoticon>());
for (String info : emote.getInfos()) {
if (!event.containsKey(info)) {
event.put(info, new HashSet<Emoticon>());
}
event.get(info).add(emote);
}
event.get(info).add(emote);
}
else {
} else {
regular.add(emote);
}
}

if (channelEmotes.isEmpty()) {
addTitle("No emotes found for #" + stream);
addSubtitle("No FFZ or BTTV emotes found.", false);
} else {
addEmotes(regular, "Emotes specific to #" + stream);
for (String info : event.keySet()) {
addEmotes(event.get(info), "Featured "+info);
addEmotes(event.get(info), "Featured " + info);
}
}

// Subemotes
// Subscriber Emotes
int emoteset = emoteManager.getEmotesetFromStream(stream);
if (emoteset != -1) {
Set<Emoticon> subEmotes = emoteManager.getEmoticons(emoteset);
Expand Down Expand Up @@ -833,7 +835,8 @@ protected void updateEmotes() {
lgbc.insets = new Insets(4, 4, 4, 4);

addInfo(panel2, "Code:", emote.code);
addInfo(panel2, "Type:", emote.type.toString());
String featured = emote.subType == Emoticon.SubType.EVENT ? " (Featured)" : "";
addInfo(panel2, "Type:", emote.type.toString()+featured);
if (emote.numericId > Emoticon.ID_UNDEFINED) {
addInfo(panel2, "Emote ID:", ""+emote.numericId);
}
Expand All @@ -855,8 +858,11 @@ protected void updateEmotes() {
if (emote.creator != null) {
addInfo(panel2, "Emote by:", emote.creator);
}
if (emote.info != null) {
addInfo(panel2, "Info:", emote.info);

// Info
featured = emote.subType == Emoticon.SubType.EVENT ? "Featured " : "";
for (String info : emote.getInfos()) {
addInfo(panel2, featured+info);
}

gbc.fill = GridBagConstraints.HORIZONTAL;
Expand Down Expand Up @@ -886,6 +892,13 @@ private void addScaledEmote(Emoticon emote, JPanel panel, float scale, String la
lgbc.gridx++;
}

/**
* Adds a info line with separated key and value.
*
* @param panel
* @param key
* @param value
*/
private void addInfo(JPanel panel, String key, String value) {
lgbc.gridx = 0;
lgbc.anchor = GridBagConstraints.WEST;
Expand All @@ -899,6 +912,23 @@ private void addInfo(JPanel panel, String key, String value) {
lgbc.gridy++;
}

/**
* Adds a full-width info line.
*
* @param panel
* @param value
*/
private void addInfo(JPanel panel, String value) {
lgbc.gridx = 0;
lgbc.gridwidth = 2;
lgbc.anchor = GridBagConstraints.CENTER;

panel.add(new JLabel(StringUtil.shortenTo(value, 35, 20)), lgbc);

lgbc.gridwidth = 1;
lgbc.gridy++;
}

}

}
8 changes: 4 additions & 4 deletions src/chatty/gui/components/help/help-guide_folders.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ <h3>Restore backup</h3>
<ol>
<li>Prepare & Locate Backup Folder
<ul>
<li>Make sure Chatty is not running. Settings are saved when
Chatty is closed, so if you change setting files manually
while it is running your manual changes would just be
overwritten once you close Chatty.</li>
<li>Enter <code>/openBackupDir</code> to open the Backup folder
(or enter <code>/dir</code> and navigate to the Backup folder
manually).</li>
<li>There should be several files in the format <code>backup_x_&lt;name&gt;</code>,
these represent the separate batches of backups.</li>
<li>After that, make sure Chatty is not running. Settings are saved when
Chatty is closed, so if you change setting files manually
while it is running your manual changes would just be
overwritten once you close Chatty.</li>
</ul>
</li>
<li>Find latest backup and rename
Expand Down
6 changes: 3 additions & 3 deletions src/chatty/gui/components/help/help-setting_commands.html
Original file line number Diff line number Diff line change
Expand Up @@ -447,21 +447,21 @@ <h3><a name="streamhighlights">Stream Highlights</a></h3>
<td>Channel name (with leading #) or empty</td>
<td><em>empty</em></td>
<td>Allows moderators in the given channel to run the
!addStreamHighlight command.</td>
!highlight command.</td>
</tr>
<tr class="settingExclusive">
<td class="setting">streamHighlightChannelRespond</td>
<td colspan="2">Boolean</td>
<td>false</td>
<td>If this is enabled, Chatty sends a message to chat when
a moderator uses the !addStreamHighlight command. Otherwise
a moderator uses the !hghlight command. Otherwise
the response to the command is only shown locally.</td>
</tr>
<tr class="settingExclusive">
<td class="setting">streamHighlightCommand</td>
<td>String</td>
<td>The command to use for moderators</td>
<td><em>!addstreamhighlight</em></td>
<td><em>!highlight</em></td>
<td>Change this to define the command that can be used by
mods to add stream highlights in the channel defined with
the <code>streamHighlightChannel</code> setting.</td>
Expand Down
6 changes: 4 additions & 2 deletions src/chatty/gui/components/help/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1><a name="top">Chatty (Version: 0.8.3b1)</a></h1>
<h1><a name="top">Chatty (Version: 0.8.3b2)</a></h1>
<table>
<tr>
<td valign="top">
Expand Down Expand Up @@ -1115,7 +1115,7 @@ <h2>

<h3>Allow your moderators to add highlights</h3>
<p>You can also let your moderators add stream highlights
(<code>!addStreamHighlight [comment]</code>), but you first have to
(<code>!highlight [comment]</code>), but you first have to
change some <a href="help-setting_commands.html#streamhighlights">settings</a>:</p>

<ul>
Expand Down Expand Up @@ -1297,6 +1297,8 @@ <h2>
the <a href="http://www.apache.org/licenses/LICENSE-2.0">"Apache License 2.0"</a>.</li>
<li>Versions with Windows Global Hotkey support use <a href="https://code.google.com/p/jintellitype/">JIntellitype</a>,
which is licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">"Apache License 2.0"</a>.</li>
<li>Using the <a href="https://tyrus.java.net">Tyrus</a> standalone websocket client library licensed under
<a href="https://tyrus.java.net/license.html">CDDL 1.1 and GPL 2 with CPE</a>.</li>
<li><a href="https://www.iconfinder.com/icons/17999/bookmark_favorite_star_icon">Favorite Icon</a>
(Star Icon) by Everaldo Coelho under <a href="http://www.gnu.org/licenses/lgpl.html">LGPL</a>.</li>
<li>Several Icons from the <a href="http://tango.freedesktop.org/Tango_Icon_Library">Tango Icon Theme</a>
Expand Down
15 changes: 10 additions & 5 deletions src/chatty/gui/components/menus/EmoteContextMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ public EmoteContextMenu(EmoticonImage emoteImage, ContextMenuListener listener)
} else if (emote.type == Emoticon.Type.CUSTOM) {
addItem("", "Custom Emote");
}
if (emote.info != null) {
if (emote.subType == Emoticon.SubType.EVENT) {
addItem("", "Featured "+emote.info);
} else {
addItem("", emote.info);

// Info
if (emote.subType == Emoticon.SubType.EVENT) {
for (String info : emote.getInfos()) {
addItem("", "Featured " + info);
}
} else {
for (String info : emote.getInfos()) {
addItem("", info);
}
}

addStreamSubmenu(emote);
}

Expand Down
4 changes: 2 additions & 2 deletions src/chatty/util/JSONUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public static boolean getBoolean(JSONObject data, Object key, boolean errorValue
return errorValue;
}

public static String listToJSON(String... args) {
public static String listToJSON(Object... args) {
JSONArray o = new JSONArray();
for (String a : args) {
for (Object a : args) {
o.add(a);
}
return o.toJSONString();
Expand Down
Loading

0 comments on commit 0b78430

Please sign in to comment.