Skip to content

Commit

Permalink
Stream Status Writer, hide ignored users from GUI
Browse files Browse the repository at this point in the history
- Add follower/subscriber count to Stream Status Writer, add formatted numbers
  - Add follower/subscriber count to StreamInfo (set externally)
  - Some minor refactoring
- Add setting to hide users from joins/parts and userlist if on chat ignore list
- Add some commands to TAB Completion
- Update help
  • Loading branch information
tduva committed Jun 20, 2016
1 parent b5c7ecb commit 67f5f28
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 38 deletions.
1 change: 1 addition & 0 deletions src/chatty/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ void defineSettings() {
settings.addBoolean("ignoreShowNotDialog", false);
settings.addList("ignoredUsers", new ArrayList(), Setting.STRING);
settings.addList("ignoredUsersWhisper", new ArrayList(), Setting.STRING);
settings.addBoolean("ignoredUsersHideInGUI", true);

// Chat Logging
settings.addString("logMode", "always");
Expand Down
43 changes: 39 additions & 4 deletions src/chatty/TwitchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import chatty.util.api.EmoticonSizeCache;
import chatty.util.api.EmoticonUpdate;
import chatty.util.api.Emoticons;
import chatty.util.api.Follower;
import chatty.util.api.FollowerInfo;
import chatty.util.api.StreamInfo.ViewerStats;
import chatty.util.api.TwitchApi.RequestResult;
Expand Down Expand Up @@ -1616,7 +1617,29 @@ public void receivedUsericons(List<Usericon> icons) {
public void receivedFollowers(FollowerInfo followerInfo) {
g.setFollowerInfo(followerInfo);
followerInfoNames(followerInfo);

receivedFollowerOrSubscriberCount(followerInfo);
}

/**
* Set follower/subscriber count in StreamInfo and send to Stream Status
* Writer.
*
* @param followerInfo
*/
private void receivedFollowerOrSubscriberCount(FollowerInfo followerInfo) {
if (followerInfo.requestError) {
return;
}
StreamInfo streamInfo = api.getStreamInfo(followerInfo.stream, null);
boolean changed = false;
if (followerInfo.type == Follower.Type.SUBSCRIBER) {
changed = streamInfo.setSubscriberCount(followerInfo.total);
} else if (followerInfo.type == Follower.Type.FOLLOWER) {
changed = streamInfo.setFollowerCount(followerInfo.total);
}
if (changed && streamInfo.isValid()) {
streamStatusWriter.streamStatus(streamInfo);
}
}

@Override
Expand All @@ -1628,6 +1651,7 @@ public void newFollowers(FollowerInfo followerInfo) {
public void receivedSubscribers(FollowerInfo info) {
g.setSubscriberInfo(info);
followerInfoNames(info);
receivedFollowerOrSubscriberCount(info);
}

private void followerInfoNames(FollowerInfo info) {
Expand Down Expand Up @@ -2056,7 +2080,7 @@ public void onChannelLeft(String channel) {
@Override
public void onJoin(User user) {
String channel = user.getChannel();
if (settings.getBoolean("showJoinsParts")) {
if (settings.getBoolean("showJoinsParts") && showUserInGui(user)) {
g.printCompact(channel,"JOIN", user);
}
g.playSound("joinPart", channel);
Expand All @@ -2074,7 +2098,9 @@ public void onPart(User user) {

@Override
public void onUserUpdated(User user) {
g.updateUser(user);
if (showUserInGui(user)) {
g.updateUser(user);
}
g.updateUserinfo(user);
}

Expand Down Expand Up @@ -2132,7 +2158,16 @@ public void onJoinAttempt(String channel) {

@Override
public void onUserAdded(User user) {
g.addUser(user.getChannel(), user);
if (showUserInGui(user)) {
g.addUser(user.getChannel(), user);
}
}

private boolean showUserInGui(User user) {
if (!settings.getBoolean("ignoredUsersHideInGUI")) {
return true;
}
return !settings.listContains("ignoredUsers", user.nick);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/chatty/gui/components/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ private class InputCompletionServer implements AutoCompletionServer {
"set", "add", "clearSetting", "remove", "customCompletion",
"clearStreamChat", "getStreamChatSize", "setStreamChatSize", "streamChatTest", "openStreamChat",
"customEmotes", "reloadCustomEmotes", "addStreamHighlight", "openStreamHighlights",
"ignore", "unignore", "ignoreWhisper", "unignoreWhisper", "ignoreChat", "unignoreChat"
"ignore", "unignore", "ignoreWhisper", "unignoreWhisper", "ignoreChat", "unignoreChat",
"follow", "unfollow", "ffzws"
}));

private void updateSettings() {
Expand Down
30 changes: 30 additions & 0 deletions src/chatty/gui/components/help/help-releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,36 @@ <h2>
<a name="0.8.3">Version 0.8.3b</a> <a name="latest">(This one!)</a> (2016-??-??)
<a href="#top" class="top">[back to top]</a>
</h2>
<p></p>

<h3>Full Changelog</h3>
<pre>
Improvements
============
- Added info to login dialog when token was set through -token parameter
- Added setting to prevent token from being set through -token parameter when
login data is already available in Chatty
- Added support for FFZ Featured Emotes, which are frequently available in
channels of Speedrunning events (not to confuse with FFZ Feature Friday)
- Added ability to follow/unfollow channels, either through the context menus
(under Miscellaneous) or the new commands /follow and /unfollow
- Added simple search to tables in the Settings Dialog (click into a table
column and start typing, Backspace or wait to reset search)

- Restrict size of session debug log file
- Automatically exit application when too many errors occur (which should never
happen, but if it does, this should prevent affecting the rest of the system)

- Added state display for emote-only in titlebar
- Added display of timeout duration/reason (can be configured in the settings)

- Added some Mac specific shortcuts

Bugfixes
========
- Fix not being able to join (and other actions) through context menu for
channels that contain spaces in the display name
</pre>

<h2>
<a name="0.8.2">Version 0.8.2</a> (2016-04-26)
Expand Down
33 changes: 24 additions & 9 deletions src/chatty/gui/components/help/help-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ <h3>General Settings</h3>
effect when you change it.</em></li>
<li><strong>Enable FFZ Mod Icon</strong>: Show the FFZ Mod Icon instead of the regular
Mod Icon (where available). <em>Requires FrankerFaceZ setting to be enabled.</em></li>
<li><strong>Enable FFZ Featured Emotes</strong>: Show special FFZ emotes
available in some channels (mainly Speedrunning Events).</li>
<li><strong>Allow animated emotes</strong>: Show animated emotes (BTTV GIF emotes).</li>
<li><strong>Scale</strong>: The relative size of how emotes are displayed in chat (100% is regular size).</li>
<li><strong>Maximum Height</strong>: The maximum height of emotes in chat (in pixels). Use 0 to allow any height.</li>
Expand Down Expand Up @@ -1068,10 +1070,12 @@ <h2>
<a href="#top" class="top">[back to menu]</a>
</h2>
<h3>Other</h3>
<ul>
<li><strong>Inform me about new versions</strong>: Checks for new
versions every few days and outputs a message about it.</li>
<li><strong>Auto-Unhost when your stream goes live</strong>: Automatically
<dl class="dl-settings">
<dt>Inform me about new versions</dt>
<dd>Checks for new versions every few days and outputs a message about it.</dd>

<dt>Auto-Unhost when your stream goes live</dt>
<dd>Automatically
sends the <code>/unhost</code> command to your channel if you started
your stream session in the last 15 minutes and the stream status
changes (usually from offline -> live).<br />
Expand All @@ -1082,11 +1086,14 @@ <h3>Other</h3>
<code>autoUnhostStreams</code> setting, via
<code>/add autoUnhostStreams &lt;streamName&gt;</code>, in order to
tell Chatty that you are authorized/want to use the automatic <code>/unhost</code>
feature in that channel).</li>
<li><strong>Titlebar Addition</strong>: Prepend some arbitrary text to
the window title. This can be useful if you run several instances of
Chatty (to be able to tell them apart more easily).</li>
</ul>
feature in that channel).</dd>

<dt>Prepend to window title</dt>
<dd>Add some arbitrary text to the beginning of the window title. This
can be useful if you run several instances of Chatty (to be able to
tell them apart more easily).</dd>
</dl>

<h3>Write Stream Status</h3>
<p>You can let Chatty write information (title, game, viewercount) of a
certain stream to a file. The file will be written to the subfolder <code>exported</code> of the settings directory
Expand Down Expand Up @@ -1115,6 +1122,14 @@ <h3>Write Stream Status</h3>
<li><code>%title</code> - The title of the stream</li>
<li><code>%game</code> - The game of the stream</li>
<li><code>%viewers</code> - The current viewercount</li>
<li><code>%followers</code> - The current number of followers, only
updates correctly when the Followers Dialog for this channel is open
(Main Menu - Extra - Followers)</li>
<li><code>%subscribers</code> - The current number of subscribers, only
updates correctly when the Subscribers Dialog for this channel is
open (Main Menu - Extra - Subscribers)</li>
<li><code>%viewersf</code>, <code>%followersf</code>, <code>%subscribersf</code>
- The same as above, but formatted numbers (e.g. <code>1,532</code>)</li>
</ul>
<p>Example which will write two files (if joined to #joshimuz):</p>
<p style="padding-left:10px;">
Expand Down
15 changes: 15 additions & 0 deletions src/chatty/gui/components/help/help-troubleshooting.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h1><a name="top">Troubleshooting</a></h1>
<li><a href="#performance">Bad performance / OutOfMemoryError</a></li>
<li><a href="#livestreamer">Livestreamer won't run properly</a></li>
<li><a href="#font">Some characters in chat only show up as boxes / Fallback fonts</a></li>
<li><a href="#visual-glitches">Visual Artifacts/Glitches</a></li>
<li><a href="#log">Debug log</a></li>
</ul>
</li>
Expand Down Expand Up @@ -265,6 +266,20 @@ <h3>Find errors in debug.log</h3>
<p>See next section. Of course you'll have to navigate to the folder
manually.</p>

<h2>
<a name="visual-glitches">Visual Artifacts/Glitches</a>
<a href="#top" class="top">[back to menu]</a>
</h2>
<p>If you experience issues with the GUI where things are drawn on top of
eachother or repeating themselves, try the following:</p>
<ul>
<li>Check if you have any programs running that may interfere, for
example MSI Afterburner and add <code>javaw.exe</code> to an ignore
list or disable on-screen display support if possible.</li>
<li>If you have more than one monitor, try the other monitor. Not sure
why, but some people had it work better on another monitor.</li>
</ul>

<h2>
<a name="log">Debug log</a>
<a href="#top" class="top">[back to menu]</a>
Expand Down
6 changes: 6 additions & 0 deletions src/chatty/gui/components/settings/IgnoreSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ public IgnoredUsers(SettingsDialog d) {
+ "independant from the main ignore list, so the users are "
+ "ignored even if the Ignore system is disabled."), gbc);

gbc = d.makeGbc(0, 3, 2, 1);
add(d.addSimpleBooleanSetting("ignoredUsersHideInGUI",
"Hide ignored users (chat) from the userlist and joins/parts",
""),
gbc);

JButton closeButton = new JButton("Close");
closeButton.addActionListener(new ActionListener() {

Expand Down
2 changes: 2 additions & 0 deletions src/chatty/gui/components/settings/OtherSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class OtherSettings extends SettingsPanel {
+ "<li><code>%title</code> - The stream title</li>"
+ "<li><code>%game</code> - The game being played</li>"
+ "<li><code>%viewers</code> - The viewercount</li>"
+ "<li><code>%followers</code> / <code>%subscribers</code> - The follower/subscriber count (only when Follower/Subscriber List is open)</li>"
+ "<li><code>%viewersf</code> / <code>%followersf</code> / <code>%subscribersf</code> - Formatted numbers (e.g. 1,342)</li>"
+ "</ul>"
+ "<p>Example:</p>"
+ "<p><code> joshimuz status.txt %title %game (%viewers)<br />"
Expand Down
5 changes: 5 additions & 0 deletions src/chatty/util/StreamStatusWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ private boolean checkItemAndWrite(StreamInfo info, Item item) {
private String makeContent(StreamInfo info, String content) {
content = content.replace("%title", info.getTitle());
content = content.replace("%game", info.getGame());
content = content.replace("%viewersf", Helper.formatViewerCount(info.getViewers()));
content = content.replace("%followersf", Helper.formatViewerCount(info.getFollowerCount()));
content = content.replace("%subscribersf", Helper.formatViewerCount(info.getSubscriberCount()));
content = content.replace("%viewers", String.valueOf(info.getViewers()));
content = content.replace("%followers", String.valueOf(info.getFollowerCount()));
content = content.replace("%subscribers", String.valueOf(info.getSubscriberCount()));
return content;
}

Expand Down
7 changes: 6 additions & 1 deletion src/chatty/util/api/Follower.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
*/
public class Follower {

public enum Type { FOLLOWER, SUBSCRIBER }

public final Type type;

/**
* The name of the follower (display name, so it might not be all
* lowercase).
Expand Down Expand Up @@ -39,7 +43,8 @@ public class Follower {
* @param refollow Whether it was detected as a refollow
* @param newFollower Whether it is a new follower in this request
*/
public Follower(String name, long time, boolean refollow, boolean newFollower) {
public Follower(Type type, String name, long time, boolean refollow, boolean newFollower) {
this.type = type;
this.name = name;
this.time = time;
this.refollow = refollow;
Expand Down
10 changes: 8 additions & 2 deletions src/chatty/util/api/FollowerInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
public class FollowerInfo {

public final Follower.Type type;

/**
* The list of followers (not necessarily all followers).
*/
Expand Down Expand Up @@ -46,11 +48,13 @@ public class FollowerInfo {
/**
* Creates a new follower info object.
*
* @param type
* @param stream
* @param followers
* @param total
*/
public FollowerInfo(String stream, List<Follower> followers, int total) {
public FollowerInfo(Follower.Type type, String stream, List<Follower> followers, int total) {
this.type = type;
this.followers = followers;
this.total = total;
this.time = System.currentTimeMillis();
Expand All @@ -62,10 +66,12 @@ public FollowerInfo(String stream, List<Follower> followers, int total) {
/**
* Creates a new follower info object for when an error occured.
*
* @param type
* @param stream The name of the stream
* @param error The error message
*/
public FollowerInfo(String stream, String error) {
public FollowerInfo(Follower.Type type, String stream, String error) {
this.type = type;
this.followers = null;
this.total = -1;
this.time = System.currentTimeMillis();
Expand Down
Loading

0 comments on commit 67f5f28

Please sign in to comment.