Compare commits

...

2 Commits

Author SHA1 Message Date
e396ce6417 Start implementing yaml loading
Some checks failed
continuous-integration/drone/push Build is failing
2022-11-21 20:20:03 +01:00
66d27fe1fe Start implementing config file 2022-11-21 20:04:28 +01:00
4 changed files with 62 additions and 7 deletions

View File

@ -11,16 +11,15 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class Configuration
public class Cache
{
private static DatabaseManager dbManager = null;
private static boolean verbose = false;
private static MessageLogger verbosityLogger;
// todo: allow people to set their own user id
private static final long botOwnerId = 979809420714332260L;
private static final long botMaintainerId = 979809420714332260L;
private static long botOwnerId = 0L;
private final static String expiryTimestampFormat = "yy/MM/dd HH:mm:ss";
@ -98,6 +97,14 @@ public class Configuration
*/
public static long getBotOwnerId() { return botOwnerId; }
/**
* Get the bot maintainer's profile id.
*
* @return a long of the account's id
*/
public static long getBotMaintainerId() { return botMaintainerId; }
/**
* Set the bot's application id.
*

View File

@ -67,9 +67,9 @@ public class BotInfoCommand
DecimalFormat ramMBFormatter = new DecimalFormat("#.##");
embedBuilder.addField("RAM Usage", ramMBFormatter.format(usedRamMB) + " MB", true);
// author field
String authorMention = "<@" + Configuration.getBotOwnerId() + ">";
embedBuilder.addField("Author", authorMention, true);
// developer field
String developerMention = "<@" + Configuration.getBotMaintainerId() + ">";
embedBuilder.addField("Maintainer", developerMention, true);
// uptime field
embedBuilder.addField("Uptime", FormatUtil.getNiceUptime(), true);

View File

@ -0,0 +1,40 @@
package wtf.beatrice.hidekobot.utils;
import org.yaml.snakeyaml.Yaml;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
public class ConfigurationUtil
{
private final String configFilePath;
public ConfigurationUtil(String configFilePath)
{
this.configFilePath = configFilePath;
}
public void initConfig()
{
Yaml internalConfigYaml = new Yaml();
Map<String, Object> internalConfigContents = null;
try (InputStream internalConfigStream = getClass()
.getClassLoader()
.getResourceAsStream("config.yml"))
{
internalConfigContents = internalConfigYaml.load(internalConfigStream);
} catch (IOException e) {
e.printStackTrace();
}
if(internalConfigContents == null) // todo error handling
{
return;
}
}
}

View File

@ -0,0 +1,8 @@
bot-settings:
bot-token: 'paste-token-here'
bot-owner-id: 'paste_your_user_id_here'
bot-color: 'PINK'
system-settings:
heartbeat:
enabled: false
link: 'https://your-heartbeat-api.com/api/push/apikey?status=up&msg=OK&ping='