Skip to content

Commit

Permalink
Updated to v0.25-b2.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Jul 19, 2023
2 parents e23d8ca + 3382ebd commit 94a6452
Show file tree
Hide file tree
Showing 62 changed files with 1,228 additions and 232 deletions.
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import java.util.regex.Matcher

plugins {
id "com.github.johnrengelman.shadow" version "6.0.0"
id "org.gradle.crypto.checksum" version "1.1.0"
id 'com.github.johnrengelman.shadow' version '8.1.1'
id "org.gradle.crypto.checksum" version "1.4.0"
id "java"
}

Expand Down Expand Up @@ -81,7 +81,7 @@ jar {
// dependencies. This removes the need for a separate 'libs' directory when Chatty is installed.
shadowJar {
// A suffix for the release jar name. By default this is '-all', which gives a name like 'Chatty-v0.8.3b3-all.jar'
classifier = ''
archiveClassifier = ''
archiveVersion = ''

manifest {
Expand Down Expand Up @@ -321,6 +321,8 @@ task releaseWinSetups(group: 'build') {
import org.gradle.crypto.checksum.Checksum

task createChecksums(type: Checksum) {
mustRunAfter(allPlatformsZip, windowsZip, releaseWindows, releaseWinSetups)

files = layout.files { releasesDir.listFiles() }.filter { File f ->
f.name.endsWith(".exe") || f.name.endsWith(".zip")
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
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.24.0.168";
public static final String VERSION = "0.25.0.168";

/**
* Enable Version Checker (if you compile and distribute this yourself, you
Expand Down
11 changes: 11 additions & 0 deletions src/chatty/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,11 @@ public static void addUserParameters(User user, String msgId, String autoModMsgI
parameters.put("msg", m.text);
parameters.put("msg-time", String.valueOf(m.getTime()));
}
User.SubMessage sm = user.getSubMessage(msgId);
if (sm != null) {
parameters.put("msg", sm.attached_message);
parameters.put("msg-time", String.valueOf(sm.getTime()));
}
}
if (autoModMsgId != null) {
parameters.put("automod-msg-id", autoModMsgId);
Expand All @@ -1003,6 +1008,12 @@ public static void addUserParameters(User user, String msgId, String autoModMsgI
parameters.putObject("user", user);
}

public static Parameters createRoomParameters(Room room) {
Parameters parameters = Parameters.create("");
parameters.putObject("room", room);
return parameters;
}

private static final Map<UserNotice, javax.swing.Timer> pointsMerge = new HashMap<>();

/**
Expand Down
3 changes: 3 additions & 0 deletions src/chatty/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ public void defineSettings() {
"Translate=/openUrlPrompt https://translate.google.com/#view=home&op=translate&sl=auto&tl=en&text=$$urlencode($(msg))");
settings.addString("adminContextMenu", "!title=!title $(title)\n!game=!game $(game)");
settings.addBoolean("menuCommandLabels", false);
settings.addBoolean("menuRestrictions", false);

settings.addBoolean("closeUserDialogOnAction", true);
settings.addBoolean("openUserDialogByMouse", true);
Expand Down Expand Up @@ -590,6 +591,8 @@ public void defineSettings() {
settings.addBoolean("pauseChatOnMouseMove", false);
settings.addBoolean("pauseChatOnMouseMoveCtrlRequired", false);
settings.addString("commandOnCtrlClick", "");
settings.addString("commandOnMiddleClick", "");
settings.addString("commandOnCtrlMiddleClick", "");

// Not really used anymore, kept for compatability
settings.addBoolean("ignoreJoinsParts",false);
Expand Down
4 changes: 4 additions & 0 deletions src/chatty/TwitchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import chatty.util.TwitchEmotesApi;
import chatty.util.UserRoom;
import chatty.util.Webserver;
import chatty.util.api.AccessChecker;
import chatty.util.api.AutoModCommandHelper;
import chatty.util.api.ChannelStatus;
import chatty.util.api.CheerEmoticon;
Expand Down Expand Up @@ -361,6 +362,9 @@ public TwitchClient(Map<String, String> args) {
c.addChannelStateListener(new ChannelStateUpdater());
c.setMaxReconnectionAttempts(settings.getLong("maxReconnectionAttempts"));

// Uses TwitchConnection
AccessChecker.setInstance(new AccessChecker(settings, this));

w = new WhisperManager(new MyWhisperListener(), settings, c, this);

streamStatusWriter = new StreamStatusWriter(Chatty.getPath(PathType.EXPORT), api);
Expand Down
6 changes: 5 additions & 1 deletion src/chatty/TwitchConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ private synchronized void flush() {
}
b.append(" (").append(recipients.size()).append(" total)");
}
listener.onSubscriberNotification(gifter, b.toString(), null, -1, null);
listener.onSubscriberNotification(gifter, b.toString(), null, -1, MsgTags.EMPTY);
this.gifter = null;
this.text = null;
this.subPlan = null;
Expand Down Expand Up @@ -1188,6 +1188,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);

if (tags.isValue("msg-id", "announcement") && !StringUtil.isNullOrEmpty(login)) {
String displayName = tags.get("display-name", login);
Expand Down Expand Up @@ -1215,6 +1216,9 @@ 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.";
}
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
35 changes: 31 additions & 4 deletions src/chatty/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ public synchronized void addMsgDeleted(String targetMsgId, String msg) {
replayCachedBanInfo();
}

public synchronized void addSub(String message, String text) {
public synchronized void addSub(String message, String text, String id) {
setFirstSeen();
addLine(new SubMessage(System.currentTimeMillis(), message, text));
addLine(new SubMessage(System.currentTimeMillis(), message, text, id));
}

public synchronized void addInfo(String message, String fullText) {
Expand Down Expand Up @@ -598,9 +598,34 @@ public synchronized TextMessage getMessage(String msgId) {
return null;
}

public synchronized SubMessage getSubMessage(String msgId) {
if (msgId == null) {
return null;
}
if (lines == null) {
return null;
}
for (Message msg : lines) {
if (msg instanceof SubMessage) {
SubMessage textMsg = (SubMessage)msg;
if (msgId.equals(textMsg.id)) {
return textMsg;
}
}
}
return null;
}

public String getMessageText(String msgId) {
TextMessage msg = getMessage(msgId);
return msg != null ? msg.text : null;
if (msg != null) {
return msg.text;
}
SubMessage subMsg = getSubMessage(msgId);
if (subMsg != null) {
return subMsg.attached_message;
}
return null;
}

public synchronized AutoModMessage getAutoModMessage(String msgId) {
Expand Down Expand Up @@ -1291,11 +1316,13 @@ public static class SubMessage extends Message {

public final String attached_message;
public final String system_msg;
public final String id;

public SubMessage(long time, String message, String text) {
public SubMessage(long time, String message, String text, String id) {
super(time);
this.attached_message = message;
this.system_msg = text;
this.id = id;
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/chatty/gui/Highlighter.java
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,11 @@ else if (part.equals("restricted")) {
return tags.isRestrictedMessage();
});
}
else if (part.equals("hypechat")) {
addTagsItem("Hype Chat", null, tags -> {
return tags.getHypeChatAmountText() != null;
});
}
else if (part.startsWith("repeatedmsg")) {
// String options = parsePrefix(item, "repeatmsg:");
// String[] split = options.split("/");
Expand Down Expand Up @@ -1938,6 +1943,14 @@ public boolean matches(Type type, String text, int msgStart, int msgEnd,
ab = user.getAddressbook();
}
}
if (localUser != null) {
if (channel == null) {
channel = localUser.getChannel();
}
if (ab == null) {
ab = localUser.getAddressbook();
}
}
if (tags == null) {
tags = MsgTags.EMPTY;
}
Expand Down
72 changes: 52 additions & 20 deletions src/chatty/gui/MainGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -2592,33 +2592,52 @@ public void userClicked(User user, String msgId, String autoModMsgId, MouseEvent
});
return;
}
if (e == null || (!e.isControlDown() && !e.isAltDown())) {
if (e == null ||
(!e.isControlDown()
&& !e.isAltDown()
&& !SwingUtilities.isMiddleMouseButton(e))) {
openUserInfoDialog(user, msgId, autoModMsgId);
return;
}
String command = client.settings.getString("commandOnCtrlClick").trim();
if (e.isControlDown() && command.length() > 1) {
CustomCommand customCommand;
Parameters parameters = Parameters.create(user.getRegularDisplayNick());
Helper.addUserParameters(user, msgId, autoModMsgId, parameters);
if (command.contains(" ")) {
// Assume that something containing a space is direct Custom Command
customCommand = CustomCommand.parse(command);
if (SwingUtilities.isMiddleMouseButton(e)) {
if (e.isControlDown()) {
userClickCommand(user, client.settings.getString("commandOnCtrlMiddleClick"), msgId, autoModMsgId);
} else {
// Just a command name (old format)
if (!command.startsWith("/")) {
// Need to add since not calling client.command(), so
// it would just be output to chat (but could just be
// a command name)
command = "/"+command;
}
customCommand = CustomCommand.createDefault(command);
userClickCommand(user, client.settings.getString("commandOnMiddleClick"), msgId, autoModMsgId);
}
client.anonCustomCommand(user.getRoom(), customCommand, parameters);
} else if (!e.isAltDown()) {
}
else if (e.isControlDown() && command.length() > 1) {
userClickCommand(user, command, msgId, autoModMsgId);
}
else if (!e.isAltDown()) {
openUserInfoDialog(user, msgId, autoModMsgId);
}
}

private void userClickCommand(User user, String command, String msgId, String autoModMsgId) {
command = command.trim();
if (command.length() <= 1) {
return;
}
CustomCommand customCommand;
Parameters parameters = Parameters.create(user.getRegularDisplayNick());
Helper.addUserParameters(user, msgId, autoModMsgId, parameters);
if (command.contains(" ")) {
// Assume that something containing a space is direct Custom Command
customCommand = CustomCommand.parse(command);
} else {
// Just a command name (old format)
if (!command.startsWith("/")) {
// Need to add since not calling client.command(), so
// it would just be output to chat (but could just be
// a command name)
command = "/" + command;
}
customCommand = CustomCommand.createDefault(command);
}
client.anonCustomCommand(user.getRoom(), customCommand, parameters);
}

@Override
public void emoteClicked(Emoticon emote, MouseEvent e) {
Expand Down Expand Up @@ -2768,7 +2787,7 @@ else if (!Helper.isValidStream(username)) {
}
else {
User user = client.getUser(channel, username);
openUserInfoDialog(user, null, null);
openUserInfoDialog(user, p.getParameters().get("msg-id"), null);
}
});
client.commands.addEdt("search", p -> {
Expand Down Expand Up @@ -3628,6 +3647,18 @@ public void run() {
user.addMessage(processMessage(text), action, tags.getId(), timestamp);
}
// Update User
String hypeChatAmount = tags.getHypeChatAmountText();
if (hypeChatAmount != null) {
user.addSub(processMessage(text), tags.getHypeChatInfo(), tags.getId());
}
else {
// Stuff independent of highlight/ignore
if (timestamp == null) {
user.addMessage(processMessage(text), action, tags.getId());
} else {
user.addMessage(processMessage(text), action, tags.getId(), timestamp);
}
}
if (highlighted) {
user.setHighlighted();
}
Expand Down Expand Up @@ -3690,7 +3721,7 @@ private boolean printUsernotice(UserNotice m) {
String message = m.attachedMessage != null ? processMessage(m.attachedMessage) : "";
String text = m.infoText;
if (m instanceof SubscriberMessage) {
m.user.addSub(message, text);
m.user.addSub(message, text, m.tags.getId());
} else {
m.user.addInfo(message, m.text);
}
Expand Down Expand Up @@ -5053,6 +5084,7 @@ private void setTokenScopes(TokenInfo info) {
}
if (info.valid) {
client.settings.putList("scopes", info.scopes);
AccessChecker.instance().removeWarningsForAvailableScopes();
} else {
client.settings.listClear("scopes");
}
Expand Down
Loading

0 comments on commit 94a6452

Please sign in to comment.