mirror of
https://github.com/Noratrieb/killua-bot.git
synced 2026-01-14 15:15:01 +01:00
recover from missing tty
This commit is contained in:
parent
f0c8af29a3
commit
789064d2d5
4 changed files with 44 additions and 29 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
FROM maven AS build
|
FROM maven AS build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN maven -f pom.xml clean package
|
RUN mvn -f pom.xml clean assembly:assembly
|
||||||
|
|
||||||
FROM openjdk:18-jre-slim
|
FROM gcr.io/distroless/java17
|
||||||
COPY --from=build /app/target/1.0.0
|
COPY --from=build /app/target/KilluaBot-1.0.0-jar-with-dependencies.jar /app/KilluaBot.jar
|
||||||
|
ENTRYPOINT ["java", "-jar", "/app/KilluaBot.jar"]
|
||||||
4
pom.xml
4
pom.xml
|
|
@ -9,8 +9,8 @@
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>14</maven.compiler.source>
|
<maven.compiler.source>18</maven.compiler.source>
|
||||||
<maven.compiler.target>14</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
||||||
5
run.sh
Normal file
5
run.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
docker run -e "BOT_TOKEN=LOL" -e "KILLUA_JSON_PATH=/app/trivia_questions.json" \
|
||||||
|
-v "$(pwd)/trivia_questions.json:/app/trivia_questions.json" \
|
||||||
|
--name killua-bot killua-bot:1.0
|
||||||
|
|
@ -42,35 +42,44 @@ public class Main {
|
||||||
Config.setJda(jda);
|
Config.setJda(jda);
|
||||||
|
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
Scanner scanner = new Scanner(System.in);
|
try {
|
||||||
String line = scanner.nextLine();
|
interactivePrompt(jda);
|
||||||
while (!line.equals("exit") && !line.equals("quit")) {
|
} catch (Exception e) {
|
||||||
if (line.startsWith("send")) {
|
e.printStackTrace();
|
||||||
System.out.println("GuildID");
|
System.err.println("Interactive mode failed, presumably no TTY attached. Ignoring interactive mode...");
|
||||||
line = scanner.nextLine();
|
|
||||||
Guild guild = jda.getGuildById(line);
|
|
||||||
if (guild != null) {
|
|
||||||
System.out.println("TextChannelID");
|
|
||||||
line = scanner.nextLine();
|
|
||||||
TextChannel textChannel = guild.getTextChannelById(line);
|
|
||||||
if (textChannel != null) {
|
|
||||||
System.out.println("Message");
|
|
||||||
line = scanner.nextLine();
|
|
||||||
if (!line.equals("")) {
|
|
||||||
textChannel.sendMessage(line).queue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (line.startsWith("version") || line.startsWith("v")) {
|
|
||||||
System.out.println(Config.VERSION);
|
|
||||||
}
|
|
||||||
line = scanner.nextLine();
|
|
||||||
}
|
}
|
||||||
System.exit(0);
|
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void interactivePrompt(JDA jda) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
String line = scanner.nextLine();
|
||||||
|
while (!line.equals("exit") && !line.equals("quit")) {
|
||||||
|
if (line.startsWith("send")) {
|
||||||
|
System.out.println("GuildID");
|
||||||
|
line = scanner.nextLine();
|
||||||
|
Guild guild = jda.getGuildById(line);
|
||||||
|
if (guild != null) {
|
||||||
|
System.out.println("TextChannelID");
|
||||||
|
line = scanner.nextLine();
|
||||||
|
TextChannel textChannel = guild.getTextChannelById(line);
|
||||||
|
if (textChannel != null) {
|
||||||
|
System.out.println("Message");
|
||||||
|
line = scanner.nextLine();
|
||||||
|
if (!line.equals("")) {
|
||||||
|
textChannel.sendMessage(line).queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (line.startsWith("version") || line.startsWith("v")) {
|
||||||
|
System.out.println(Config.VERSION);
|
||||||
|
}
|
||||||
|
line = scanner.nextLine();
|
||||||
|
}
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
private static void setupCommands() {
|
private static void setupCommands() {
|
||||||
new HelpCommand();
|
new HelpCommand();
|
||||||
new EvalCommand();
|
new EvalCommand();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue