1
0
mirror of https://github.com/demodude4u/Factorio-FBSR.git synced 2025-02-19 19:59:54 +02:00

Added album link to reddit bot

This commit is contained in:
Weston Rye (Demod) 2017-08-07 22:27:05 -04:00
parent 849ef5f551
commit dd37dedf17

View File

@ -6,6 +6,8 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
@ -158,7 +160,29 @@ public class BlueprintBotRedditService extends AbstractScheduledService {
List<Pair<Optional<String>, String>> images = reporting.getImages();
if (images.size() > 1) {
int id = 1;
lines.add("Blueprint Images:");
List<Pair<URL, String>> links = new ArrayList<>();
for (Pair<Optional<String>, String> pair : images) {
Optional<String> label = pair.getKey();
String url = pair.getValue();
try {
links.add(new Pair<>(new URL(url), label.orElse(null)));
} catch (MalformedURLException e) {
reporting.addException(e);
}
}
Optional<URL> albumUrl;
try {
albumUrl = Optional
.of(WebUtils.uploadToBundly("Blueprint Images", "Renderings provided by Blueprint Bot", links));
} catch (IOException e) {
reporting.addException(e);
albumUrl = Optional.empty();
}
if (albumUrl.isPresent()) {
lines.add("Blueprint Images ([View As Album](" + albumUrl.get() + ")):\n");
} else {
lines.add("Blueprint Images:");
}
for (Pair<Optional<String>, String> pair : images) {
Optional<String> label = pair.getKey();
String url = pair.getValue();