Skip to content

Commit

Permalink
Updated to v0.27-b3.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Oct 24, 2024
2 parents b6eeacf + c69f257 commit 7b63d60
Show file tree
Hide file tree
Showing 16 changed files with 213 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/chatty/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void defineSettings() {
settings.addLong("autoSaveSettings", 15);
settings.addBoolean("debugLogIrc", false);
settings.addBoolean("debugLogIrcFile", false);
settings.addString("ignoreError", "");
settings.addBoolean("autoRequestMods", false);

// Backup
Expand Down
2 changes: 2 additions & 0 deletions src/chatty/TwitchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,8 @@ public void run() {
}
});
}
} else if (command.equals("error")) {
Helper.unhandledException();
} else if (command.equals("getuserid")) {
if (parameter == null) {
g.printSystem("Parameter required.");
Expand Down
9 changes: 5 additions & 4 deletions src/chatty/TwitchConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ void onUsernotice(String channel, String message, MsgTags tags) {
months = tags.getInteger("msg-param-months", -1);
}
int giftMonths = tags.getInteger("msg-param-gift-months", -1);
int multiMonth = tags.getInteger("msg-param-multimonth-duration", -1);
// int multiMonth = tags.getInteger("msg-param-multimonth-duration", -1);

if (tags.isValue("msg-id", "announcement") && !StringUtil.isNullOrEmpty(login)) {
String displayName = tags.get("display-name", login);
Expand Down Expand Up @@ -1145,9 +1145,10 @@ void onUsernotice(String channel, String message, MsgTags tags) {
}
text += " "+recipient+" subscribed for "+months+" months!";
}
if (multiMonth > 1 && !text.contains("in advance")) {
text += " They subscribed for "+multiMonth+" months in advance.";
}
// Didn't seem to work the same way anymore, or at least not always
// if (multiMonth > 1 && !text.contains("in advance")) {
// text += " They subscribed for "+multiMonth+" months in advance.";
// }
listener.onSubscriberNotification(user, text, message, months, tags);
} else if (tags.isValue("msg-id", "charity") && login.equals("twitch")) {
listener.onUsernotice("Charity", user, text, message, tags);
Expand Down
66 changes: 60 additions & 6 deletions src/chatty/gui/Highlighter.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ else if (includeAllTextMatches) {
}

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

private void addMatch(User user, HighlightItem item) {
if (highlightNextMessages && user != null) {
String username = user.getName();
lastHighlighted.put(username, MiscUtil.ems());
lastHighlightedItem.put(username, item);
if (user == null) {
return;
}
if (item.followUp == 0) {
return;
}
if (!highlightNextMessages && item.followUp <= 0) {
return;
}
String username = user.getName();
lastHighlighted.put(username, MiscUtil.ems());
lastHighlightedItem.put(username, item);
}

private boolean hasRecentMatch(String fromUsername) {
clearRecentMatches();
return lastHighlighted.containsKey(fromUsername);
HighlightItem item = lastHighlightedItem.get(fromUsername);
if (item == null) {
return false;
}
return highlightNextMessages || item.followUp > 0;
}

private void clearRecentMatches() {
Expand Down Expand Up @@ -592,6 +603,7 @@ public boolean matches(Type type, String text, int msgStart, int msgEnd, Blackli
private boolean noSound;
private boolean hide;
private boolean noLog;
private int followUp = -1;

/**
* Replacement string for filtering parts of a message
Expand Down Expand Up @@ -1021,6 +1033,14 @@ else if (part.equals("hide")) {
else if (part.equals("!log")) {
noLog = true;
}
else if (part.startsWith("followup")) {
if (part.equals("followup")) {
followUp = 10;
}
else if (part.equals("followup|0")) {
followUp = 0;
}
}
else if (part.equals("block")) {
blacklistBlock = true;
}
Expand Down Expand Up @@ -1115,6 +1135,11 @@ else if (part.equals("hl")) {
} else if (part.equals(chatty.util.ForkUtil.FILTER_FORK_PREFIX)) {
// Do nothing.
}
else if (part.equals("highlighted")) {
addTagsItem("Highlighted by highlight list", null, t -> {
return t.isChattyHighlighted();
});
}
else if (part.equals("url") || part.equals("msgurl")) {
matchItems.add(new Item("Contains URL"+(part.startsWith("msg") ? " (msg)" : ""), null, true) {

Expand Down Expand Up @@ -1959,6 +1984,35 @@ public String getMatchInfo() {
result.append("Copy message to: ").append(routingTargets);
result.append("\n");
}
StringBuilder behaviour = new StringBuilder();
if (color != null) {
behaviour.append("Foreground: ").append(HtmlColors.getNamedColorString(color, true)).append("\n");
}
if (backgroundColor != null) {
behaviour.append("Background: ").append(HtmlColors.getNamedColorString(backgroundColor, true)).append("\n");
}
if (noNotification) {
behaviour.append("Don't show notification\n");
}
if (noSound) {
behaviour.append("Don't play sound\n");
}
if (hide) {
behaviour.append("Don't add to Highlighted/Ignored panel\n");
}
if (noLog) {
behaviour.append("Don't add to Highlighted/Ignored log file\n");
}
if (followUp == 0) {
behaviour.append("Don't highlight follow-up messages\n");
}
if (followUp > 0) {
behaviour.append("Highlight follow-up messages\n");
}
if (behaviour.length() > 0) {
result.append("\nIf message is matched:\n");
result.append(behaviour);
}
return result.toString();
}

Expand Down
11 changes: 11 additions & 0 deletions src/chatty/gui/MainGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
import chatty.util.history.HistoryUtil;
import chatty.util.seventv.WebPUtil;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import org.json.simple.JSONValue;

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

@Override
Expand Down Expand Up @@ -3617,6 +3621,7 @@ public void run() {
|| highlighter.getLastMatchItem().overrideIgnored()) {
ignored = false;
}
tags = MsgTags.addTag(tags, MsgTags.IS_HIGHLIGHTED, "true");
}
}

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

@Override
public void run() {
String ignore = client.settings.getString("ignoreError");
if (!ignore.isEmpty()
&& Pattern.compile(ignore).matcher(ErrorMessage.makeErrorText(error, previous)).find()) {
return;
}
int result = errorMessage.show(error, previous, client.getOpenChannels().size());
if (result == ErrorMessage.QUIT) {
exit();
Expand Down
2 changes: 1 addition & 1 deletion src/chatty/gui/components/ErrorMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private void addError(LogRecord error, LinkedList<LogRecord> previous,
debugMessage.append(errorText);
}

private String makeErrorText(LogRecord error, LinkedList<LogRecord> previous) {
public static String makeErrorText(LogRecord error, LinkedList<LogRecord> previous) {
StringBuilder b = new StringBuilder();
for (LogRecord r : previous) {
// Should never be null, but since this may contain null and it
Expand Down
8 changes: 8 additions & 0 deletions src/chatty/gui/components/help/help-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,9 @@ <h3><a name="Highlight_Meta_Matching">Meta Prefixes (Matching)</a></h3>
messages and regular user messages</li>
<li><code>config:hl</code> - Restrict matching to user messages
highlighted by using channel points</li>
<li><code>config:highlighted</code> - Applies when the message
has been highlighted through the Highlight list, doesn't
work for entries on the Highlight or Ignore list.</li>
<li><code>config:historic</code> - Applies to messages loaded
from the history service on channel join. This also allows
historic message to be matched for features that are
Expand Down Expand Up @@ -1215,6 +1218,11 @@ <h3><a name="Highlight_Meta_Behaviour">Meta Prefixes (Behaviour)</a></h3>
<li><code>config:!log</code> - Don't log the message to the
separate highlighted/ignored log file (may still be logged
to the channel log file)</li>
<li><code>config:followup</code> - Enable highlighting follow-up
messages from the same user within 10s, regardless of the
state of the setting in the Highlights settings
(<code>config:followup|0</code> to force off regardless of
setting).</li>
</ul>
</li>
<li><code>n:</code> to provide a note that is ignored for matching.
Expand Down
2 changes: 1 addition & 1 deletion 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.27-b2)</a></h1>
<h1><a name="top">Chatty (Version: 0.27-b3)</a></h1>
<table>
<tr>
<td valign="top">
Expand Down
26 changes: 25 additions & 1 deletion src/chatty/gui/components/menus/RoutingTargetContextMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import chatty.gui.DockedDialogHelper;
import chatty.gui.components.Channel;
import chatty.gui.components.routing.RoutingTargetSettings;
import java.awt.event.ActionEvent;
import java.util.List;

Expand All @@ -17,7 +18,8 @@ public RoutingTargetContextMenu(List<Channel> openChannels,
boolean fixedChannelEnabled,
boolean addAllEntry,
boolean showAll,
String currentChannel) {
String currentChannel,
int channelLogo) {

if (openChannels != null) {
addItem("clearAll", "Clear all");
Expand All @@ -34,6 +36,28 @@ public RoutingTargetContextMenu(List<Channel> openChannels,
else {
addItem("clearAll", "Clear");
}

final String logoSubmenu = "Channel Logos";
int defaultSize = RoutingTargetSettings.CHANNEL_LOGO_DEFAULT;
int currentSize = channelLogo;
for (int i=30;i>10;i -= 2) {
String action = "logoSize"+i;
if (i == defaultSize) {
addRadioItem(action, i+"px (default)", logoSubmenu, logoSubmenu);
}
else {
addRadioItem(action, i+"px", logoSubmenu, logoSubmenu);
}
if (i == currentSize) {
getItem(action).setSelected(true);
}
}
addSeparator(logoSubmenu);
addRadioItem("logoSize0", "Off", logoSubmenu, logoSubmenu);
if (currentSize == 0) {
getItem("logoSize0").setSelected(true);
}

}

@Override
Expand Down
6 changes: 6 additions & 0 deletions src/chatty/gui/components/menus/UsericonContextMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public UsericonContextMenu(CachedImage<Usericon> usericonImage, ContextMenuListe
this.listener = listener;
this.usericonImage = usericonImage;
Usericon usericon = usericonImage.getObject();

if (usericon.type == Usericon.Type.CHANNEL_LOGO) {
addItem("badgeImage", usericonImage.getSizeString(), ContextMenuHelper.ICON_IMAGE);
addItem("hideChannelLogo", "Hide channel logo");
return;
}

//--------------------
// General Description
Expand Down
4 changes: 3 additions & 1 deletion src/chatty/gui/components/routing/RoutingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ private RoutingTarget getTarget(String targetName) {
protected void updateSettings(String targetId, RoutingTargetSettings settings) {
entries.put(targetId, settings);
targets.get(targetId).settingsUpdated();
saveSettings();
}

public static String toId(String name) {
Expand All @@ -294,7 +295,8 @@ protected RoutingTargetSettings getSettings(String targetName) {
String targetId = toId(targetName);
RoutingTargetSettings entry = entries.get(targetId);
if (entry == null) {
entry = new RoutingTargetSettings(targetName, 1, true, false, "", 0, false, false);
entry = new RoutingTargetSettings(targetName, 1, true, false, "", 0, false, false,
RoutingTargetSettings.CHANNEL_LOGO_DEFAULT);
entries.put(targetId, entry);
}
return entry;
Expand Down
16 changes: 14 additions & 2 deletions src/chatty/gui/components/routing/RoutingTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public MutableAttributeSet getStyle(String type) {
MutableAttributeSet attr = new SimpleAttributeSet(styles.getStyle(type));
// For crossing out messages for timeouts, but never show separate message
attr.addAttribute(ChannelTextPane.Setting.SHOW_BANMESSAGES, false);
attr.addAttribute(ChannelTextPane.Setting.CHANNEL_LOGO_SIZE, 22);
attr.addAttribute(ChannelTextPane.Setting.CHANNEL_LOGO_SIZE, channelLogo());
return attr;
}
return styles.getStyle(type);
Expand Down Expand Up @@ -160,6 +160,7 @@ public JPopupMenu getContextMenu() {
//==========
public void settingsUpdated() {
setChannel(currentChannel, true);
refreshStyles();
}

private int multiChannel() {
Expand All @@ -174,6 +175,10 @@ private boolean channelFixed() {
return routingManager.getSettings(targetId).channelFixed;
}

private int channelLogo() {
return routingManager.getSettings(targetId).channelLogo;
}

//==========
// Channels
//==========
Expand Down Expand Up @@ -264,6 +269,12 @@ else if (e.getActionCommand().equals("dockToggleFixedChannel")) {
routingManager.updateSettings(targetId,
settings.setChannelFixed(!settings.channelFixed));
}
else if (e.getActionCommand().startsWith("logoSize")) {
int size = Integer.parseInt(e.getActionCommand().substring("logoSize".length()));
RoutingTargetSettings settings = routingManager.getSettings(targetId);
routingManager.updateSettings(targetId,
settings.setChannelLogo(size));
}
super.menuItemClicked(e);
}

Expand Down Expand Up @@ -387,7 +398,8 @@ public TextPane(MainGui main, StyleServer styleServer, boolean startAtBottom) {
routingManager.getSettings(targetId).channelFixed,
multiChannel() == 2,
routingManager.getSettings(targetId).showAll,
currentChannel));
currentChannel,
channelLogo()));
}

@Override
Expand Down
Loading

0 comments on commit 7b63d60

Please sign in to comment.