This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
forked from twitch4j/twitch4j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbstractChannelMessageEvent.java
79 lines (66 loc) · 2.19 KB
/
AbstractChannelMessageEvent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.github.twitch4j.chat.events;
import com.github.twitch4j.chat.events.channel.IRCMessageEvent;
import com.github.twitch4j.chat.events.channel.ReplyableEvent;
import com.github.twitch4j.chat.flag.AutoModFlag;
import com.github.twitch4j.common.annotation.Unofficial;
import com.github.twitch4j.common.enums.CommandPermission;
import com.github.twitch4j.common.events.domain.EventChannel;
import com.github.twitch4j.common.events.domain.EventUser;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Set;
@Data
@Setter(AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false)
public abstract class AbstractChannelMessageEvent extends AbstractChannelEvent implements ReplyableEvent {
/**
* RAW Message Event
*/
private IRCMessageEvent messageEvent;
/**
* User
*/
private EventUser user;
/**
* Message
*/
private String message;
/**
* Permissions of the user
*/
private Set<CommandPermission> permissions;
/**
* The exact number of months the user has been a subscriber, or zero if not subscribed
*/
private int subscriberMonths;
/**
* The tier at which the user is subscribed (prime is treated as 1), or zero if not subscribed
*/
private int subscriptionTier;
/**
* Nonce
*/
@Unofficial
@Getter(lazy = true)
private final String nonce = getMessageEvent().getNonce().orElse(null);
public AbstractChannelMessageEvent(EventChannel channel, IRCMessageEvent messageEvent, EventUser user, String message, Set<CommandPermission> permissions) {
super(channel);
this.messageEvent = messageEvent;
this.user = user;
this.message = message;
this.permissions = permissions;
this.subscriberMonths = messageEvent.getSubscriberMonths().orElse(0);
this.subscriptionTier = messageEvent.getSubscriptionTier().orElse(0);
}
/**
* @return the regions of the message that were flagged by AutoMod.
*/
@Unofficial
public List<AutoModFlag> getFlags() {
return this.getMessageEvent().getFlags();
}
}