use of com.demod.fbsr.FBSR in project Factorio-FBSR by demodude4u.
the class BlueprintBotDiscordService method startUp.
@Override
protected void startUp() throws JSONException, IOException {
configJson = Config.get().getJSONObject("discord");
DataTable table = FactorioData.getTable();
System.out.println("Factorio " + FBSR.getVersion() + " Data Loaded.");
bot = //
DCBA.builder().setInfo(//
"Blueprint Bot").withSupport(//
"Find Demod and complain to him!\nYou can find him over in the [Factorio Discord.](https://discord.gg/factorio)").withTechnology("[FBSR](https://github.com/demodude4u/Factorio-FBSR)", //
"Factorio Blueprint String Renderer").withTechnology("[FactorioDataWrapper](https://github.com/demodude4u/Java-Factorio-Data-Wrapper)", //
"Factorio Data Scraper").withCredits("Attribution", //
"[Factorio](https://www.factorio.com/) - Made by Wube Software").withCredits("Contributors", //
"Demod").withCredits("Contributors", //
"Bilka").withCredits("Contributors", //
"FactorioBlueprints").withCredits("Contributors", //
"acid").withCredits("Contributors", //
"Vilsol").withInvite(new Permission[] { //
Permission.VIEW_CHANNEL, //
Permission.MESSAGE_SEND, //
Permission.MESSAGE_ATTACH_FILES, //
Permission.MESSAGE_EXT_EMOJI, //
Permission.MESSAGE_EMBED_LINKS, //
Permission.MESSAGE_HISTORY, //
Permission.MESSAGE_ADD_REACTION }).withCustomField("Need old !blueprint commands?", //
"[BlueprintBot Legacy Invite Link](https://discord.com/oauth2/authorize?scope=bot&client_id=958469202824552498&permissions=379968)").addMessageCommand("Blueprint Image", event -> handleBlueprintMessageCommand(event)).addSlashCommand("blueprint/string", "Renders an image of the blueprint string.", //
event -> handleBlueprintSlashCommand(event)).withParam(OptionType.STRING, "string", //
"Blueprint string.").withOptionalParam(OptionType.BOOLEAN, "simple", "Set True to show just the image, no side panels.").withOptionalParam(OptionType.INTEGER, "max-width", "Maximum width of image, in pixels.").withOptionalParam(OptionType.INTEGER, "max-height", "Maximum height of image, in pixels.").withLegacyWarning("blueprint", //
"bp").addSlashCommand("blueprint/url", "Renders an image of the blueprint url.", //
event -> handleBlueprintSlashCommand(event)).withParam(OptionType.STRING, "url", //
"Url containing blueprint string.").withOptionalParam(OptionType.BOOLEAN, "simple", "Set True to show just the image, no side panels.").withOptionalParam(OptionType.INTEGER, "max-width", "Maximum width of image, in pixels.").withOptionalParam(OptionType.INTEGER, "max-height", "Maximum height of image, in pixels.").addSlashCommand("blueprint/file", "Renders an image of the blueprint attachment.", //
event -> handleBlueprintSlashCommand(event)).withParam(OptionType.ATTACHMENT, "file", //
"File containing blueprint string.").withOptionalParam(OptionType.BOOLEAN, "simple", "Set True to show just the image, no side panels.").withOptionalParam(OptionType.INTEGER, "max-width", "Maximum width of image, in pixels.").withOptionalParam(OptionType.INTEGER, "max-height", "Maximum height of image, in pixels.").addSlashCommand("json", "Provides a dump of the json data in the specified blueprint string.", //
event -> handleBlueprintJsonCommand(event)).withOptionalParam(OptionType.STRING, "string", //
"Blueprint string.").withOptionalParam(OptionType.STRING, "url", //
"Url containing blueprint string.").withOptionalParam(OptionType.ATTACHMENT, "file", //
"File containing blueprint string.").withLegacyWarning(//
"blueprintJSON").addSlashCommand("upgrade/belts", "Converts all yellow belts into red belts, and all red belts into blue belts.", //
event -> handleBlueprintUpgradeBeltsCommand(event)).withOptionalParam(OptionType.STRING, "string", //
"Blueprint string.").withOptionalParam(OptionType.STRING, "url", //
"Url containing blueprint string.").withOptionalParam(OptionType.ATTACHMENT, "file", //
"File containing blueprint string.").withLegacyWarning(//
"blueprintUpgradeBelts").addSlashCommand("items", "Prints out all of the items needed by the blueprint.", //
event -> handleBlueprintItemsCommand(event)).withOptionalParam(OptionType.STRING, "string", //
"Blueprint string.").withOptionalParam(OptionType.STRING, "url", //
"Url containing blueprint string.").withOptionalParam(OptionType.ATTACHMENT, "file", //
"File containing blueprint string.").withLegacyWarning("blueprintItems", //
"bpItems").addSlashCommand("raw/items", "Prints out all of the raw items needed by the blueprint.", //
event -> handleBlueprintItemsRawCommand(event)).withOptionalParam(OptionType.STRING, "string", //
"Blueprint string.").withOptionalParam(OptionType.STRING, "url", //
"Url containing blueprint string.").withOptionalParam(OptionType.ATTACHMENT, "file", //
"File containing blueprint string.").withLegacyWarning("blueprintRawItems", //
"bpRawItems").addSlashCommand("counts", "Prints out the total counts of entities, items and tiles needed by the blueprint.", event -> handleBlueprintTotalsCommand(event)).withOptionalParam(OptionType.STRING, "string", //
"Blueprint string.").withOptionalParam(OptionType.STRING, "url", //
"Url containing blueprint string.").withOptionalParam(OptionType.ATTACHMENT, "file", //
"File containing blueprint string.").withLegacyWarning("blueprintCounts", //
"bpCounts").addSlashCommand("book/extract", "Provides an collection of blueprint strings contained within the specified blueprint book.", //
event -> handleBlueprintBookExtractCommand(event)).withOptionalParam(OptionType.STRING, "string", //
"Blueprint string.").withOptionalParam(OptionType.STRING, "url", //
"Url containing blueprint string.").withOptionalParam(OptionType.ATTACHMENT, "file", //
"File containing blueprint string.").withLegacyWarning(//
"blueprintBookExtract").addSlashCommand("book/assemble", "Combines all blueprints (including from other books) from multiple strings into a single book.", //
event -> handleBlueprintBookAssembleCommand(event)).withOptionalParam(OptionType.STRING, "string", //
"Blueprint string.").withOptionalParam(OptionType.STRING, "url", //
"Url containing blueprint string.").withOptionalParam(OptionType.ATTACHMENT, "file", //
"File containing blueprint string.").withLegacyWarning(//
"blueprintBookAssemble").addSlashCommand("prototype/entity", "Lua data for the specified entity prototype.", createPrototypeCommandHandler("entity", table.getEntities()), //
createPrototypeAutoCompleteHandler(table.getEntities())).withAutoParam(OptionType.STRING, "name", //
"Prototype name of the entity.").withLegacyWarning(//
"prototypeEntity").addSlashCommand("prototype/recipe", "Lua data for the specified recipe prototype.", createPrototypeCommandHandler("recipe", table.getRecipes()), //
createPrototypeAutoCompleteHandler(table.getRecipes())).withAutoParam(OptionType.STRING, "name", //
"Prototype name of the recipe.").withLegacyWarning(//
"prototypeRecipe").addSlashCommand("prototype/fluid", "Lua data for the specified fluid prototype.", createPrototypeCommandHandler("fluid", table.getFluids()), //
createPrototypeAutoCompleteHandler(table.getFluids())).withAutoParam(OptionType.STRING, "name", //
"Prototype name of the fluid.").withLegacyWarning(//
"prototypeFluid").addSlashCommand("prototype/item", "Lua data for the specified item prototype.", createPrototypeCommandHandler("item", table.getItems()), //
createPrototypeAutoCompleteHandler(table.getItems())).withAutoParam(OptionType.STRING, "name", //
"Prototype name of the item.").withLegacyWarning(//
"prototypeItem").addSlashCommand("prototype/technology", "Lua data for the specified technology prototype.", createPrototypeCommandHandler("technology", table.getTechnologies()), //
createPrototypeAutoCompleteHandler(table.getTechnologies())).withAutoParam(OptionType.STRING, "name", //
"Prototype name of the technology.").withLegacyWarning(//
"prototypeTechnology").addSlashCommand("prototype/equipment", "Lua data for the specified equipment prototype.", createPrototypeCommandHandler("equipment", table.getEquipments()), //
createPrototypeAutoCompleteHandler(table.getEquipments())).withAutoParam(OptionType.STRING, "name", //
"Prototype name of the equipment.").withLegacyWarning(//
"prototypeEquipment").addSlashCommand("prototype/tile", "Lua data for the specified tile prototype.", createPrototypeCommandHandler("tile", table.getTiles()), //
createPrototypeAutoCompleteHandler(table.getTiles())).withAutoParam(OptionType.STRING, "name", //
"Prototype name of the tile.").withLegacyWarning(//
"prototypeTile").addSlashCommand("data/raw", "Lua from `data.raw` for the specified key.", //
createDataRawCommandHandler(table::getRaw)).withParam(OptionType.STRING, "path", //
"Path to identify which key.").withLegacyWarning(//
"dataRaw").withCustomSetup(builder -> {
return //
builder.setChunkingFilter(//
ChunkingFilter.NONE);
}).create();
bot.startAsync().awaitRunning();
hostingChannelID = configJson.getString("hosting_channel_id");
ServiceFinder.addService(this);
ServiceFinder.addService(WatchdogReporter.class, new WatchdogReporter() {
@Override
public void notifyInactive(String label) {
CommandReporting reporting = new CommandReporting("Watchdog Reporter", null, null);
reporting.addWarning(label + " has gone inactive!");
bot.submitReport(reporting);
}
@Override
public void notifyReactive(String label) {
CommandReporting reporting = new CommandReporting("Watchdog Reporter", null, null);
reporting.addWarning(label + " is now active again!");
bot.submitReport(reporting);
}
});
}
Aggregations