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

Commit 3d2a513

Browse files
committed
Merge branch 'feature/131-cheer,host,raid-events' into feature/129-streamelements-connector
2 parents 35d8dbe + 917401c commit 3d2a513

16 files changed

+430
-11
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: 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+
* Another streamer has started hosting your stream on their channel.
9+
*/
10+
public class Host<T extends User> {
11+
private final T streamer;
12+
private final String message;
13+
private final int viewerCount;
14+
private final OffsetDateTime time;
15+
16+
public Host(T streamer, String message, int viewerCount, OffsetDateTime time) {
17+
this.streamer = streamer;
18+
this.message = message;
19+
this.viewerCount = viewerCount;
20+
this.time = time;
21+
}
22+
23+
/**
24+
* Get the streamer which started hosting you.
25+
*
26+
* @return streamer that hosts you
27+
*/
28+
public T getStreamer() {
29+
return streamer;
30+
}
31+
32+
/**
33+
* Get the message from the streamer that has started hosting you.
34+
*
35+
* @return the host message
36+
*/
37+
public String getMessage() {
38+
return message;
39+
}
40+
41+
/**
42+
* Get the viewer count with which the streamer is hosting you.
43+
*
44+
* @return the viewer count of the host
45+
*/
46+
public int getViewerCount() {
47+
return viewerCount;
48+
}
49+
50+
/**
51+
* Get the time when the streamer has started hosting you.
52+
*
53+
* @return host time
54+
*/
55+
public OffsetDateTime getTime() {
56+
return time;
57+
}
58+
}
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+
* Another streamer has started a raid against your stream.
9+
*/
10+
public class Raid<T extends User> {
11+
private final T streamer;
12+
private final String message;
13+
private final int viewerCount;
14+
private final OffsetDateTime time;
15+
16+
public Raid(T streamer, String message, int viewerCount, OffsetDateTime time) {
17+
this.streamer = streamer;
18+
this.message = message;
19+
this.viewerCount = viewerCount;
20+
this.time = time;
21+
}
22+
23+
/**
24+
* Get the streamer which started the raid.
25+
*
26+
* @return initiating streamer
27+
*/
28+
public T getStreamer() {
29+
return streamer;
30+
}
31+
32+
/**
33+
* Get the message from the initiating streamer.
34+
*
35+
* @return the raid message
36+
*/
37+
public String getMessage() {
38+
return message;
39+
}
40+
41+
/**
42+
* Get the viewer count with which the streamer raids you.
43+
*
44+
* @return the viewer count of the raid
45+
*/
46+
public int getViewerCount() {
47+
return viewerCount;
48+
}
49+
50+
/**
51+
* Get the time when the raid has started
52+
*
53+
* @return raid time
54+
*/
55+
public OffsetDateTime getTime() {
56+
return time;
57+
}
58+
}

src/main/java/org/codeoverflow/chatoverflow/api/io/dto/stat/stream/Subscription.java

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ public class Subscription<T extends User> {
88
private final T subscriber;
99
private final OffsetDateTime time;
1010
private final int resub;
11+
private final SubscriptionTier tier;
12+
private final boolean gifted;
13+
private final T donor;
1114

12-
public Subscription(T subscriber, int resub, OffsetDateTime time) {
15+
public Subscription(T subscriber, OffsetDateTime time, int resub, SubscriptionTier tier, boolean gifted, T donor) {
1316
this.subscriber = subscriber;
1417
this.time = time;
1518
this.resub = resub;
19+
this.tier = tier;
20+
this.gifted = gifted;
21+
this.donor = donor;
1622
}
1723

1824
/**
@@ -24,6 +30,15 @@ public T getSubscriber() {
2430
return subscriber;
2531
}
2632

33+
/**
34+
* Get the time when the user has subscribed
35+
*
36+
* @return subscription time
37+
*/
38+
public OffsetDateTime getTime() {
39+
return time;
40+
}
41+
2742
/**
2843
* Returns how often that user has subscribed
2944
*
@@ -34,11 +49,29 @@ public int getResub() {
3449
}
3550

3651
/**
37-
* Get the time when the user started following
52+
* Returns the tier of the subscription {@link SubscriptionTier}.
3853
*
39-
* @return follow start time
54+
* @return the subscription tier
4055
*/
41-
public OffsetDateTime getTime() {
42-
return time;
56+
public SubscriptionTier getTier() {
57+
return tier;
58+
}
59+
60+
/**
61+
* Returns if the subscription was gifted by someone else or not
62+
*
63+
* @return it the subscription was gifted
64+
*/
65+
public boolean isGifted() {
66+
return gifted;
67+
}
68+
69+
/**
70+
* Returns the donor of the subscription if it was gifted.
71+
*
72+
* @return the donor of the subscription
73+
*/
74+
public T getDonor() {
75+
return donor;
4376
}
4477
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream;
2+
3+
import java.util.Arrays;
4+
5+
/**
6+
* Represents the tier of a {@link Subscription}.
7+
*/
8+
public enum SubscriptionTier {
9+
PRIME, // Free for the user, same as a tier 1 for the streamer.
10+
TIER1, // 4.99
11+
TIER2, // 9.99
12+
TIER3, // 24.99
13+
UNKNOWN;
14+
15+
/**
16+
* Converts the tier to a string, e.g. {@link #TIER1} is "tier 1", {@link #PRIME} is "prime" and
17+
* {@link #UNKNOWN} is "unknown".
18+
*
19+
* @return the tier formatted as a string.
20+
*/
21+
@Override
22+
public String toString() {
23+
switch (this) {
24+
case PRIME: return "prime";
25+
case TIER1: return "tier 1";
26+
case TIER2: return "tier 2";
27+
case TIER3: return "tier 3";
28+
default: return "unknown";
29+
}
30+
}
31+
32+
/**
33+
* Parse the tier from a string
34+
*
35+
* @param tier the tier of the subscription. 0 is prime, 1 is tier 1 and so on.
36+
* @return the subscription-tier represented by the passed number or {@link #UNKNOWN}.
37+
*/
38+
public static SubscriptionTier parse(int tier) {
39+
return Arrays.stream(values())
40+
.filter(e -> e.ordinal() == tier)
41+
.findAny().orElse(UNKNOWN);
42+
}
43+
}
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: 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.Host;
5+
6+
import java.time.OffsetDateTime;
7+
8+
public class TipeeestreamHost extends Host<User> {
9+
public TipeeestreamHost(User streamer, String message, int viewerCount, OffsetDateTime time) {
10+
super(streamer, message, viewerCount, time);
11+
}
12+
}
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.Raid;
5+
6+
import java.time.OffsetDateTime;
7+
8+
public class TipeeestreamRaid extends Raid<User> {
9+
public TipeeestreamRaid(User streamer, String message, int viewerCount, OffsetDateTime time) {
10+
super(streamer, message, viewerCount, time);
11+
}
12+
}

src/main/java/org/codeoverflow/chatoverflow/api/io/dto/stat/stream/tipeeestream/TipeeestreamSubscription.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
import org.codeoverflow.chatoverflow.api.io.dto.User;
44
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.Subscription;
5+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.SubscriptionTier;
56

67
import java.time.OffsetDateTime;
78

89
public class TipeeestreamSubscription extends Subscription<User> {
910

1011
private final TipeeestreamProvider provider;
1112

12-
public TipeeestreamSubscription(User subscriber, int resub, OffsetDateTime time, TipeeestreamProvider provider) {
13-
super(subscriber, resub, time);
13+
public TipeeestreamSubscription(User subscriber, OffsetDateTime time, int resub, SubscriptionTier tier, boolean gifted, User donor, TipeeestreamProvider provider) {
14+
super(subscriber, time, resub, tier, gifted, donor);
1415
this.provider = provider;
1516
}
1617

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+
}
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.Host;
4+
5+
/**
6+
* Generic event for hosts
7+
*/
8+
public abstract class HostEvent<T extends Host> {
9+
10+
private final T info;
11+
12+
protected HostEvent(T cheerInfo) {
13+
this.info = cheerInfo;
14+
}
15+
16+
/**
17+
* Get the Host object that contains all information about that host
18+
*
19+
* @return all info about that host
20+
*/
21+
public T getInfo() {
22+
return info;
23+
}
24+
}

0 commit comments

Comments
 (0)