mirror of
https://github.com/Noratrieb/killua-bot.git
synced 2026-01-14 15:15:01 +01:00
trivia things
This commit is contained in:
parent
7ffb771946
commit
a30e1653ca
7 changed files with 80 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@ target\*
|
||||||
.idea/*
|
.idea/*
|
||||||
*.class
|
*.class
|
||||||
Secrets.java
|
Secrets.java
|
||||||
|
src\main\java\com\github\nilstrieb\cofig/Secrets.java
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
[]
|
|
||||||
17
pom.xml
17
pom.xml
|
|
@ -34,5 +34,22 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>com.github.nilstrieb.core.Main</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -23,7 +23,7 @@ public class TriviaCommand extends Command {
|
||||||
4 Greed Island arc
|
4 Greed Island arc
|
||||||
5 Chimera Ant arc
|
5 Chimera Ant arc
|
||||||
6 Election arc
|
6 Election arc
|
||||||
|
|
||||||
Add questions using `""" + Config.PREFIX + "trivia add`");
|
Add questions using `""" + Config.PREFIX + "trivia add`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,7 +128,14 @@ public class TriviaCommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(MessageReceivedEvent event) {
|
public void messageReceived(MessageReceivedEvent event) {
|
||||||
if (!event.getMessage().getContentRaw().startsWith(Config.PREFIX + "help")) {
|
if (event.getAuthor().getIdLong() == Config.NILS_ID && event.getMessage().getContentRaw().startsWith("debug")) {
|
||||||
|
answers[0] = "question";
|
||||||
|
answers[1] = "a;b;c;d";
|
||||||
|
answers[2] = "0";
|
||||||
|
answers[3] = "0";
|
||||||
|
new TriviaApproval(event, new TriviaQuestion(answers));
|
||||||
|
} else {
|
||||||
|
|
||||||
System.out.println(ConsoleColors.BLUE_BOLD + "[TriviaCommand.AddSection 121] Received Next Message: "
|
System.out.println(ConsoleColors.BLUE_BOLD + "[TriviaCommand.AddSection 121] Received Next Message: "
|
||||||
+ event.getMessage().getContentRaw() + " status: " + status + ConsoleColors.RESET);
|
+ event.getMessage().getContentRaw() + " status: " + status + ConsoleColors.RESET);
|
||||||
answers[status] = event.getMessage().getContentRaw();
|
answers[status] = event.getMessage().getContentRaw();
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,17 @@ import com.github.nilstrieb.listener.ChannelMessageListener;
|
||||||
import com.github.nilstrieb.listener.CommandListener;
|
import com.github.nilstrieb.listener.CommandListener;
|
||||||
import com.github.nilstrieb.listener.ReactionEventListener;
|
import com.github.nilstrieb.listener.ReactionEventListener;
|
||||||
import com.github.nilstrieb.listener.StartUpListener;
|
import com.github.nilstrieb.listener.StartUpListener;
|
||||||
|
import com.github.nilstrieb.util.ConsoleColors;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
import net.dv8tion.jda.api.entities.Activity;
|
import net.dv8tion.jda.api.entities.Activity;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
import net.dv8tion.jda.api.utils.Compression;
|
import net.dv8tion.jda.api.utils.Compression;
|
||||||
|
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
|
|
@ -31,6 +36,37 @@ public class Main {
|
||||||
|
|
||||||
JDA jda = builder.build();
|
JDA jda = builder.build();
|
||||||
setupCommands();
|
setupCommands();
|
||||||
|
|
||||||
|
/* Thread t = new Thread(() -> {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
String line = scanner.nextLine();
|
||||||
|
while (!line.equals("exit")) {
|
||||||
|
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("filetest")){
|
||||||
|
File f = new File("hallo.eric");
|
||||||
|
System.out.println(ConsoleColors.BLUE + "[TriviaQuestionData 80] File path " + f.getAbsolutePath() + ConsoleColors.RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
line = scanner.nextLine();
|
||||||
|
}
|
||||||
|
System.exit(0);
|
||||||
|
});
|
||||||
|
t.start();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setupCommands() {
|
private static void setupCommands() {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.github.nilstrieb.util.trivia;
|
||||||
|
|
||||||
import com.github.nilstrieb.util.ConsoleColors;
|
import com.github.nilstrieb.util.ConsoleColors;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -11,9 +10,10 @@ import java.util.Random;
|
||||||
|
|
||||||
public class TriviaQuestionData {
|
public class TriviaQuestionData {
|
||||||
static List<List<TriviaQuestion>> questions = new ArrayList<>();
|
static List<List<TriviaQuestion>> questions = new ArrayList<>();
|
||||||
private static final List<TriviaQuestion> newQuestions = new ArrayList<>();
|
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
|
||||||
|
private static final String JSON_PATH = "trivia_questions.json";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
questions.add(new ArrayList<>());
|
questions.add(new ArrayList<>());
|
||||||
questions.add(new ArrayList<>());
|
questions.add(new ArrayList<>());
|
||||||
|
|
@ -22,28 +22,34 @@ public class TriviaQuestionData {
|
||||||
questions.add(new ArrayList<>());
|
questions.add(new ArrayList<>());
|
||||||
questions.add(new ArrayList<>());
|
questions.add(new ArrayList<>());
|
||||||
questions.add(new ArrayList<>());
|
questions.add(new ArrayList<>());
|
||||||
|
System.out.println(ConsoleColors.BLUE + "[TriviaQuestionData 25] JSON File Path: " + new File(JSON_PATH + "hallo").getAbsolutePath() + ConsoleColors.RESET);
|
||||||
loadJSON();
|
loadJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadJSON() {
|
private static void loadJSON() {
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
StringBuilder json = new StringBuilder();
|
StringBuilder json = new StringBuilder();
|
||||||
try (BufferedReader bufferedReader = new BufferedReader(
|
try (BufferedReader bufferedReader = new BufferedReader(
|
||||||
new FileReader("trivia_questions.json"))) {
|
new FileReader(JSON_PATH))) {
|
||||||
String line = bufferedReader.readLine();
|
String line = bufferedReader.readLine();
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
json.append(line);
|
json.append(line);
|
||||||
line = bufferedReader.readLine();
|
line = bufferedReader.readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
TriviaQuestion[] array = gson.fromJson(json.toString(), TriviaQuestion[].class);
|
||||||
|
|
||||||
|
for (TriviaQuestion triviaQuestion : array) {
|
||||||
|
questions.get(triviaQuestion.getArc()).add(triviaQuestion);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Gson gson = new Gson();
|
|
||||||
TriviaQuestion[] array = gson.fromJson(json.toString(), TriviaQuestion[].class);
|
|
||||||
|
|
||||||
for (TriviaQuestion triviaQuestion : array) {
|
|
||||||
questions.get(triviaQuestion.getArc()).add(triviaQuestion);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void saveJSON(String path, TriviaQuestion[] array) {
|
private static void saveJSON(String path, TriviaQuestion[] array) {
|
||||||
|
|
@ -77,7 +83,7 @@ public class TriviaQuestionData {
|
||||||
|
|
||||||
public static void add(TriviaQuestion triviaQuestion) {
|
public static void add(TriviaQuestion triviaQuestion) {
|
||||||
questions.get(triviaQuestion.getArc()).add(triviaQuestion);
|
questions.get(triviaQuestion.getArc()).add(triviaQuestion);
|
||||||
saveJSONFromAll("trivia_questions.json");
|
saveJSONFromAll(JSON_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TriviaQuestion getQuestion(int toArc) {
|
public static TriviaQuestion getQuestion(int toArc) {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
[{"question":"What\u0027s the name of Gons aunt?","answers":["Kite","Mito","Ging","Kurapika"],"correctAnswer":1,"arc":0},{"question":"Why does Leorio want money?","answers":["To become a doctor","To send it to e-girls","So that others don\u0027t get it","To buy large quantities of drugs"],"correctAnswer":0,"arc":0},{"question":"What was Gon\u0027s aim after Killua left him alone playing with the Chairman Netero?","answers":["Get the ball","Make Netero use his right hand","Make Netero use his left leg","Let Netero drop the ball"],"correctAnswer":1,"arc":0},{"question":"What did Tonpa mix into the drink?","answers":["Sleeping pills","Headache tabletsschla","Laxative","Rat poison"],"correctAnswer":2,"arc":0},{"question":"How many doors are there at the Testing Gate of the Zoldyck Family?","answers":["7","5","12","8"],"correctAnswer":0,"arc":1},{"question":"How many tons did Killua manage to move when he entered Kukooro Mountain","answers":["14","16","32","64"],"correctAnswer":1,"arc":1},{"question":"What did Kurapika bring to his fight with Uvo?","answers":["Shovel","Bomb","Gon"],"correctAnswer":0,"arc":3},{"question":"What is Bisky\u0027s true form?","answers":["Boy","Big Woman","Little Girl"],"correctAnswer":1,"arc":4},{"question":"How did Gon die on Greed Island?","answers":["He didn\u0027t die on Greed Island","Hisoka killed him with a card to the neck","He lost too muich blood when Genthru blew his arm of","He killed himself after Killuas death"],"correctAnswer":0,"arc":4},{"question":"What is Genthrus ability called?","answers":["Nuke","Massive Explosion","Little Flower"],"correctAnswer":2,"arc":4},{"question":"Where did Meruem die?","answers":["Volcano","In the desert with Netero","In the basement of the palace","In the womb of the queen"],"correctAnswer":2,"arc":5},{"question":"What is Pitou\u0027s full name?","answers":["Pitoue","Youpitou","Neferpitou","Pitorius"],"correctAnswer":2,"arc":5},{"question":"Who is Alluka?","answers":["Gon\u0027s sister","A Zodiac","The \u0027dark\u0027 side of Nanika","Killua\u0027s sister"],"correctAnswer":3,"arc":6},{"question":"Who won the election?","answers":["Gon","Pariston","Morel","Leorio"],"correctAnswer":1,"arc":6},{"question":"haha","answers":["never","immer"],"correctAnswer":1,"arc":6}]
|
[{"question":"question","answers":["a","b","c","d"],"correctAnswer":0,"arc":0}]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue