mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-12-25 01:47:35 +01:00
Merge pull request #62 from cnaude/feature/sasl-password-file
new feature to load sasl password from file
This commit is contained in:
commit
e8b7c2ec0a
16
pom.xml
16
pom.xml
@ -6,7 +6,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- Bukkit API Version, change if out dated -->
|
||||
<bukkit.version>1.20-R0.1-SNAPSHOT</bukkit.version>
|
||||
<bukkit.version>1.20.6-R0.1-SNAPSHOT</bukkit.version>
|
||||
<build.number>SNAPSHOT</build.number>
|
||||
</properties>
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
|
||||
<repositories>
|
||||
<!-- For anything else without its own repo -->
|
||||
<repository>
|
||||
@ -72,7 +71,18 @@
|
||||
<repository>
|
||||
<id>dynmap</id>
|
||||
<url>https://repo.mikeprimm.com/</url>
|
||||
</repository>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.sk89q.com/repo/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
|
@ -39,6 +39,7 @@ import static com.cnaude.purpleirc.IRCMessage.Type.CTCP;
|
||||
import static com.cnaude.purpleirc.IRCMessage.Type.MESSAGE;
|
||||
import static com.cnaude.purpleirc.IRCMessage.Type.NOTICE;
|
||||
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
|
||||
import com.cnaude.purpleirc.Utilities.FileHelpers;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
@ -132,6 +133,7 @@ public final class PurpleBot {
|
||||
public String botIdentPassword;
|
||||
public String saslUsername;
|
||||
public String saslPassword;
|
||||
public String saslPasswordFile;
|
||||
public List<String> rawMessages;
|
||||
public String channelCmdNotifyMode;
|
||||
public String partInvalidChannelsMsg;
|
||||
@ -818,7 +820,14 @@ public final class PurpleBot {
|
||||
botServerPass = config.getString("password", "");
|
||||
botIdentPassword = config.getString("ident-password", "");
|
||||
saslUsername = config.getString("sasl-username", "");
|
||||
saslPassword = config.getString("sasl-password", "");
|
||||
saslPasswordFile = config.getString("sasl-password-file", "");
|
||||
if (!saslPasswordFile.isEmpty()) {
|
||||
plugin.logInfo("Loading sasl password from file: " + saslPasswordFile);
|
||||
saslPassword = FileHelpers.loadFirstLineFromFile(saslPasswordFile);
|
||||
} else {
|
||||
saslPassword = config.getString("sasl-password", "");
|
||||
}
|
||||
// plugin.logDebug("saslPassword: " + saslPassword);
|
||||
commandPrefix = config.getString("command-prefix", ".");
|
||||
chatDelay = config.getLong("message-delay", 1000);
|
||||
finger = config.getString("finger-reply", "PurpleIRC");
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.cnaude.purpleirc.Utilities;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class FileHelpers {
|
||||
|
||||
public static String loadFirstLineFromFile(String filePath) throws IOException {
|
||||
File file = new File(filePath);
|
||||
|
||||
if (!file.exists() || !file.canRead()) {
|
||||
throw new IOException("File does not exist or is not readable.");
|
||||
}
|
||||
|
||||
String firstLine;
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath))) {
|
||||
firstLine = bufferedReader.readLine();
|
||||
}
|
||||
return firstLine;
|
||||
}
|
||||
}
|
@ -47,6 +47,8 @@ ident-password: ''
|
||||
sasl: false
|
||||
# SASL password
|
||||
sasl-password: ''
|
||||
# Load SASL password from a file instead of this YAML file
|
||||
sasl-password-file: ''
|
||||
# SASL username
|
||||
sasl-username: ''
|
||||
# command-prefix - The bot will listen for commands that start with this.
|
||||
|
Loading…
Reference in New Issue
Block a user