diff --git a/src/main/java/dev/marcospaulo/canalhandia/Ai.java b/src/main/java/dev/marcospaulo/canalhandia/Ai.java index 5fdad58..89d8f1e 100644 --- a/src/main/java/dev/marcospaulo/canalhandia/Ai.java +++ b/src/main/java/dev/marcospaulo/canalhandia/Ai.java @@ -62,6 +62,13 @@ final class Ai { record Answered(UUID asker, String question, String answer) { } + /** + * How many answers players have flagged wrong with {@code /ia feedback ruim}. + * Shown in {@code /canalhandia status}. Simple in-memory counter — a restart + * resets it, like {@link #askedToday}. + */ + private int feedbackWrong; + /** Package-private so Task 11's {@code /ia corrigir} can read what to correct. */ Answered lastAnswer() { return lastAnswer; @@ -77,6 +84,21 @@ final class Ai { return corrections; } + /** A player marked the last answer wrong with {@code /ia feedback ruim}. */ + boolean flagLastAnswerWrong() { + if (lastAnswer == null) { + return false; + } + feedbackWrong++; + plugin.getLogger().info("IA: resposta marcada como errada — pergunta: " + lastAnswer.question()); + return true; + } + + /** How many answers players have flagged wrong. Shown in /canalhandia status. */ + int feedbackWrong() { + return feedbackWrong; + } + Ai(Canalhandia plugin) { this.plugin = plugin; Settings settings = plugin.settings(); diff --git a/src/main/java/dev/marcospaulo/canalhandia/Canalhandia.java b/src/main/java/dev/marcospaulo/canalhandia/Canalhandia.java index a802a98..a0bfa4e 100644 --- a/src/main/java/dev/marcospaulo/canalhandia/Canalhandia.java +++ b/src/main/java/dev/marcospaulo/canalhandia/Canalhandia.java @@ -71,7 +71,8 @@ public final class Canalhandia extends JavaPlugin implements Listener { CanalhandiaCommand root = new CanalhandiaCommand(this); for (String name : List.of("canalhandia", "curiosidade", "adivinha", "enquete", "ranking", - "reagir", "reacoes", "palpite", "votar", "legal", "wow", "top", "f", "ia")) { + "reagir", "reacoes", "palpite", "votar", "legal", "wow", "top", "f", "ia", "iap", + "errado")) { register(name, root); } @@ -305,16 +306,35 @@ public final class Canalhandia extends JavaPlugin implements Listener { } /** - * Opens the reaction row on a public AI answer. Minimal for now: reuses - * the shared {@link #openReactions()} machinery. Task 11 wires the - * asker-gated feedback path and the typed {@code /reagir} twin. + * Opens the reaction row on a public AI answer: 👍 (reuses the shared + * {@code joia}/{@code /legal} reaction so the typed Bedrock twin resolves + * via {@link Settings#reactionForCommand}) and ❌ ({@code /errado}, new). + * + *
The {@code askerId} param is kept in the signature because
+ * {@link Ai#deliver} passes it, but is not used structurally here.
*/
void openAiReactions(UUID askerId) {
- // TODO Task 11: asker-gated feedback and the typed /reagir twin use askerId.
if (!settings.reactionsEnabled()) {
return;
}
- openReactions();
+ Reactions reactions = new Reactions(nextId++, List.of(
+ new ReactionDef("joia", "[👍]", "[+1]", "legal"),
+ new ReactionDef("errado", "[❌]", "[ERRADO]", "errado")));
+ liveReactions = reactions;
+ remember(reactions);
+ reactions.show();
+ getServer().getScheduler().runTaskLater(this, () -> {
+ reactions.hide();
+ if (liveReactions == reactions) {
+ liveReactions = null;
+ }
+ if (reactions.hasAnyVote()) {
+ broadcastPerPlatform(bedrock -> Component.text(" ")
+ .append(reactions.summary(bedrock, settings.summaryNames())));
+ }
+ }, settings.reactionWindowSeconds() * 20L);
+ broadcastPerPlatform(bedrock -> Component.text(" ")
+ .append(reactions.buttons(bedrock)));
}
/**
diff --git a/src/main/java/dev/marcospaulo/canalhandia/CanalhandiaCommand.java b/src/main/java/dev/marcospaulo/canalhandia/CanalhandiaCommand.java
index dbe5b85..c43ddff 100644
--- a/src/main/java/dev/marcospaulo/canalhandia/CanalhandiaCommand.java
+++ b/src/main/java/dev/marcospaulo/canalhandia/CanalhandiaCommand.java
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
/**
@@ -46,7 +47,8 @@ final class CanalhandiaCommand implements CommandExecutor, TabCompleter {
case "palpite" -> guessLatest(sender, args);
case "votar" -> voteLatest(sender, args);
case "reacoes" -> whoReacted(sender);
- case "ia" -> ia(sender, args);
+ case "ia" -> ia(sender, args, false);
+ case "iap" -> ia(sender, args, true);
default -> {
String reaction = plugin.settings().reactionForCommand(command.getName());
if (reaction != null) {
@@ -656,10 +658,12 @@ final class CanalhandiaCommand implements CommandExecutor, TabCompleter {
}
Msg.line(sender, "categorias ativas", enabled.isEmpty() ? "nenhuma" : String.join(", ", enabled));
Msg.line(sender, "ia", plugin.ai().configured()
- ? settings.aiModel() + " · " + plugin.ai().askedToday() + "/"
- + settings.aiDailyLimit() + " hoje · cooldown "
- + settings.aiCooldownSeconds() + "s · "
+ ? settings.aiModel() + " · perfil " + settings.aiProfile().name().toLowerCase(Locale.ROOT)
+ + " · " + plugin.ai().askedToday() + "/" + settings.aiDailyLimit() + " hoje"
+ + " · cooldown " + settings.aiCooldownSeconds() + "s · "
+ (settings.aiPublic() ? "resposta pública" : "resposta privada")
+ + " · " + plugin.ai().corrections().all().size() + " correções"
+ + " · " + plugin.ai().feedbackWrong() + " feedback ruim"
: "sem chave configurada");
}
@@ -754,7 +758,7 @@ final class CanalhandiaCommand implements CommandExecutor, TabCompleter {
* has it out of the box and LuckPerms can hand it to anyone else with
* {@code lp user