Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Add Shortify configuration option.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaude committed Feb 20, 2014
1 parent 1f629da commit 924afb9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Expand Up @@ -42,8 +42,8 @@ public void onMessage(MessageEvent event) {
User user = event.getUser();

plugin.logDebug("Message caught <" + user.getNick() + ">: " + message);

if (plugin.shortifyHook != null) {
if (plugin.shortifyHook != null && ircBot.isShortifyEnabled(channel.getName())) {
message = plugin.shortifyHook.shorten(message);
}

Expand Down
16 changes: 14 additions & 2 deletions src/main/java/com/cnaude/purpleirc/PurpleBot.java
Expand Up @@ -66,7 +66,7 @@ public final class PurpleBot {
public boolean showMOTD;
public boolean channelCmdNotifyEnabled;
public boolean relayPrivateChat;
public boolean partInvalidChannels;
public boolean partInvalidChannels;
public int botServerPort;
public long chatDelay;
public String botServer;
Expand Down Expand Up @@ -97,6 +97,7 @@ public final class PurpleBot {
public CaseInsensitiveMap<Boolean> hideQuitWhenVanished;
public CaseInsensitiveMap<Boolean> invalidCommandPrivate;
public CaseInsensitiveMap<Boolean> invalidCommandCTCP;
private CaseInsensitiveMap<Boolean> shortify;
public CaseInsensitiveMap<String> heroChannel;
public CaseInsensitiveMap<Collection<String>> opsList;
public CaseInsensitiveMap<Collection<String>> worldList;
Expand Down Expand Up @@ -125,6 +126,7 @@ public PurpleBot(File file, PurpleIRC plugin) {
this.opsList = new CaseInsensitiveMap<Collection<String>>();
this.heroChannel = new CaseInsensitiveMap<String>();
this.invalidCommandCTCP = new CaseInsensitiveMap<Boolean>();
this.shortify = new CaseInsensitiveMap<Boolean>();
this.invalidCommandPrivate = new CaseInsensitiveMap<Boolean>();
this.hideQuitWhenVanished = new CaseInsensitiveMap<Boolean>();
this.hideListWhenVanished = new CaseInsensitiveMap<Boolean>();
Expand Down Expand Up @@ -304,6 +306,13 @@ public void asyncConnect(CommandSender sender) {
sender.sendMessage(connectMessage);
asyncConnect();
}

public boolean isShortifyEnabled(String channelName) {
if (shortify.containsKey(channelName)) {
return shortify.get(channelName);
}
return false;
}

/**
*
Expand Down Expand Up @@ -465,7 +474,7 @@ private void sanitizeServerName() {
private void loadConfig() {
try {
config.load(file);
autoConnect = config.getBoolean("autoconnect", true);
autoConnect = config.getBoolean("autoconnect", true);
ssl = config.getBoolean("ssl", false);
trustAllCerts = config.getBoolean("trust-all-certs", false);
sendRawMessageOnConnect = config.getBoolean("raw-message-on-connect", false);
Expand Down Expand Up @@ -565,6 +574,9 @@ private void loadConfig() {

invalidCommandCTCP.put(channelName, config.getBoolean("channels." + enChannelName + ".invalid-command.ctcp", false));
plugin.logDebug(" InvalidCommandCTCP => " + invalidCommandCTCP.get(channelName));

shortify.put(channelName, config.getBoolean("channels." + enChannelName + ".shortify", true));
plugin.logDebug(" Shortify => " + shortify.get(channelName));

// build channel op list
Collection<String> cOps = new ArrayList<String>();
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/SampleBot.yml
Expand Up @@ -70,6 +70,8 @@ channels:
topic: New topic
# topic-protect - Prevent others from changing the topic
topic-protect: false
# If the Shortify plugin is installed then shoten URLs sent from IRC
shortify: true
# enabled-messages - These are the message types that are either sent to the game or IRC
# config.yml. Remove or comment the messages you don't want.
enabled-messages:
Expand Down

0 comments on commit 924afb9

Please sign in to comment.