Skip to content

Commit

Permalink
Automatic Subscriber Addressbook categories, uptime, some small fixes
Browse files Browse the repository at this point in the history
- Add feature to automatically add Addressbook category on Subscriber notification
- Add option to show more detailed uptime in titlebar
- Don't require channel for FFZ Feature Friday
- Update Release Information
- Update Help
  • Loading branch information
tduva committed Mar 11, 2016
1 parent 978d516 commit 59a1d01
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/chatty/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ void defineSettings() {

settings.addBoolean("simpleTitle", false);
settings.addBoolean("titleShowUptime", true);
settings.addBoolean("titleLongerUptime", true);
settings.addBoolean("titleShowViewerCount", true);
settings.addBoolean("titleShowChannelState", true);
settings.addBoolean("chatScrollbarAlways", false);
Expand Down Expand Up @@ -360,6 +361,8 @@ void defineSettings() {
settings.addString("abCommands", "add,set,remove");
settings.addString("abUniqueCats", "");
settings.addBoolean("abAutoImport", false);
settings.addString("abSubMonthsChan", "");
settings.addList("abSubMonths", new ArrayList(), Setting.LONG);

// Backup
settings.addLong("backupDelay", 1);
Expand Down
22 changes: 22 additions & 0 deletions src/chatty/TwitchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,28 @@ public void onChannelCleared(String channel) {
@Override
public void onWhisper(User user, String message, String emotes) {
}

@Override
public void onSubscriberNotification(String channel, String name, int months) {
System.out.println(channel+" "+name+" "+months);
if (!settings.getString("abSubMonthsChan").equalsIgnoreCase(channel)) {
return;
}
List<Long> monthsDef = new ArrayList<>();
settings.getList("abSubMonths", monthsDef);
long max = 0;
for (long entry : monthsDef) {
if (months >= entry && entry > max) {
max = entry;
}
}
if (name != null && max > 0) {
String cat = max+"months";
addressbook.add(name, cat);
LOGGER.info(String.format("[Subscriber] Added '%s' with category '%s'",
name, cat));
}
}

}

Expand Down
22 changes: 20 additions & 2 deletions src/chatty/TwitchConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public enum JoinError {
*/
private final int maxReconnectionAttempts = 20;
/**
* The time between reconnection attempts. The time for the first attempt,
* second time for the second attempt etc..
* The time in seconds between reconnection attempts. The first entry is the
* time for the first attempt, second entry for the second attempt and so
* on. The last entry is used for all further attempts.
*/
private final static int[] RECONNECTION_DELAY = new int[]{1, 5, 5, 10, 10, 60};

Expand Down Expand Up @@ -950,6 +951,21 @@ void onChannelMessage(String channel, String nick, String from, String text,
if (onChannel(channel)) {
if (settings.getBoolean("twitchnotifyAsInfo") && nick.equals("twitchnotify")) {
listener.onInfo(channel, "[Notification] " + text);
Pattern p = Pattern.compile("([^\\s]+) (?:just )?subscribed(?: for (\\d+) months in a row)?!");
Matcher m = p.matcher(text);
if (m.find()) {
String name = null;
int months = 1;
try {
name = m.group(1);
months = Integer.parseInt(m.group(2));
} catch (Exception ex) {
// Do nothing
}
if (name != null) {
listener.onSubscriberNotification(channel, name, months);
}
}
} else if (nick.equals("jtv")) {
specialMessage(text, channel);
} else {
Expand Down Expand Up @@ -1394,6 +1410,8 @@ public interface ConnectionListener {

void onChannelCleared(String channel);

void onSubscriberNotification(String channel, String name, int months);

}

}
4 changes: 4 additions & 0 deletions src/chatty/WhisperConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ public void onWhisper(User user, String message, String emotes) {
autoRespondedTo.remove(user.nick);
}
}

@Override
public void onSubscriberNotification(String channel, String name, int months) {
}

}

Expand Down
10 changes: 8 additions & 2 deletions src/chatty/gui/MainGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,8 @@ private void loadSettingsInternal() {
private static final String[] menuBooleanSettings = new String[]{
"showJoinsParts", "ontop", "showModMessages", "attachedWindows",
"simpleTitle", "globalHotkeysEnabled", "mainResizable", "streamChatResizable",
"titleShowUptime", "titleShowViewerCount", "titleShowChannelState"
"titleShowUptime", "titleShowViewerCount", "titleShowChannelState",
"titleLongerUptime"
};

/**
Expand Down Expand Up @@ -3003,8 +3004,13 @@ private String makeTitle(Channel channel, int state) {

String uptime = "";
if (client.settings.getBoolean("titleShowUptime")) {
uptime = DateTime.agoUptimeCompact2(
if (client.settings.getBoolean("titleLongerUptime")) {
uptime = DateTime.agoUptimeCompact2(
streamInfo.getTimeStartedWithPicnic());
} else {
uptime = DateTime.agoUptimeCompact(
streamInfo.getTimeStartedWithPicnic());
}
}
String numViewers = "|"+Helper.formatViewerCount(streamInfo.getViewers());
if (!client.settings.getBoolean("titleShowViewerCount")) {
Expand Down
1 change: 1 addition & 0 deletions src/chatty/gui/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public MainMenu(ActionListener actionListener, ItemListener itemListener) {

JMenu titleOptions = new JMenu("Titlebar");
addCheckboxItem(titleOptions, "titleShowUptime", "Stream Uptime");
addCheckboxItem(titleOptions, "titleLongerUptime", "More Detailed Uptime");
addCheckboxItem(titleOptions, "titleShowChannelState", "Channel State");
addCheckboxItem(titleOptions, "titleShowViewerCount", "Viewer/Chatter Count");

Expand Down
31 changes: 31 additions & 0 deletions src/chatty/gui/components/help/help-addressbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,37 @@ <h3><a name="unique-cats">Somewhat unique categories</a></h3>

<p>If you want to have more than one unique category, you can separate
several categories by comma: <code>/set abUniqueCats star,gold</code></p>


<h3><a name="unique-cats">Automatic Subscriber Categories</a></h3>
<p>This is an experimental feature that adds Subscribers automatically to
an Addressbook category, depending on how many months they subscribed.
This works on Subscriber Notifications in chat, so you have to be in the
channel at the time of the subscription for it to work.</p>
<p>First you need to do some configuration:</p>
<ul>
<li><code>/set abSubMonthsChan #&lt;yourchannel&gt;</code> - Set the
channel you want the feature enabled for</li>
<li><code>/add abSubMonths &lt;number&gt;</code> - Add one or several
subscription lenghts in months (repeat the command with a different
number to add more than one)</li>
<li><code>/remove abSubMonths &lt;number&gt;</code> - Remove a number
from the list</li>
</ul>

<p>The months represent the categories that are automatically added. For
example if you configured the months as <code>[3, 6, 12]</code>:</p>
<ul>
<li><code>.. subscribed for 3 months in a row!</code> would add that
user to the <code>3months</code> category</li>
<li><code>.. subscribed for 4 months in a row!</code> would add that
user to the <code>3months</code> category</li>
<li><code>.. subscribed for 11 months in a row!</code> would add that
user to the <code>6months</code> category</li>
<li><code>.. subscribed for 20 months in a row!</code> would add that
user to the <code>12months</code> category</li>
<li><code>.. just subscribed!</code> won't do anything</li>
</ul>
</body>
</html>

49 changes: 48 additions & 1 deletion src/chatty/gui/components/help/help-releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<h1><a name="top">Release Information</a></h1>

<p>
<a href="#0.8.1">0.8.2</a> |
<a href="#0.8.1">0.8.1</a> |
<a href="#0.8">0.8</a> |
<a href="#0.7.3">0.7.3</a> |
Expand All @@ -39,7 +40,53 @@ <h1><a name="top">Release Information</a></h1>
full list of changes.</p>

<h2>
<a name="0.8.1">Version 0.8.1</a> <a name="latest">(This one!)</a> (2015-08-10)
<a name="0.8.2">Version 0.8.2</a> <a name="latest">(This one!)</a> (2016-03-10)
<a href="#top" class="top">[back to top]</a>
</h2>
<pre>
Improvements
============
- Added some account info to User Info Dialog (click on "More..")
- Added auto-unhost feature (to unhost when your stream goes live, disabled by
default)
- Added single-instance mode, with the ability to join channels in the already
running instance
- Improved Emote Dialog info a bit
- Added `force_verify=true` parameter to Authorize URL (makes Twitch always ask
if you want to Authorize, makes sure you are logged in to the right account)
- Added new Twitch Player URL in context menu
- Added /emoteonly and /emoteonlyoff commands (in case they get enabled again)
- Added "emotesets" parameter to /refresh command
- Changed twitchemotes.com API URL (which is the source of emoteset information)
- Added some support for selecting the correct chat server
- Added auto-responses to whispers for ignored/non-whitelisted users (disabled
by default)
- Updated help

Settings
========
- Added more font sizes to GUI
- Added input font setting to GUI
- Added setting to prevent highlights from specific users (e.g. your own bots)
- Added setting to toggle closing of Emote Dialog on double-click on Emote
- Added setting to remember Status History table sorting order
- Added setting to toggle Usercolor correction
- Changed default for showing animated emotes to off
- Changed default for Min. Userlist Width to 0
- Made setting names case-insensitive (when using setting commands)

Bugfixes
========
- Fixed Admin Dialog sizing causing display issues
- Fixed spam protection message being displayed on the wrong channel
- Fixed new Twitch Emotes code being one character short
- Fixed autojoin not working sometimes
- Fixed framerate of GIFs, which may break some GIFs that worked before, but
prevents high CPU usage (displaying animated GIFs in Java is hard)
</pre>

<h2>
<a name="0.8.1">Version 0.8.1</a> (2015-08-10)
<a href="#top" class="top">[back to top]</a>
</h2>
<h3>Highlights / Important Information</h3>
Expand Down
21 changes: 17 additions & 4 deletions src/chatty/gui/components/help/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h1><a name="top">Chatty (Version: 0.8.2b3)</a></h1>
<strong>Chat basics</strong>
<ul class="menu">
<li><a href="#symbols">Symbols used in chat</a></li>
<li><a href="#userlist">Userlist</a></li>
<li><a href="#favorites">Favorites / History</a></li>
<li><a href="help-whisper.html">Whisper Feature</a></li>
</ul>
Expand Down Expand Up @@ -220,13 +221,22 @@ <h2>
<ul>
<li><code>/server &lt;host&gt;[:port]</code> - Connect to a custom server</li>
<li><code>/raw &lt;command&gt;</code> - Send a raw command to the server</li>
<li><code>/refresh &lt;emoticons/badges/ffz/ffzglobal/bttvemotes&gt;</code>
- Refresh the Twitch emoticons or badges (current channel) list or
refresh FrankerFaceZ channel emoticons (current channel) or global emoticons.
<li><code>/refresh &lt;emoticons/badges/ffz/ffzglobal/bttvemotes/emotesets&gt;</code>
- Refresh the given data from it's respective API:
<ul>
<li><code>emoticons</code>: Twitch Emotes</li>
<li><code>badges</code>: Twitch Badges (current channel)</li>
<li><code>ffz</code>: FFZ Emotes (current channel)</li>
<li><code>ffzglobal</code>: Global FFZ Emotes</li>
<li><code>bttvemotes</code>: BTTV Emotes (global and current channel)</li>
<li><code>emotesets</code>: Association between emoteset and
channel name, to display Twitch Subemotes info correctly
(twitchemotes.com API)</li>
</ul>
<em>This downloads the lists from the Internet, so don't use this
unless you need to (it's basicially like pressing reload in your
browser, just only for some stuff).</em></li>
<li><code>/changetoken &lt;token&gt;</code> - Checks if the given token
<li><code>/changetoken &lt;token&gt;</code> - Checks if the given token
is valid and sets it as new token if it is</li>
</ul>

Expand Down Expand Up @@ -402,6 +412,9 @@ <h2>
seconds too late (possibly longer). The user may even have already left
the channel again, but it just doesn't show yet.</p>

<p>The userlist can also take some time to initially load after you join a
channel, or not load at all sometimes.</p>

<p>Also note that the userlist doesn't necessarily have to do with who
watches your stream. A user can be logged into chat without watching the
stream and vice versa. Overall, just don't take the userlist too
Expand Down
2 changes: 1 addition & 1 deletion src/chatty/util/DateTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static String agoUptimeCompact2(long time) {
long hours = seconds/HOUR;
long minutes = (seconds%HOUR) / MINUTE;
if (hours > 0) {
return String.format("%dh%02dm", hours, minutes);
return String.format("%dh %dm", hours, minutes);
}
return String.format("%dm", minutes);
}
Expand Down
8 changes: 4 additions & 4 deletions src/chatty/util/FrankerFaceZ.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ private void parseResult(Type type, String stream, String result) {
} else if (type == Type.FEATURE_FRIDAY) {
emotes = FrankerFaceZParsing.parseSetEmotes(result, Emoticon.SubType.FEATURE_FRIDAY);
for (Emoticon emote : emotes) {
emote.setStream(featureFridayChannel);
if (featureFridayChannel != null) {
emote.setStream(featureFridayChannel);
}
}
}

Expand Down Expand Up @@ -273,9 +275,7 @@ private int parseFeatureFriday(String json) {
JSONObject root = (JSONObject)parser.parse(json);
int set = ((Number)root.get("set")).intValue();
featureFridayChannel = (String)root.get("channel");
if (featureFridayChannel != null) {
return set;
}
return set;
} catch (ParseException | NullPointerException | ClassCastException ex) {
// Assume no feature friday
}
Expand Down
3 changes: 2 additions & 1 deletion src/chatty/util/api/FollowerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ private Follower parseFollower(String stream, Object o) {
String display_name = (String)user.get("display_name");

return createFollowerItem(stream, display_name, time);
} catch (ClassCastException | NullPointerException | java.text.ParseException ex) {
} catch (ClassCastException | NullPointerException
| java.text.ParseException | NumberFormatException ex) {
LOGGER.warning("Error parsing entry of "+type+": "+o+" ["+ex+"]");
}
return null;
Expand Down

0 comments on commit 59a1d01

Please sign in to comment.