Skip to content

Commit

Permalink
Updated to v0.24-b1.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Feb 22, 2023
2 parents a7cff4e + 6066caa commit 56a797e
Show file tree
Hide file tree
Showing 24 changed files with 596 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/chatty/Chatty.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Chatty {
* by points. May contain a single "b" for beta versions, which are counted
* as older (so 0.8.7b4 is older than 0.8.7).
*/
public static final String VERSION = "0.23.0.168";
public static final String VERSION = "0.24.0.168";

/**
* Enable Version Checker (if you compile and distribute this yourself, you
Expand Down
4 changes: 4 additions & 0 deletions src/chatty/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,10 @@ public void defineSettings() {

// Message filtering
settings.addLong("filterCombiningCharacters", Helper.FILTER_COMBINING_CHARACTERS_LENIENT);

// Low-trust/restricted messages
settings.addBoolean("showLowTrustInfo", false);
settings.addBoolean("showRestrictedMessages", false);


//==============
Expand Down
33 changes: 33 additions & 0 deletions src/chatty/TwitchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import chatty.lang.Language;
import chatty.gui.colors.UsercolorManager;
import chatty.gui.components.admin.StatusHistory;
import chatty.util.api.pubsub.*;
import chatty.util.commands.CustomCommands;
import chatty.util.api.usericons.Usericon;
import chatty.util.api.usericons.UsericonManager;
Expand Down Expand Up @@ -2623,6 +2624,30 @@ else if (message.data instanceof UserModerationMessageData) {
handleUserModeration(data);
}
}
else if (message.data instanceof LowTrustUserMessageData) {
LowTrustUserMessageData data = (LowTrustUserMessageData) message.data;
if (c.isChannelOpen(Helper.toChannel(data.stream))) {
handleLowTrustUser(data);
}
}
else if (message.data instanceof LowTrustUserUpdateData) {
LowTrustUserUpdateData data = (LowTrustUserUpdateData) message.data;
String channel = Helper.toChannel(data.stream);

// Mod Action
List<String> args = new ArrayList<>();
args.add(data.targetUsername);
handleModAction(new ModeratorActionData(
"", "chat_moderator_actions", "",
data.stream,
data.treatment.name(),
args,
data.moderatorUsername,
null));

User targetUser = c.getUser(channel, data.targetUsername);
targetUser.addInfo("", data.makeInfo());
}
}
}

Expand All @@ -2642,6 +2667,14 @@ private void handleReward(RewardRedeemedMessageData data) {
private void handleUserModeration(UserModerationMessageData data) {
g.printLine(c.getRoomByChannel(Helper.toChannel(data.stream)), data.info);
}

private void handleLowTrustUser(LowTrustUserMessageData data) {
String channel = Helper.toChannel(data.stream);

g.printLowTrustUserInfo(c.getUser(channel, data.username), data);
User targetUser = c.getUser(channel, data.username);
targetUser.addInfo("", data.makeInfo());
}

}

Expand Down
5 changes: 5 additions & 0 deletions src/chatty/gui/Highlighter.java
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,11 @@ else if (part.equals("firstmsg")) {
return user.getNumberOfMessages() == 0;
});
}
else if (part.equals("restricted")) {
addTagsItem("Restricted Message", null, tags -> {
return tags.isRestrictedMessage();
});
}
else if (part.startsWith("repeatedmsg")) {
// String options = parsePrefix(item, "repeatmsg:");
// String[] split = options.split("/");
Expand Down
35 changes: 32 additions & 3 deletions src/chatty/gui/MainGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import chatty.gui.transparency.TransparencyManager;
import chatty.gui.laf.LaF;
import chatty.util.api.pubsub.LowTrustUserMessageData;
import chatty.util.colors.HtmlColors;
import chatty.Addressbook;
import chatty.gui.components.textpane.UserMessage;
Expand Down Expand Up @@ -4148,12 +4149,40 @@ public void run() {
}
});
}


public void printLowTrustUserInfo(User user, final LowTrustUserMessageData data) {
String channel = Helper.toValidChannel(data.stream);
if (channels.isChannel(channel)) {
data.fetchUserInfoForBannedChannels(client.api, () -> SwingUtilities.invokeLater(() -> {
//--------------------------
// Restricted Message
//--------------------------
Channel chan = channels.getExistingChannel(channel);
if (data.treatment == LowTrustUserMessageData.Treatment.RESTRICTED
&& client.settings.getBoolean("showRestrictedMessages")) {
// Message is not being posted to actual chat, display it here anyway
MsgTags tags = MsgTags.create(
"id", data.aboutMessageId,
"chatty-is-restricted", "1"
);
printMessage(user, data.text, false, tags);
}

//--------------------------
// Appended Info
//--------------------------
if (client.settings.getBoolean("showLowTrustInfo")) {
chan.printLowTrustInfo(user, data);
}
}));
}
}

/**
* If not matching message was found for the ModAction to append the @mod,
* then output anyway.
*
* @param info
*
* @param info
*/
public void printAbandonedModLogInfo(ModLogInfo info) {
boolean showActions = client.settings.getBoolean("showModActions");
Expand Down
9 changes: 5 additions & 4 deletions src/chatty/gui/components/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import chatty.gui.components.textpane.InfoMessage;
import chatty.gui.components.textpane.Message;
import chatty.util.StringUtil;
import chatty.util.api.pubsub.LowTrustUserMessageData;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
Expand All @@ -27,10 +28,7 @@
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

/**
* A single channel window, combining styled text pane, userlist and input box.
Expand Down Expand Up @@ -304,7 +302,10 @@ public void printMessage(Message message) {
public void printMessage(Message message, String timestamp) {
text.printMessage(message, timestamp);
}


public void printLowTrustInfo(User user, LowTrustUserMessageData data) {
text.printLowTrustInfo(user, data);
}

// Style

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

<p>
<a href="#0.24">0.24</a> |
<a href="#0.23">0.23</a> |
<a href="#0.22">0.22</a> |
<a href="#0.21">0.21</a> |
Expand Down Expand Up @@ -72,7 +73,15 @@ <h1><a name="top">Release Information</a></h1>
full list of changes.</p>

<h2>
<a name="0.23">Version 0.23</a> <a name="latest">(This one!)</a> (2023-02-17)
<a name="0.24">Version 0.24</a> <a name="latest">(This one!)</a> (2023-??-??)
<a href="#top" class="top">[back to top]</a>
</h2>
<pre>
BETA, TBD
</pre>

<h2>
<a name="0.23">Version 0.23</a> (2023-02-17)
<a href="#top" class="top">[back to top]</a>
</h2>
<pre>
Expand Down
3 changes: 3 additions & 0 deletions src/chatty/gui/components/help/help-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,9 @@ <h3><a name="Highlight_Meta_Matching">Meta Prefixes (Matching)</a></h3>
default in the "Substitutes / Lookalikes" dialog in the
Highlight settings (if no prefix is provided it will use the
default setting).</li>
<li><code>config:restricted</code> - Match messages by
restricted users shown only for moderators. Note that
messages by monitored users can not be matched yet.</li>
</ul>
</li>
<li><a name="Highlight_Prefix-blacklist"><code>blacklist:</code></a> to specify one or more text patterns
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.23)</a></h1>
<h1><a name="top">Chatty (Version: 0.24-b1)</a></h1>
<table>
<tr>
<td valign="top">
Expand Down
6 changes: 6 additions & 0 deletions src/chatty/gui/components/settings/ModerationSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public ModerationSettings(final SettingsDialog d) {
modInfoPanel.add(new JLabel(SettingConstants.HTML_PREFIX
+ "Approve/deny AutoMod messages in chat through their context menu (right-click) or the User Dialog (left-click) or <code>Extra - AutoMod</code>."),
d.makeGbc(1, 6, 2, 1, GridBagConstraints.CENTER));

modInfoPanel.add(d.addSimpleBooleanSetting("showLowTrustInfo"),
d.makeGbc(0, 7, 3, 1, GridBagConstraints.WEST));

modInfoPanel.add(d.addSimpleBooleanSetting("showRestrictedMessages"),
d.makeGbc(0, 8, 3, 1, GridBagConstraints.WEST));

//==========================
// User Dialog
Expand Down
37 changes: 35 additions & 2 deletions src/chatty/gui/components/textpane/ChannelTextPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import chatty.SettingsManager;
import chatty.gui.MouseClickedListener;
import chatty.gui.UserListener;
import chatty.util.api.pubsub.LowTrustUserMessageData;
import chatty.util.colors.HtmlColors;
import chatty.gui.LinkListener;
import chatty.gui.StyleServer;
Expand Down Expand Up @@ -65,7 +66,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.*;
import static javax.swing.JComponent.WHEN_FOCUSED;
import javax.swing.border.Border;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
Expand Down Expand Up @@ -104,6 +104,7 @@ public class ChannelTextPane extends JTextPane implements LinkListener, CachedIm
private static final Logger LOGGER = Logger.getLogger(ChannelTextPane.class.getName());

private static final ImageIcon REPLY_ICON = new ImageIcon(MainGui.class.getResource("reply.png"));
private static final ImageIcon NO_CHAT_ICON = new ImageIcon(MainGui.class.getResource("no_chat.png"));

private final DefaultStyledDocument doc;

Expand Down Expand Up @@ -149,7 +150,7 @@ public enum Attribute {
URL_DELETED, DELETED_LINE, EMOTICON, IS_APPENDED_INFO, INFO_TEXT, BANS,
BAN_MESSAGE, ID, ID_AUTOMOD, AUTOMOD_ACTION, USERICON, IMAGE_ID, ANIMATED,
APPENDED_INFO_UPDATED, MENTION, USERICON_INFO, GENERAL_LINK,
REPEAT_MESSAGE_COUNT,
REPEAT_MESSAGE_COUNT, LOW_TRUST_INFO, IS_RESTRICTED,

HIGHLIGHT_WORD, HIGHLIGHT_LINE, HIGHLIGHT_SOURCE, EVEN, PARAGRAPH_SPACING,
CUSTOM_BACKGROUND, CUSTOM_BACKGROUND_ORIG, CUSTOM_FOREGROUND,
Expand Down Expand Up @@ -207,6 +208,8 @@ public enum Type {

private final Type type;

private final Map<User, LowTrustUserMessageData> pendingLowTrustInfoCache = new HashMap<>();

public ChannelTextPane(MainGui main, StyleServer styleServer) {
this(main, styleServer, Type.REGULAR, true);
}
Expand Down Expand Up @@ -689,6 +692,11 @@ else if (type == Type.IGNORED) {
});
}

LowTrustUserMessageData pendingLowTrust = pendingLowTrustInfoCache.remove(user);
if (pendingLowTrust != null) {
printLowTrustInfo(user, pendingLowTrust);
}

lastUsers.add(new MentionCheck(user));
}

Expand Down Expand Up @@ -1068,6 +1076,11 @@ private void changeInfo(Element line, InfoChanger changer) {
if (actionBy != null) {
text = StringUtil.append(text, " ", "(@"+StringUtil.join(actionBy, ", ")+")");
}

LowTrustUserMessageData lowTrustData = (LowTrustUserMessageData) attributes.getAttribute(Attribute.LOW_TRUST_INFO);
if (lowTrustData != null) {
text = StringUtil.append(text, " ", "(" + lowTrustData.makeInfo() + ")");
}

//--------------------------
// Insert new appended info
Expand Down Expand Up @@ -1115,6 +1128,19 @@ private String getElementText(Element element) {
}
return "";
}

public void printLowTrustInfo(User user, LowTrustUserMessageData data) {
for (Userline userLine : getUserLines(user)) {
String elementId = getIdFromElement(userLine.userElement);
if (elementId != null && elementId.equals(data.aboutMessageId)) {
changeInfo(userLine.line, attributes -> attributes.addAttribute(Attribute.LOW_TRUST_INFO, data));
return;
}
}

// message has not been printed yet, let printUserMessage call back
pendingLowTrustInfoCache.put(user, data);
}

/**
* Searches backwards from the newest message for a ban message from the
Expand Down Expand Up @@ -2051,6 +2077,13 @@ else if (styles.namesMode() != SettingsManager.DISPLAY_NAMES_MODE_CAPITALIZED
userName = user.getName();
}

if (tags.isRestrictedMessage()) {
SimpleAttributeSet style = new SimpleAttributeSet();
StyleConstants.setIcon(style, addSpaceToIcon(NO_CHAT_ICON));
style.addAttribute(Attribute.IS_RESTRICTED, true);
print("'", style);
}

// Badges or Status Symbols
if (styles.isEnabled(Setting.USERICONS_ENABLED)) {
printUserIcons(user, localUser, tags);
Expand Down
6 changes: 5 additions & 1 deletion src/chatty/gui/components/textpane/LinkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public void mouseMoved(MouseEvent e) {
String replacedText = getReplacedText(element);
String replyMsgId = getReplyText(element);
User mention = getMention(element);
boolean isRestricted = element.getAttributes().getAttribute(ChannelTextPane.Attribute.IS_RESTRICTED) != null;
if (emoteImage != null) {
popup.show(textPane, element, p -> makeEmoticonPopupText(emoteImage, popupImagesEnabled, p, element), emoteImage.getImageIcon().getIconWidth());
} else if (usericonImage != null) {
Expand All @@ -307,6 +308,8 @@ public void mouseMoved(MouseEvent e) {
popup.show(textPane, element, p -> makeReplyPopupText(replyMsgId, p), 1);
} else if (mention != null && mentionMessages > 0) {
popup.show(textPane, element, p -> makeMentionPopupText(mention, p, mentionMessages), 1);
} else if (isRestricted) {
popup.show(textPane, element, p -> p.setText(POPUP_HTML_PREFIX+"Message not posted to chat (restricted)"), 1);
} else {
popup.hide();
}
Expand All @@ -317,7 +320,8 @@ public void mouseMoved(MouseEvent e) {
|| (user = getUser(element)) != null
|| mention != null
|| emoteImage != null
|| usericonImage != null;
|| usericonImage != null
|| isRestricted;

if (isClickableElement) {
textPane.setCursor(HAND_CURSOR);
Expand Down
4 changes: 4 additions & 0 deletions src/chatty/gui/components/updating/UpdateDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ private String makeDownloadLinks(Release release) {
b.append("[url:").append(forkUrl + assetName).append(" ").append(assetName).append("]");
b.append("</li>");
}
b.append("<li>");
b.append("[url:https://tduva.com/chatty/checksums/v").append(release.getVersion()).append(" View download checksums]");
b.append("</li>");
b.append("</ul>");

return b.toString();
}

Expand Down
Binary file added src/chatty/gui/no_chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/chatty/lang/Strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,10 @@ settings.long.repeatMsgMethod.option.1 = Strict
settings.long.repeatMsgMethod.option.2 = Lenient
settings.label.repeatMsgIgnored = Ignored characters:
settings.label.repeatMsgIgnored.tip = These characters will be removed prior to comparison (whitespace is always removed). Only works for characters in the Unicode BMP.
settings.boolean.showLowTrustInfo = Show restricted/monitored user info in chat
settings.boolean.showLowTrustInfo.tip = Appends info about suspicious users to their messages in chat
settings.boolean.showRestrictedMessages = Show restricted messages in chat
settings.boolean.showRestrictedMessages.tip = When a restricted user sends a message, it is not posted to public chat. This setting displays those messages in your chat.

!-- Names --!
settings.label.displayNamesMode = Names in Chat:
Expand Down
Loading

0 comments on commit 56a797e

Please sign in to comment.