
de.malkusch.telgrambot.Update Maven / Gradle / Ivy
package de.malkusch.telgrambot;
import java.util.List;
public sealed interface Update {
record TextMessage(MessageId id, String message, boolean fromBot) implements Update {
}
record ReactionUpdate(MessageId id, List reactions, boolean fromBot) implements Update {
public boolean contains(Reaction reaction) {
return reactions.contains(reaction);
}
public static enum Reaction {
THUMBS_UP, IGNORED
}
}
record CallbackUpdate(MessageId id, CallbackId callbackId, Callback callback) implements Update {
public record CallbackId(String id) {
}
public record Callback(Command command, String data) {
public Callback(Command command) {
this(command, "null");
}
public static Callback parse(String callback) {
var parsed = callback.split(":", 2);
var command = new Command(parsed[0]);
var data = parsed[1];
return new Callback(command, data);
}
@Override
public String toString() {
return command.name() + ":" + data;
}
}
}
record UnknownUpdate() implements Update {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy