Skip to content

Commit 7b63d60

Browse files
committed
Updated to v0.27-b3.
2 parents b6eeacf + c69f257 commit 7b63d60

16 files changed

+213
-25
lines changed

src/chatty/SettingsManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public void defineSettings() {
112112
settings.addLong("autoSaveSettings", 15);
113113
settings.addBoolean("debugLogIrc", false);
114114
settings.addBoolean("debugLogIrcFile", false);
115+
settings.addString("ignoreError", "");
115116
settings.addBoolean("autoRequestMods", false);
116117

117118
// Backup

src/chatty/TwitchClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,6 +2067,8 @@ public void run() {
20672067
}
20682068
});
20692069
}
2070+
} else if (command.equals("error")) {
2071+
Helper.unhandledException();
20702072
} else if (command.equals("getuserid")) {
20712073
if (parameter == null) {
20722074
g.printSystem("Parameter required.");

src/chatty/TwitchConnection.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ void onUsernotice(String channel, String message, MsgTags tags) {
11171117
months = tags.getInteger("msg-param-months", -1);
11181118
}
11191119
int giftMonths = tags.getInteger("msg-param-gift-months", -1);
1120-
int multiMonth = tags.getInteger("msg-param-multimonth-duration", -1);
1120+
// int multiMonth = tags.getInteger("msg-param-multimonth-duration", -1);
11211121

11221122
if (tags.isValue("msg-id", "announcement") && !StringUtil.isNullOrEmpty(login)) {
11231123
String displayName = tags.get("display-name", login);
@@ -1145,9 +1145,10 @@ void onUsernotice(String channel, String message, MsgTags tags) {
11451145
}
11461146
text += " "+recipient+" subscribed for "+months+" months!";
11471147
}
1148-
if (multiMonth > 1 && !text.contains("in advance")) {
1149-
text += " They subscribed for "+multiMonth+" months in advance.";
1150-
}
1148+
// Didn't seem to work the same way anymore, or at least not always
1149+
// if (multiMonth > 1 && !text.contains("in advance")) {
1150+
// text += " They subscribed for "+multiMonth+" months in advance.";
1151+
// }
11511152
listener.onSubscriberNotification(user, text, message, months, tags);
11521153
} else if (tags.isValue("msg-id", "charity") && login.equals("twitch")) {
11531154
listener.onUsernotice("Charity", user, text, message, tags);

src/chatty/gui/Highlighter.java

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ else if (includeAllTextMatches) {
374374
}
375375

376376
// Then see if there is a recent match ("Highlight follow-up")
377-
if (highlightNextMessages && user != null && hasRecentMatch(user.getName())) {
377+
if (user != null && hasRecentMatch(user.getName())) {
378378
fillLastMatchVariables(lastHighlightedItem.get(user.getName()), null, -1, -1, null);
379379
return true;
380380
}
@@ -412,16 +412,27 @@ public void resetLastMatchVariables() {
412412
}
413413

414414
private void addMatch(User user, HighlightItem item) {
415-
if (highlightNextMessages && user != null) {
416-
String username = user.getName();
417-
lastHighlighted.put(username, MiscUtil.ems());
418-
lastHighlightedItem.put(username, item);
415+
if (user == null) {
416+
return;
419417
}
418+
if (item.followUp == 0) {
419+
return;
420+
}
421+
if (!highlightNextMessages && item.followUp <= 0) {
422+
return;
423+
}
424+
String username = user.getName();
425+
lastHighlighted.put(username, MiscUtil.ems());
426+
lastHighlightedItem.put(username, item);
420427
}
421428

422429
private boolean hasRecentMatch(String fromUsername) {
423430
clearRecentMatches();
424-
return lastHighlighted.containsKey(fromUsername);
431+
HighlightItem item = lastHighlightedItem.get(fromUsername);
432+
if (item == null) {
433+
return false;
434+
}
435+
return highlightNextMessages || item.followUp > 0;
425436
}
426437

427438
private void clearRecentMatches() {
@@ -592,6 +603,7 @@ public boolean matches(Type type, String text, int msgStart, int msgEnd, Blackli
592603
private boolean noSound;
593604
private boolean hide;
594605
private boolean noLog;
606+
private int followUp = -1;
595607

596608
/**
597609
* Replacement string for filtering parts of a message
@@ -1021,6 +1033,14 @@ else if (part.equals("hide")) {
10211033
else if (part.equals("!log")) {
10221034
noLog = true;
10231035
}
1036+
else if (part.startsWith("followup")) {
1037+
if (part.equals("followup")) {
1038+
followUp = 10;
1039+
}
1040+
else if (part.equals("followup|0")) {
1041+
followUp = 0;
1042+
}
1043+
}
10241044
else if (part.equals("block")) {
10251045
blacklistBlock = true;
10261046
}
@@ -1115,6 +1135,11 @@ else if (part.equals("hl")) {
11151135
} else if (part.equals(chatty.util.ForkUtil.FILTER_FORK_PREFIX)) {
11161136
// Do nothing.
11171137
}
1138+
else if (part.equals("highlighted")) {
1139+
addTagsItem("Highlighted by highlight list", null, t -> {
1140+
return t.isChattyHighlighted();
1141+
});
1142+
}
11181143
else if (part.equals("url") || part.equals("msgurl")) {
11191144
matchItems.add(new Item("Contains URL"+(part.startsWith("msg") ? " (msg)" : ""), null, true) {
11201145

@@ -1959,6 +1984,35 @@ public String getMatchInfo() {
19591984
result.append("Copy message to: ").append(routingTargets);
19601985
result.append("\n");
19611986
}
1987+
StringBuilder behaviour = new StringBuilder();
1988+
if (color != null) {
1989+
behaviour.append("Foreground: ").append(HtmlColors.getNamedColorString(color, true)).append("\n");
1990+
}
1991+
if (backgroundColor != null) {
1992+
behaviour.append("Background: ").append(HtmlColors.getNamedColorString(backgroundColor, true)).append("\n");
1993+
}
1994+
if (noNotification) {
1995+
behaviour.append("Don't show notification\n");
1996+
}
1997+
if (noSound) {
1998+
behaviour.append("Don't play sound\n");
1999+
}
2000+
if (hide) {
2001+
behaviour.append("Don't add to Highlighted/Ignored panel\n");
2002+
}
2003+
if (noLog) {
2004+
behaviour.append("Don't add to Highlighted/Ignored log file\n");
2005+
}
2006+
if (followUp == 0) {
2007+
behaviour.append("Don't highlight follow-up messages\n");
2008+
}
2009+
if (followUp > 0) {
2010+
behaviour.append("Highlight follow-up messages\n");
2011+
}
2012+
if (behaviour.length() > 0) {
2013+
result.append("\nIf message is matched:\n");
2014+
result.append(behaviour);
2015+
}
19622016
return result.toString();
19632017
}
19642018

src/chatty/gui/MainGui.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
import chatty.util.history.HistoryUtil;
125125
import chatty.util.seventv.WebPUtil;
126126
import java.util.function.Consumer;
127+
import java.util.regex.Pattern;
127128
import org.json.simple.JSONValue;
128129

129130
/**
@@ -2589,6 +2590,9 @@ else if (e.getActionCommand().startsWith("hideUsericonOfBadgeType")) {
25892590
else if (e.getActionCommand().equals("badgeImage")) {
25902591
UrlOpener.openUrlPrompt(getActiveWindow(), usericonImage.getSourceUrl(), true);
25912592
}
2593+
else if (e.getActionCommand().equals("hideChannelLogo")) {
2594+
JOptionPane.showMessageDialog(getActiveWindow(), "Custom Tabs/Stream Chat: Right-click on empty space to open context menu.");
2595+
}
25922596
}
25932597

25942598
@Override
@@ -3617,6 +3621,7 @@ public void run() {
36173621
|| highlighter.getLastMatchItem().overrideIgnored()) {
36183622
ignored = false;
36193623
}
3624+
tags = MsgTags.addTag(tags, MsgTags.IS_HIGHLIGHTED, "true");
36203625
}
36213626
}
36223627

@@ -4111,6 +4116,7 @@ private boolean printInfo(Channel channel, InfoMessage message) {
41114116
|| highlighter.getLastMatchItem().overrideIgnored()) {
41124117
ignored = false;
41134118
}
4119+
tags = MsgTags.addTag(tags, MsgTags.IS_HIGHLIGHTED, "true");
41144120
}
41154121
}
41164122
if (!ignored) {
@@ -5955,6 +5961,11 @@ public void error(final LogRecord error, final LinkedList<LogRecord> previous) {
59555961

59565962
@Override
59575963
public void run() {
5964+
String ignore = client.settings.getString("ignoreError");
5965+
if (!ignore.isEmpty()
5966+
&& Pattern.compile(ignore).matcher(ErrorMessage.makeErrorText(error, previous)).find()) {
5967+
return;
5968+
}
59585969
int result = errorMessage.show(error, previous, client.getOpenChannels().size());
59595970
if (result == ErrorMessage.QUIT) {
59605971
exit();

src/chatty/gui/components/ErrorMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private void addError(LogRecord error, LinkedList<LogRecord> previous,
245245
debugMessage.append(errorText);
246246
}
247247

248-
private String makeErrorText(LogRecord error, LinkedList<LogRecord> previous) {
248+
public static String makeErrorText(LogRecord error, LinkedList<LogRecord> previous) {
249249
StringBuilder b = new StringBuilder();
250250
for (LogRecord r : previous) {
251251
// Should never be null, but since this may contain null and it

src/chatty/gui/components/help/help-settings.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,9 @@ <h3><a name="Highlight_Meta_Matching">Meta Prefixes (Matching)</a></h3>
10921092
messages and regular user messages</li>
10931093
<li><code>config:hl</code> - Restrict matching to user messages
10941094
highlighted by using channel points</li>
1095+
<li><code>config:highlighted</code> - Applies when the message
1096+
has been highlighted through the Highlight list, doesn't
1097+
work for entries on the Highlight or Ignore list.</li>
10951098
<li><code>config:historic</code> - Applies to messages loaded
10961099
from the history service on channel join. This also allows
10971100
historic message to be matched for features that are
@@ -1215,6 +1218,11 @@ <h3><a name="Highlight_Meta_Behaviour">Meta Prefixes (Behaviour)</a></h3>
12151218
<li><code>config:!log</code> - Don't log the message to the
12161219
separate highlighted/ignored log file (may still be logged
12171220
to the channel log file)</li>
1221+
<li><code>config:followup</code> - Enable highlighting follow-up
1222+
messages from the same user within 10s, regardless of the
1223+
state of the setting in the Highlights settings
1224+
(<code>config:followup|0</code> to force off regardless of
1225+
setting).</li>
12181226
</ul>
12191227
</li>
12201228
<li><code>n:</code> to provide a note that is ignored for matching.

src/chatty/gui/components/help/help.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="stylesheet" type="text/css" href="style.css" />
66
</head>
77
<body>
8-
<h1><a name="top">Chatty (Version: 0.27-b2)</a></h1>
8+
<h1><a name="top">Chatty (Version: 0.27-b3)</a></h1>
99
<table>
1010
<tr>
1111
<td valign="top">

src/chatty/gui/components/menus/RoutingTargetContextMenu.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import chatty.gui.DockedDialogHelper;
55
import chatty.gui.components.Channel;
6+
import chatty.gui.components.routing.RoutingTargetSettings;
67
import java.awt.event.ActionEvent;
78
import java.util.List;
89

@@ -17,7 +18,8 @@ public RoutingTargetContextMenu(List<Channel> openChannels,
1718
boolean fixedChannelEnabled,
1819
boolean addAllEntry,
1920
boolean showAll,
20-
String currentChannel) {
21+
String currentChannel,
22+
int channelLogo) {
2123

2224
if (openChannels != null) {
2325
addItem("clearAll", "Clear all");
@@ -34,6 +36,28 @@ public RoutingTargetContextMenu(List<Channel> openChannels,
3436
else {
3537
addItem("clearAll", "Clear");
3638
}
39+
40+
final String logoSubmenu = "Channel Logos";
41+
int defaultSize = RoutingTargetSettings.CHANNEL_LOGO_DEFAULT;
42+
int currentSize = channelLogo;
43+
for (int i=30;i>10;i -= 2) {
44+
String action = "logoSize"+i;
45+
if (i == defaultSize) {
46+
addRadioItem(action, i+"px (default)", logoSubmenu, logoSubmenu);
47+
}
48+
else {
49+
addRadioItem(action, i+"px", logoSubmenu, logoSubmenu);
50+
}
51+
if (i == currentSize) {
52+
getItem(action).setSelected(true);
53+
}
54+
}
55+
addSeparator(logoSubmenu);
56+
addRadioItem("logoSize0", "Off", logoSubmenu, logoSubmenu);
57+
if (currentSize == 0) {
58+
getItem("logoSize0").setSelected(true);
59+
}
60+
3761
}
3862

3963
@Override

src/chatty/gui/components/menus/UsericonContextMenu.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public UsericonContextMenu(CachedImage<Usericon> usericonImage, ContextMenuListe
2121
this.listener = listener;
2222
this.usericonImage = usericonImage;
2323
Usericon usericon = usericonImage.getObject();
24+
25+
if (usericon.type == Usericon.Type.CHANNEL_LOGO) {
26+
addItem("badgeImage", usericonImage.getSizeString(), ContextMenuHelper.ICON_IMAGE);
27+
addItem("hideChannelLogo", "Hide channel logo");
28+
return;
29+
}
2430

2531
//--------------------
2632
// General Description

src/chatty/gui/components/routing/RoutingManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ private RoutingTarget getTarget(String targetName) {
280280
protected void updateSettings(String targetId, RoutingTargetSettings settings) {
281281
entries.put(targetId, settings);
282282
targets.get(targetId).settingsUpdated();
283+
saveSettings();
283284
}
284285

285286
public static String toId(String name) {
@@ -294,7 +295,8 @@ protected RoutingTargetSettings getSettings(String targetName) {
294295
String targetId = toId(targetName);
295296
RoutingTargetSettings entry = entries.get(targetId);
296297
if (entry == null) {
297-
entry = new RoutingTargetSettings(targetName, 1, true, false, "", 0, false, false);
298+
entry = new RoutingTargetSettings(targetName, 1, true, false, "", 0, false, false,
299+
RoutingTargetSettings.CHANNEL_LOGO_DEFAULT);
298300
entries.put(targetId, entry);
299301
}
300302
return entry;

src/chatty/gui/components/routing/RoutingTarget.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public MutableAttributeSet getStyle(String type) {
111111
MutableAttributeSet attr = new SimpleAttributeSet(styles.getStyle(type));
112112
// For crossing out messages for timeouts, but never show separate message
113113
attr.addAttribute(ChannelTextPane.Setting.SHOW_BANMESSAGES, false);
114-
attr.addAttribute(ChannelTextPane.Setting.CHANNEL_LOGO_SIZE, 22);
114+
attr.addAttribute(ChannelTextPane.Setting.CHANNEL_LOGO_SIZE, channelLogo());
115115
return attr;
116116
}
117117
return styles.getStyle(type);
@@ -160,6 +160,7 @@ public JPopupMenu getContextMenu() {
160160
//==========
161161
public void settingsUpdated() {
162162
setChannel(currentChannel, true);
163+
refreshStyles();
163164
}
164165

165166
private int multiChannel() {
@@ -174,6 +175,10 @@ private boolean channelFixed() {
174175
return routingManager.getSettings(targetId).channelFixed;
175176
}
176177

178+
private int channelLogo() {
179+
return routingManager.getSettings(targetId).channelLogo;
180+
}
181+
177182
//==========
178183
// Channels
179184
//==========
@@ -264,6 +269,12 @@ else if (e.getActionCommand().equals("dockToggleFixedChannel")) {
264269
routingManager.updateSettings(targetId,
265270
settings.setChannelFixed(!settings.channelFixed));
266271
}
272+
else if (e.getActionCommand().startsWith("logoSize")) {
273+
int size = Integer.parseInt(e.getActionCommand().substring("logoSize".length()));
274+
RoutingTargetSettings settings = routingManager.getSettings(targetId);
275+
routingManager.updateSettings(targetId,
276+
settings.setChannelLogo(size));
277+
}
267278
super.menuItemClicked(e);
268279
}
269280

@@ -387,7 +398,8 @@ public TextPane(MainGui main, StyleServer styleServer, boolean startAtBottom) {
387398
routingManager.getSettings(targetId).channelFixed,
388399
multiChannel() == 2,
389400
routingManager.getSettings(targetId).showAll,
390-
currentChannel));
401+
currentChannel,
402+
channelLogo()));
391403
}
392404

393405
@Override

0 commit comments

Comments
 (0)