Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

TipeeeStream implementation #6

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.codeoverflow.chatoverflow.api.io.dto.event;

public interface Event {
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<TipeeeStreamSubscription> handler);
void registerDonationHandler(Consumer<TipeeeStreamDonation> handler);
void registerFollowHandler(Consumer<TipeeeStreamFollow> handler);
}
Original file line number Diff line number Diff line change
@@ -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<T extends TipeeeStreamDonation> extends EventInput {

void registerDonationHandler(Consumer<T> handler);
}
Original file line number Diff line number Diff line change
@@ -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<T extends TipeeeStreamFollow> extends EventInput {

void registerFollowHandler(Consumer<T> handler);
}
Original file line number Diff line number Diff line change
@@ -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<T extends TipeeeStreamSubscription> 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<T> handler);
}
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -90,6 +91,18 @@ public Requirement<SerialInput> 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<TipeeeStreamInput> tipeeeStream(String uniqueRequirementId, String displayName, boolean isOptional) {
return requirements.requireInput(uniqueRequirementId, displayName, isOptional, TipeeeStreamInput.class);
}

// Add more inputs here

}