Skip to content

Commit

Permalink
Updated to v0.26.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Mar 21, 2024
2 parents 2362bb8 + cf4d256 commit 290e8f8
Show file tree
Hide file tree
Showing 22 changed files with 426 additions and 113 deletions.
8 changes: 8 additions & 0 deletions src/chatty/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ public String getArgs() {
return parameters.getArgs();
}

public String getArgsTrimNonNull() {
String args = StringUtil.trim(getArgs());
if (args != null) {
return args;
}
return "";
}

public boolean hasArgs() {
return !StringUtil.isNullOrEmpty(parameters.getArgs());
}
Expand Down
20 changes: 15 additions & 5 deletions src/chatty/TwitchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import chatty.util.api.Follower;
import chatty.util.api.FollowerInfo;
import chatty.util.api.ResultManager;
import chatty.util.api.ResultManager.CreateClipResult;
import chatty.util.api.StreamCategory;
import chatty.util.api.StreamInfo.StreamType;
import chatty.util.api.StreamInfo.ViewerStats;
Expand Down Expand Up @@ -1629,9 +1630,18 @@ private void addCommands() {
commandAddStreamMarker(p.getRoom(), p.getArgs());
});
commands.add("createClip", p -> {
api.createClip(p.getRoom().getStream(), result -> {
g.printLine(p.getRoom(), result);
api.subscribe(ResultManager.Type.CREATE_CLIP, commands, (CreateClipResult) (editUrl, viewUrl, error) -> {
if (error != null) {
g.printLine(p.getRoom(), error);
}
else {
// Update indices when changing info text
MsgTags tags = MsgTags.createLinks(
new MsgTags.Link(MsgTags.Link.Type.URL, editUrl, 14, 22));
g.printInfo(p.getRoom(), "Clip created (Edit Clip): "+viewUrl, tags);
}
});
api.createClip(p.getRoom().getStream());
});
c.addNewCommands(commands, this);
commands.add("addStreamHighlight", p -> {
Expand Down Expand Up @@ -2109,7 +2119,7 @@ public void run() {
} else if (command.equals("testr")) {
api.test();
} else if (command.equals("joinlink")) {
MsgTags tags = MsgTags.create("chatty-channel-join", Helper.toChannel("twitch"));
MsgTags tags = MsgTags.createLinks(new MsgTags.Link(MsgTags.Link.Type.JOIN, Helper.toChannel("twitch"), "Join"));
g.printInfo(c.getRoomByChannel(channel), "Join link:", tags);
}
}
Expand Down Expand Up @@ -2753,7 +2763,7 @@ public void messageReceived(chatty.util.api.eventsub.Message message) {
String channel = Helper.toChannel(raid.fromLogin);
String text = String.format("[Raid] Now raiding %s with %d viewers.",
raid.toLogin, raid.viewers);
MsgTags tags = MsgTags.create("chatty-channel-join", Helper.toChannel(raid.toLogin));
MsgTags tags = MsgTags.createLinks(new MsgTags.Link(MsgTags.Link.Type.JOIN, Helper.toChannel(raid.toLogin), "Join"));
g.printInfo(c.getRoomByChannel(channel), text, tags);
}
String pollMessage = PollPayload.getPollMessage(message);
Expand Down Expand Up @@ -2784,7 +2794,7 @@ public void messageReceived(chatty.util.api.eventsub.Message message) {
String infoText = String.format("[Shoutout] Was given to %s (@%s)",
shoutout.target_name,
shoutout.moderator_login);
MsgTags tags = MsgTags.create("chatty-channel-join", Helper.toChannel(shoutout.target_login));
MsgTags tags = MsgTags.createLinks(new MsgTags.Link(MsgTags.Link.Type.JOIN, Helper.toChannel(shoutout.target_login), "Join"));
g.printInfo(c.getRoomByChannel(channel), infoText, tags);
// Mod Action
List<String> args = new ArrayList<>();
Expand Down
4 changes: 3 additions & 1 deletion src/chatty/TwitchCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import chatty.gui.UrlOpener;
import chatty.lang.Language;
import chatty.util.DateTime;
import chatty.util.RecentlyAffectedUsers;
import chatty.util.StringUtil;
import chatty.util.api.TwitchApi;
import chatty.util.api.TwitchApi.SimpleRequestResultListener;
Expand Down Expand Up @@ -58,7 +59,7 @@ public class TwitchCommands {
private static final Set<String> OTHER_COMMANDS = new HashSet<>(Arrays.asList(new String[]{
}));

private TwitchConnection c;
private final TwitchConnection c;

public TwitchCommands(TwitchConnection c) {
this.c = c;
Expand Down Expand Up @@ -392,6 +393,7 @@ private void userCommand(TwitchClient client,
if (r.error == null) {
// Success
client.g.addToLine(p.getRoom(), objectId, "OK");
RecentlyAffectedUsers.addUser(user);
}
else {
// Failed
Expand Down
21 changes: 17 additions & 4 deletions src/chatty/gui/MainGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -2731,10 +2731,14 @@ public void usericonClicked(Usericon usericon, MouseEvent e) {
}

@Override
public void linkClicked(Channel channel, String link) {
if (link.startsWith("join.")) {
String c = link.substring("join.".length());
client.joinChannel(c);
public void linkClicked(Channel channel, MsgTags.Link link) {
switch (link.type) {
case JOIN:
client.joinChannel(link.target);
break;
case URL:
UrlOpener.openUrl(link.target);
break;
}
}

Expand Down Expand Up @@ -2865,6 +2869,15 @@ else if (!Helper.isValidStream(username)) {
openUserInfoDialog(user, p.getParameters().get("msg-id"), null);
}
});
client.commands.addEdt("userinfoRecent", p -> {
User user = RecentlyAffectedUsers.poll(p.getChannel());
if (user == null) {
printSystem(p.getRoom(), "No recently affected user found");
}
else {
openUserInfoDialog(user, p.getParameters().get("msg-id"), null);
}
});
client.commands.addEdt("search", p -> {
openSearchDialog();
});
Expand Down
3 changes: 2 additions & 1 deletion src/chatty/gui/UserListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import chatty.gui.components.Channel;
import chatty.util.api.Emoticon;
import chatty.util.api.usericons.Usericon;
import chatty.util.irc.MsgTags;
import java.awt.event.MouseEvent;

/**
Expand All @@ -21,7 +22,7 @@ public interface UserListener {
public void userClicked(User user, String messageId, String autoModMsgId, MouseEvent e);
public void emoteClicked(Emoticon emote, MouseEvent e);
public void usericonClicked(Usericon usericon, MouseEvent e);
public void linkClicked(Channel channel, String link);
public void linkClicked(Channel channel, MsgTags.Link link);
public void imageClicked(String url);

}
5 changes: 5 additions & 0 deletions src/chatty/gui/components/help/help-builtin_commands.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ <h3>Open windows in Chatty</h3>
<code>/openSubscribers</code> - Opens the according dialog</li>
<li><code>/userinfo &lt;username&gt;</code> - To open the User Info Dialog
on a specific user of the current channel (if available)</li>
<li><code>/userinfoRecent</code> - To open the User Info Dialog on a
user recently affected by a Twitch Command or with recently open
User Dialog on that channel. Repeately executing the command (e.g.
through a hotkey) goes back in the history of recently affected
users, up to 10 users.</li>
<li><code>/releaseinfo</code> - Opens the help with the release information</li>
</ul>

Expand Down
42 changes: 38 additions & 4 deletions src/chatty/gui/components/help/help-releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,46 @@ <h1><a name="top">Release Information</a></h1>
full list of changes.</p>

<h2>
<a name="0.26">Version 0.26</a> <a name="latest">(This one!)</a> (2023-??-??)
<a name="0.26">Version 0.26</a> <a name="latest">(This one!)</a> (2024-03-21)
<a href="#top" class="top">[back to top]</a>
</h2>
<pre>
TBD
</pre>
<h3>Custom Tabs</h3>
<p>Custom Tabs allow you to route message from regular channels to a Custom Tab based on Highlight matching rules.</p>
<p>The new <code>to:</code> prefix (for Highlights, Ignore, Msg. Colours and the new Routing setting) specifies the name of the Custom Tab you want to route the matching messages to. For example adding <code>to:Mentions regw:yourname</code> to the Custom Tabs Routing list will copy all messages containing the word "yourname" to a tab called "Mentions".</p>
<p>There are also options to copy the text of Desktop Notifications to a Custom Tab, logging Custom Tab messages to a file and more.</p>
<h3>Message History</h3>
<p>Added a message history on channel join, which can be enabled in the Settings under "History". It can show regular chat messages from the last 24h for many channels based on the recent-messages.robotty.de API.</p>
<h3>Channel Moderation Panel</h3>
<p>Added an "M" button to the input field that opens a panel for changing channel modes (available only for moderators).</p>
<h3>Twitch Features</h3>
<ul>
<li>Added command <code>/createClip</code> for creating a clip on the current channel</li>
<li>Added support for Content Classification Labels to Admin Dialog</li>
</ul>
<h3>Other</h3>
<ul>
<li>Added support for animated overlayed emotes and 7TV zero-width-emotes</li>
<li>Added prefix <code>config:afterban</code> to match on messages after the user was banned/timed out (if Chatty is aware of it)</li>
<li>Added prefix <code>msgs:</code> to match on the user's past messages (as they are shown in the User Dialog)</li>
<li>Added command <code>/userinfoRecent</code> to open User Info Dialog for user recently affected by a Twitch Command or with recently open User Dialog</li>
<li>Updated Pronouns service to new API</li>
<li>Added Look&amp;Feel MacOS options (screen menubar, system colors for title bar)</li>
<li>Added setting under "Window" to toggle input length limits</li>
<li>Various GUI improvements</li>
<li>Updated help</li>
</ul>
<h3>Bugfixes</h3>
<ul>
<li>Fixed error in context menu for some types of messages</li>
<li>Fixed AutoMod Dialog hotkeys reacting when they shouldn't when docked as a tab</li>
<li>Fixed favorited emotes not being detected as usable in some cases</li>
<li>Fixed PageUp/PageDown sometimes scrolling in wrong channel (by adding as configurable hotkey acting on the active channel)</li>
<li>Fixed "Join"-entry being shown in URL context menu when it shouldn't</li>
<li>Fixed "User to never highlight" setting not applying to info messages with an attached user</li>
<li>Fixed default tab highlight/unread colors not updating when changing from dark to light LaF</li>
<li>Fixed tab joined state not always showing correctly after reconnecting</li>
<li>Fixed links that are displayed over several lines being clickable in empty spaces in between</li>
</ul>

<h2>
<a name="0.25">Version 0.25</a> (2023-07-21)
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.26-b6)</a></h1>
<h1><a name="top">Chatty (Version: 0.26)</a></h1>
<table>
<tr>
<td valign="top">
Expand Down
2 changes: 1 addition & 1 deletion src/chatty/gui/components/help/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ body {
font-size: 1em;
color: black;
background-color: #FDFDFD;
font-family: Arial, sans-serif;
font-family: sans-serif;
padding: 10px;
margin: 0;
}
Expand Down
34 changes: 16 additions & 18 deletions src/chatty/gui/components/textpane/ChannelTextPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import chatty.util.api.usericons.UsericonManager;
import java.util.function.Function;
import chatty.gui.transparency.TransparencyComponent;
import chatty.util.irc.MsgTags.Link;
import java.util.function.Consumer;


Expand Down Expand Up @@ -778,10 +779,10 @@ private void printInfoMessage2(InfoMessage message, AttributeSet style) {
printTimestamp(style);
printChannelIcon(null, message.localUser);
printSpecialsInfo(message.text, style, message.highlightMatches, message.tags);
Pair<String, String> link = message.getLink();
if (link != null) {

for (Link link : message.getAppendedLinks()) {
print(" ", style);
print(link.key, styles.generalLink(style, link.value));
print(link.label, styles.generalLink(style, link));
}
finishLine();
}
Expand Down Expand Up @@ -1948,7 +1949,7 @@ public void usericonClicked(Usericon usericon, MouseEvent e) {
}

@Override
public void linkClicked(Channel channel, String link) {
public void linkClicked(Channel channel, MsgTags.Link link) {
}

@Override
Expand Down Expand Up @@ -2733,21 +2734,18 @@ private void findSpecialLinks(TreeMap<Integer, Integer> ranges, HashMap<Integer,
if (tags == null) {
return;
}
if (tags.getChannelJoin() == null || tags.getChannelJoinIndices() == null) {
java.util.List<Link> links = tags.getLinks();
if (links == null) {
return;
}
/**
* This only allows one link per message, just extending the existing
* join link functionality a bit, but should be good enough for now.
*/
String chan = tags.getChannelJoin();
String indices = tags.getChannelJoinIndices();
String[] split = indices.split("-");
int start = Integer.parseInt(split[0]);
int end = Integer.parseInt(split[1]);
if (!inRanges(start, ranges) && !inRanges(end, ranges)) {
ranges.put(start, end);
rangesStyle.put(start, styles.generalLink(baseStyle, "join."+chan));

for (Link link : links) {
if (link.startIndex != -1 && link.endIndex != -1) {
if (!inRanges(link.startIndex, ranges) && !inRanges(link.endIndex, ranges)) {
ranges.put(link.startIndex, link.endIndex);
rangesStyle.put(link.startIndex, styles.generalLink(baseStyle, link));
}
}
}
}

Expand Down Expand Up @@ -4081,7 +4079,7 @@ public MutableAttributeSet info(Color color) {
return info();
}

public MutableAttributeSet generalLink(AttributeSet base, String target) {
public MutableAttributeSet generalLink(AttributeSet base, MsgTags.Link target) {
SimpleAttributeSet result = new SimpleAttributeSet(base);
result.addAttribute(Attribute.GENERAL_LINK, target);
StyleConstants.setUnderline(result, true);
Expand Down
14 changes: 9 additions & 5 deletions src/chatty/gui/components/textpane/InfoMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import chatty.gui.Highlighter.Match;
import chatty.util.Pair;
import chatty.util.irc.MsgTags;
import chatty.util.irc.MsgTags.Link;
import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -139,14 +141,16 @@ public int getMsgEnd() {
return -1;
}

public Pair<String, String> getLink() {
public List<Link> getAppendedLinks() {
List<Link> result = new ArrayList<>();
if (tags != null) {
// When indicdes are set the join link is added differently
if (tags.getChannelJoin() != null && tags.getChannelJoinIndices() == null) {
return new Pair<>("Join", "join."+tags.getChannelJoin());
for (Link link : tags.getLinks()) {
if (link.startIndex == -1) {
result.add(link);
}
}
}
return null;
return result;
}

}
20 changes: 13 additions & 7 deletions src/chatty/gui/components/textpane/LinkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import chatty.util.api.CachedImage;
import chatty.util.api.CachedImage.ImageType;
import chatty.util.api.usericons.Usericon;
import chatty.util.irc.MsgTags;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
Expand Down Expand Up @@ -234,7 +235,7 @@ else if (e.isPopupTrigger()) {

private void handleSingleLeftClick(MouseEvent e, Element element) {
String url;
String link;
MsgTags.Link link;
User user;
CachedImage<Emoticon> emoteImage;
CachedImage<Usericon> usericonImage;
Expand Down Expand Up @@ -395,8 +396,8 @@ private boolean isUrlDeleted(Element e) {
return deleted;
}

private String getGeneralLink(Element e) {
return (String)(e.getAttributes().getAttribute(ChannelTextPane.Attribute.GENERAL_LINK));
private MsgTags.Link getGeneralLink(Element e) {
return (MsgTags.Link)(e.getAttributes().getAttribute(ChannelTextPane.Attribute.GENERAL_LINK));
}

private User getUser(Element e) {
Expand Down Expand Up @@ -552,7 +553,7 @@ private void openContextMenu(MouseEvent e) {
user = getMention(element);
}
String url = getUrl(element);
String link = getGeneralLink(element);
MsgTags.Link link = getGeneralLink(element);
CachedImage<Emoticon> emoteImage = getEmoticonImage(element);
CachedImage<Usericon> usericonImage = getUsericonImage(element);
if (user != null) {
Expand All @@ -563,9 +564,14 @@ else if (url != null) {
m = new UrlContextMenu(url, isUrlDeleted(element), contextMenuListener);
}
else if (link != null) {
if (link.startsWith("join.")) {
String c = Helper.toStream(link.substring("join.".length()));
m = new StreamsContextMenu(Arrays.asList(new String[]{c}), contextMenuListener);
switch (link.type) {
case JOIN:
String c = Helper.toStream(link.target);
m = new StreamsContextMenu(Arrays.asList(new String[]{c}), contextMenuListener);
break;
case URL:
m = new UrlContextMenu(link.target, false, contextMenuListener);
break;
}
}
else if (emoteImage != null) {
Expand Down
1 change: 1 addition & 0 deletions src/chatty/gui/components/textpane/UserMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public UserMessage copy() {
result.ignoreSource = ignoreSource;
result.routingSource = routingSource;
result.localUser = localUser;
result.historicTimeStamp = historicTimeStamp;
return result;
}

Expand Down
Loading

0 comments on commit 290e8f8

Please sign in to comment.