diff --git a/src/chatty/TwitchClient.java b/src/chatty/TwitchClient.java index 87694bf66..70e7ffaf5 100644 --- a/src/chatty/TwitchClient.java +++ b/src/chatty/TwitchClient.java @@ -872,6 +872,14 @@ private void sendMessage(String channel, String text, boolean allowCommandMessag } } + /** + * Check if the message should be sent as a reply. + * + * @param channel The channel to send the message to (not null) + * @param text The text to send (not null) + * @return true if the message was handled by this method, false if it + * should be sent normally + */ private boolean sendAsReply(String channel, String text) { boolean restricted = settings.getBoolean("mentionReplyRestricted"); boolean doubleAt = text.startsWith("@@"); @@ -888,7 +896,8 @@ private boolean sendAsReply(String channel, String text) { if (result.action != SelectReplyMessageResult.Action.SEND_NORMALLY) { // Should not send normally, so return true if (result.action == SelectReplyMessageResult.Action.REPLY) { - sendReply(channel, actualMsg, username, result.atMsgId, null); + // If changed to parent msg-id, atMsg will be null + sendReply(channel, actualMsg, username, result.atMsgId, result.atMsg); } return true; } @@ -898,6 +907,15 @@ private boolean sendAsReply(String channel, String text) { return false; } + /** + * Send a reply. + * + * @param channel The channel to send to (not null) + * @param text The text to send (not null) + * @param atUsername The username to address (not null) + * @param atMsgId The msg-id to use as reply thread parent (not null) + * @param atMsg The parent msg text (may be null) + */ private void sendReply(String channel, String text, String atUsername, String atMsgId, String atMsg) { MsgTags tags = MsgTags.create("reply-parent-msg-id", atMsgId); if (c.sendSpamProtectedMessage(channel, text, false, tags)) { @@ -2950,7 +2968,7 @@ public void onChannelMessage(User user, String text, boolean action, MsgTags tag } else { g.printMessage(user, text, action, tags); - if (tags.isReply() && tags.hasReplyUserMsg()) { + if (tags.isReply() && tags.hasReplyUserMsg() && tags.hasId()) { ReplyManager.addReply(tags.getReplyParentMsgId(), tags.getId(), String.format("<%s> %s", user.getName(), text), tags.getReplyUserMsg()); } if (!action) { diff --git a/src/chatty/TwitchConnection.java b/src/chatty/TwitchConnection.java index 33e3036b0..b91f2bc1c 100644 --- a/src/chatty/TwitchConnection.java +++ b/src/chatty/TwitchConnection.java @@ -1408,7 +1408,7 @@ public void onChannelCommand(MsgTags tags, String nick, if (tags.containsKey("followers-only")) { channelStates.setFollowersOnly(channel, tags.get("followers-only")); } - if (!tags.isEmpty("room-id")) { + if (tags.hasValue("room-id")) { listener.onRoomId(channel, tags.get("room-id")); if (Helper.isRegularChannel(channel)) { // Set id for room (this should not run too often to diff --git a/src/chatty/gui/components/SelectReplyMessage.java b/src/chatty/gui/components/SelectReplyMessage.java index 9d1788a79..e82400630 100644 --- a/src/chatty/gui/components/SelectReplyMessage.java +++ b/src/chatty/gui/components/SelectReplyMessage.java @@ -163,11 +163,14 @@ else if (action == Action.CTRL_ENTER) { private void confirm() { User.TextMessage selected = list.getSelectedValue(); if (selected != null) { - result = new SelectReplyMessageResult(selected.id); + result = new SelectReplyMessageResult(selected.id, selected.text); if (continueThread.isSelected()) { String parentMsgId = ReplyManager.getParentMsgId(selected.id); if (parentMsgId != null) { - result = new SelectReplyMessageResult(parentMsgId); + // Overwrite result with parent msg-id if available + // Msg should be null for this, since the selected.text + // isn't the parent text + result = new SelectReplyMessageResult(parentMsgId, null); } } } @@ -177,9 +180,10 @@ private void confirm() { public SelectReplyMessageResult select() { if (list.getModel().getSize() == 0) { // No messages available, so immediatelly return - return null; + return SEND_NORMALLY_RESULT; } list.setSelectedIndex(list.getModel().getSize() - 1); + list.ensureIndexIsVisible(list.getSelectedIndex()); setLocationRelativeTo(getParent()); setVisible(true); return result; @@ -194,15 +198,18 @@ public enum Action { } public final String atMsgId; + public final String atMsg; public final Action action; - public SelectReplyMessageResult(String atMsgId) { + public SelectReplyMessageResult(String atMsgId, String atMsg) { this.atMsgId = atMsgId; + this.atMsg = atMsg; this.action = Action.REPLY; } public SelectReplyMessageResult(Action action) { this.atMsgId = null; + this.atMsg = null; this.action = action; } @@ -213,6 +220,9 @@ public static void main(String[] args) { user.addMessage("abc", true, "1"); user.addMessage("abc2", true, "2"); user.addMessage("abc2", true, null); + for (int i=0;i<30;i++) { + user.addMessage("blah"+i, false, i+"msg-id"); + } System.out.println(SelectReplyMessage.show(user)); System.exit(0); } diff --git a/src/chatty/gui/components/help/help-settings.html b/src/chatty/gui/components/help/help-settings.html index d713bec2b..98c4df8b5 100644 --- a/src/chatty/gui/components/help/help-settings.html +++ b/src/chatty/gui/components/help/help-settings.html @@ -1193,6 +1193,10 @@
Tip: Add $_whisper_
to the whitelist or blacklist
+ to affect all whispers that are output in the "One Window" tab or
+ "Per User" tabs.
diff --git a/src/chatty/gui/components/settings/LogSettings.java b/src/chatty/gui/components/settings/LogSettings.java
index df13a51a6..ea7d61bac 100644
--- a/src/chatty/gui/components/settings/LogSettings.java
+++ b/src/chatty/gui/components/settings/LogSettings.java
@@ -321,7 +321,8 @@ private static class ChannelFormatter implements DataFormatter "); + if (replies != null) { + for (Reply reply : replies) { + b.append(StringUtil.addLinebreaks(Helper.htmlspecialchars_encode(reply.userMsg), 70, true)); + b.append(" "); + } + } + else { + b.append("No reply data found (may have expired)."); } p.setText(String.format("%sThread: %s ",
POPUP_HTML_PREFIX, b.toString()));
diff --git a/src/chatty/util/ReplyManager.java b/src/chatty/util/ReplyManager.java
index 6b938980a..4ac3a57d4 100644
--- a/src/chatty/util/ReplyManager.java
+++ b/src/chatty/util/ReplyManager.java
@@ -17,7 +17,7 @@
*/
public class ReplyManager {
- private static final long DELETE_TIME = TimeUnit.HOURS.toMillis(4);
+ private static final long DELETE_TIME = TimeUnit.HOURS.toMillis(12);
// private static final long DELETE_TIME = TimeUnit.MINUTES.toMillis(2);
private static final Map |