diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/Event.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/Event.java new file mode 100644 index 0000000..3acc3ad --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/Event.java @@ -0,0 +1,4 @@ +package org.codeoverflow.chatoverflow.api.io.dto.event; + +public interface Event { +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamDonation.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamDonation.java new file mode 100644 index 0000000..a69f2cb --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamDonation.java @@ -0,0 +1,51 @@ +package org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream; + +import java.time.ZonedDateTime; + +public class TipeeeStreamDonation implements TipeeeStreamEvent { + private final ZonedDateTime createdAt; + private final String donor; + private final String message; + private final Double amount; + private final String currency; + private final String formattedAmount; + + public TipeeeStreamDonation(ZonedDateTime createdAt, String donor, String message, Double amount, String currency, String formattedAmount) { + this.createdAt = createdAt; + this.donor = donor; + this.message = message; + this.amount = amount; + this.currency = currency; + this.formattedAmount = formattedAmount; + } + + @Override + public ZonedDateTime getCreatedAt() { + return createdAt; + } + + public String getDonor() { + return donor; + } + + public String getMessage() { + return message; + } + + @Override + public String getType() { + return "donation"; + } + + public Double getAmount() { + return amount; + } + + public String getCurrency() { + return currency; + } + + public String getFormattedAmount() { + return formattedAmount; + } +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamEvent.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamEvent.java new file mode 100644 index 0000000..7b8c1ec --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamEvent.java @@ -0,0 +1,11 @@ +package org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream; + +import org.codeoverflow.chatoverflow.api.io.dto.event.Event; + +import java.time.ZonedDateTime; + +public interface TipeeeStreamEvent extends Event { + ZonedDateTime getCreatedAt(); + String getMessage(); + String getType(); +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamFollow.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamFollow.java new file mode 100644 index 0000000..aada779 --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamFollow.java @@ -0,0 +1,34 @@ +package org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream; + +import java.time.ZonedDateTime; + +public class TipeeeStreamFollow implements TipeeeStreamEvent { + private final ZonedDateTime createdAt; + private final String follower; + private final String message; + + public TipeeeStreamFollow(ZonedDateTime createdAt, String follower, String message) { + this.createdAt = createdAt; + this.follower = follower; + this.message = message; + } + + @Override + public ZonedDateTime getCreatedAt() { + return createdAt; + } + + public String getFollower() { + return follower; + } + + @Override + public String getMessage() { + return message; + } + + @Override + public String getType() { + return "follow"; + } +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamSubscription.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamSubscription.java new file mode 100644 index 0000000..274c932 --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamSubscription.java @@ -0,0 +1,39 @@ +package org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream; + +import java.time.ZonedDateTime; + +public class TipeeeStreamSubscription implements TipeeeStreamEvent { + private final ZonedDateTime createdAt; + private final String subscriber; + private final String message; + private final Integer resub; + + public TipeeeStreamSubscription(ZonedDateTime createdAt, String subscriber, String message, Integer resub) { + this.createdAt = createdAt; + this.subscriber = subscriber; + this.message = message; + this.resub = resub; + } + + @Override + public ZonedDateTime getCreatedAt() { + return createdAt; + } + + public String getSubscriber() { + return subscriber; + } + + public String getMessage() { + return message; + } + + @Override + public String getType() { + return "subscription"; + } + + public Integer getResub() { + return resub; + } +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/input/chat/TipeeeStreamInput.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/chat/TipeeeStreamInput.java new file mode 100644 index 0000000..b5df5d7 --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/chat/TipeeeStreamInput.java @@ -0,0 +1,14 @@ +package org.codeoverflow.chatoverflow.api.io.input.chat; + +import org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream.TipeeeStreamDonation; +import org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream.TipeeeStreamFollow; +import org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream.TipeeeStreamSubscription; +import org.codeoverflow.chatoverflow.api.io.input.Input; + +import java.util.function.Consumer; + +public interface TipeeeStreamInput extends Input { + void registerSubscriptionHandler(Consumer handler); + void registerDonationHandler(Consumer handler); + void registerFollowHandler(Consumer handler); +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/DonationEventInput.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/DonationEventInput.java new file mode 100644 index 0000000..ff0a3aa --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/DonationEventInput.java @@ -0,0 +1,11 @@ +package org.codeoverflow.chatoverflow.api.io.input.event; + +import org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream.TipeeeStreamDonation; + +import java.util.function.Consumer; + +//fixme extend generic donation +public interface DonationEventInput extends EventInput { + + void registerDonationHandler(Consumer handler); +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/FollowEventInput.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/FollowEventInput.java new file mode 100644 index 0000000..467ca33 --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/FollowEventInput.java @@ -0,0 +1,10 @@ +package org.codeoverflow.chatoverflow.api.io.input.event; + +import org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream.TipeeeStreamFollow; + +import java.util.function.Consumer; + +public interface FollowEventInput extends EventInput { + + void registerFollowHandler(Consumer handler); +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/SubscriptionEventInput.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/SubscriptionEventInput.java index d959515..2b8e3bd 100644 --- a/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/SubscriptionEventInput.java +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/SubscriptionEventInput.java @@ -1,5 +1,15 @@ package org.codeoverflow.chatoverflow.api.io.input.event; -//TODO implement -public interface SubscriptionEventInput extends EventInput { +import org.codeoverflow.chatoverflow.api.io.dto.event.tipeeestream.TipeeeStreamSubscription; + +import java.util.function.Consumer; + +//Fixme extend generic subscription +public interface SubscriptionEventInput extends EventInput { + /** + * Let's you register a simple handler immediately react on new subscriptions + * + * @param handler the consumer t ehandle incoming messages + */ + void registerSubscriptionHandler(Consumer handler); } diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/TwitchSubscriptionEventInput.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/TwitchSubscriptionEventInput.java index 4863479..ff1eb13 100644 --- a/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/TwitchSubscriptionEventInput.java +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/TwitchSubscriptionEventInput.java @@ -1,5 +1,5 @@ package org.codeoverflow.chatoverflow.api.io.input.event; -//TODO implement -public interface TwitchSubscriptionEventInput extends SubscriptionEventInput { +//TODO extend from SubscriptionEventInput +public interface TwitchSubscriptionEventInput extends EventInput { } diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Input.java b/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Input.java index 60af355..41a3b15 100644 --- a/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Input.java +++ b/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Input.java @@ -4,6 +4,7 @@ import org.codeoverflow.chatoverflow.api.io.input.SerialInput; import org.codeoverflow.chatoverflow.api.io.input.chat.DiscordChatInput; import org.codeoverflow.chatoverflow.api.io.input.chat.MockUpChatInput; +import org.codeoverflow.chatoverflow.api.io.input.chat.TipeeeStreamInput; import org.codeoverflow.chatoverflow.api.io.input.chat.TwitchChatInput; import org.codeoverflow.chatoverflow.api.io.input.stat.TwitchStatInput; @@ -90,6 +91,18 @@ public Requirement serial(String uniqueRequirementId, String displa return requirements.requireInput(uniqueRequirementId, displayName, isOptional, SerialInput.class); } + /** + * Requires a login for the TipeeeStream api that has to be created by the framework user. + * + * @param uniqueRequirementId any unique id by which your plugin can identify the requirement + * @param displayName Is displayed to the framework user and to tell him what to enter + * @param isOptional true if this requirement is optional, false if mandatory + * @return the requirement object + */ + public Requirement tipeeeStream(String uniqueRequirementId, String displayName, boolean isOptional) { + return requirements.requireInput(uniqueRequirementId, displayName, isOptional, TipeeeStreamInput.class); + } + // Add more inputs here }