fix example source
This commit is contained in:
parent
45b69a7ca3
commit
b6ce2f97ca
2 changed files with 17 additions and 13 deletions
|
@ -40,7 +40,7 @@ class ExampleSource implements ChatSource {
|
|||
String response = rollResponse(chat)
|
||||
String[] parts = response.split(" ")
|
||||
|
||||
ChatMessage message = new ChatMessage(true);
|
||||
ChatMessage message = new ChatMessage(true)
|
||||
|
||||
CompletableFuture.supplyAsync {
|
||||
for (int i=0; i<parts.length; i++) {
|
||||
|
@ -70,7 +70,7 @@ class ExampleSource implements ChatSource {
|
|||
counter = 11
|
||||
}
|
||||
|
||||
def parseable = prompt.toLowerCase().strip().replaceAll("[^a-zA-Z0-9\\s]", "");
|
||||
def parseable = prompt.toLowerCase().strip().replaceAll("[^a-zA-Z0-9\\s]", "")
|
||||
switch (parseable) {
|
||||
case "who am i":
|
||||
case "whats my name":
|
||||
|
@ -99,7 +99,7 @@ class ExampleSource implements ChatSource {
|
|||
switch (counter) {
|
||||
case 0:
|
||||
def i = random.nextInt(messagesCount) + 1
|
||||
response = "I'll say your %s message backwards: %s".formatted(i.toString() + (i % 10 == 1 ? "st" : (i % 10 == 2 ? "nd" : (i % 10 == 3 ? "rd" : "th"))), chat.messages.get((i - 1) * 2).text().reverse())
|
||||
response = "I'll say your %s message backwards: %s".formatted(i.toString() + (i % 10 == 1 ? "st" : (i % 10 == 2 ? "nd" : (i % 10 == 3 ? "rd" : "th"))), chat.messages.get((i - 1) * 2).content().reverse())
|
||||
break
|
||||
case 1:
|
||||
response = "I'm sorry, but I can't assist with that."
|
||||
|
@ -142,7 +142,7 @@ class ExampleSource implements ChatSource {
|
|||
i = random.nextInt(messagesCount)
|
||||
i2 = random.nextInt(messagesCount)
|
||||
}
|
||||
response = "I'm still angry after you said \"%s\" to me. You could have apologized, but you chose to say \"%s\", so I can't assist you.".formatted(chat.messages.get(i * 2).text(), chat.messages.get(i2 * 2).text())
|
||||
response = "I'm still angry after you said \"%s\" to me. You could have apologized, but you chose to say \"%s\", so I can't assist you.".formatted(chat.messages.get(i * 2).content(), chat.messages.get(i2 * 2).content())
|
||||
}
|
||||
break
|
||||
case 13:
|
||||
|
|
|
@ -3,18 +3,22 @@ package eu.m724.chatapi.source.impl;
|
|||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* makes the consumer a blocking queue
|
||||
*
|
||||
* @deprecated not a development focus
|
||||
* @param <T> type of consumer (usually {@link eu.m724.chatapi.chat.ChatEvent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlockingQueueConsumer<T> {
|
||||
public final LinkedBlockingQueue<T> queue = new LinkedBlockingQueue<>();
|
||||
|
||||
public final Consumer<T> consumer = new Consumer<>() {
|
||||
@Override
|
||||
public void accept(T t) {
|
||||
public final Consumer<T> consumer = t -> {
|
||||
try {
|
||||
queue.put(t);
|
||||
} catch (InterruptedException e) {
|
||||
// again I don't know how that is relevant
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue