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
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN maven -f pom.xml clean package
|
||||
RUN mvn -f pom.xml clean assembly:assembly
|
||||
|
||||
FROM openjdk:18-jre-slim
|
||||
COPY --from=build /app/target/1.0.0
|
||||
FROM gcr.io/distroless/java17
|
||||
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>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>14</maven.compiler.source>
|
||||
<maven.compiler.target>14</maven.compiler.target>
|
||||
<maven.compiler.source>18</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</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);
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
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();
|
||||
try {
|
||||
interactivePrompt(jda);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Interactive mode failed, presumably no TTY attached. Ignoring interactive mode...");
|
||||
}
|
||||
System.exit(0);
|
||||
});
|
||||
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() {
|
||||
new HelpCommand();
|
||||
new EvalCommand();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue