Skip to content

Commit

Permalink
Improve chatlog whitelist/blacklist for whispers
Browse files Browse the repository at this point in the history
- Allow whisper channels to be added through the settings GUI
- Add exception for $_whisper_ to also affect per user logging
  • Loading branch information
tduva committed Aug 28, 2020
1 parent 8039899 commit e3a3b1c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/chatty/gui/components/help/help-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,10 @@ <h3>Channels</h3>
<li><strong>off</strong> - Log no channels whatsoever</li>
</ul>

<p><em>Tip:</em> Add <code>$_whisper_</code> to the whitelist or blacklist
to affect all whispers that are output in the "One Window" tab or
"Per User" tabs.</p>

<h3>Other Settings</h3>
<dl class="dl-settings">
<dt>Folder</dt>
Expand Down
3 changes: 2 additions & 1 deletion src/chatty/gui/components/settings/LogSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ private static class ChannelFormatter implements DataFormatter<String> {
*/
@Override
public String format(String input) {
if (input != null && !input.isEmpty() && !input.startsWith("#")) {
if (input != null && !input.isEmpty() && !input.startsWith("#")
&& !input.startsWith("$")) {
input = "#"+input;
}
if (input.length() == 1) {
Expand Down
20 changes: 15 additions & 5 deletions src/chatty/util/chatlog/ChatLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,24 @@ private boolean isChanEnabled(String channel) {
if (mode.equals("off")) {
return false;
}
if (mode.equals("always")) {
else if (mode.equals("always")) {
return true;
}
if (mode.equals("blacklist") && !settings.listContains("logBlacklist", channel)) {
return true;
else if (mode.equals("blacklist")) {
if (!settings.listContains("logBlacklist", channel)) {
return true;
}
if (channel.startsWith("$") && !settings.listContains("logBlacklist", "$_whisper_")) {
return true;
}
}
if (mode.equals("whitelist") && settings.listContains("logWhitelist", channel)) {
return true;
else if (mode.equals("whitelist")) {
if (settings.listContains("logWhitelist", channel)) {
return true;
}
if (channel.startsWith("$") && settings.listContains("logWhitelist", "$_whisper_")) {
return true;
}
}
return false;
}
Expand Down

0 comments on commit e3a3b1c

Please sign in to comment.