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

Commit 94111c8

Browse files
committed
Add cheers to the api and to tipeeestream
1 parent e8ad9bb commit 94111c8

File tree

5 files changed

+117
-4
lines changed

5 files changed

+117
-4
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
5+
import java.time.OffsetDateTime;
6+
7+
/**
8+
* A user has cheered some bits to your stream
9+
*/
10+
public class Cheer<T extends User> {
11+
private final T cheerer;
12+
private final int amount;
13+
private final String cheerMessage;
14+
private final OffsetDateTime time;
15+
16+
public Cheer(T cheerer, int amount, String cheerMessage, OffsetDateTime time) {
17+
this.cheerer = cheerer;
18+
this.amount = amount;
19+
this.cheerMessage = cheerMessage;
20+
this.time = time;
21+
}
22+
23+
/**
24+
* Get the user object of the person that has cheered
25+
*
26+
* @return the cheerer
27+
*/
28+
public T getCheerer() {
29+
return cheerer;
30+
}
31+
32+
/**
33+
* Get how much the user cheered in twitch bits
34+
*
35+
* @return amount of cheered bits e.g. 100
36+
*/
37+
public int getAmount() {
38+
return amount;
39+
}
40+
41+
/**
42+
* Get the message with which the user has cheered
43+
*
44+
* @return the cheer message
45+
*/
46+
public String getMessage() {
47+
return cheerMessage;
48+
}
49+
50+
/**
51+
* Get the time when the cheer was made
52+
*
53+
* @return cheer time
54+
*/
55+
public OffsetDateTime getTime() {
56+
return time;
57+
}
58+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.Cheer;
5+
6+
import java.time.OffsetDateTime;
7+
8+
public class TipeeestreamCheer extends Cheer<User> {
9+
public TipeeestreamCheer(User cheerer, int amount, String cheerMessage, OffsetDateTime time) {
10+
super(cheerer, amount, cheerMessage, time);
11+
}
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.codeoverflow.chatoverflow.api.io.event.stream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.Cheer;
4+
5+
/**
6+
* Generic event for cheers
7+
*/
8+
public abstract class CheerEvent<T extends Cheer> {
9+
10+
private final T info;
11+
12+
protected CheerEvent(T cheerInfo) {
13+
this.info = cheerInfo;
14+
}
15+
16+
/**
17+
* Get the Cheer object that contains all information about that cheer
18+
*
19+
* @return all info about that cheer
20+
*/
21+
public T getInfo() {
22+
return info;
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream.TipeeestreamCheer;
4+
import org.codeoverflow.chatoverflow.api.io.event.stream.CheerEvent;
5+
6+
/**
7+
* Event that is triggered by tipeeestream if a user cheers on the stream.
8+
*/
9+
public class TipeeestreamCheerEvent extends CheerEvent<TipeeestreamCheer> implements TipeeestreamEvent {
10+
public TipeeestreamCheerEvent(TipeeestreamCheer donationInfo) {
11+
super(donationInfo);
12+
}
13+
}

src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/TipeeestreamEventInput.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package org.codeoverflow.chatoverflow.api.io.input.event;
22

33
import org.codeoverflow.chatoverflow.api.IsRequirement;
4-
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.TipeeestreamDonationEvent;
5-
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.TipeeestreamEvent;
6-
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.TipeeestreamFollowEvent;
7-
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.TipeeestreamSubscriptionEvent;
4+
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.*;
85

96
import java.util.function.Consumer;
107

@@ -37,4 +34,13 @@ default void registerFollowEventHandler(Consumer<TipeeestreamFollowEvent> eventH
3734
default void registerDonationEventHandler(Consumer<TipeeestreamDonationEvent> eventHandler) {
3835
registerEventHandler(eventHandler, TipeeestreamDonationEvent.class);
3936
}
37+
38+
/**
39+
* Register an event handler that listens to all {@link TipeeestreamCheerEvent}
40+
*
41+
* @param eventHandler consumer that receives the Events
42+
*/
43+
default void registerCheerEventHandler(Consumer<TipeeestreamCheerEvent> eventHandler) {
44+
registerEventHandler(eventHandler, TipeeestreamCheerEvent.class);
45+
}
4046
}

0 commit comments

Comments
 (0)