Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eventsub): add whisper received topic #970

Merged
merged 1 commit into from Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,16 @@
package com.github.twitch4j.eventsub.domain;

import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;

@Data
@Setter(AccessLevel.PRIVATE)
public class Whisper {

/**
* The body of the whisper message.
*/
private String text;

}
@@ -0,0 +1,47 @@
package com.github.twitch4j.eventsub.events;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Data
@Setter(AccessLevel.PRIVATE)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class EventSubUserFromToEvent extends EventSubEvent {

/**
* The user ID that triggered the event.
*/
private String fromUserId;

/**
* The user login name that triggered the event.
*/
private String fromUserLogin;

/**
* The user display name that triggered the event.
*/
private String fromUserName;

/**
* The user ID that received the event.
*/
private String toUserId;

/**
* The user login name that received the event.
*/
private String toUserLogin;

/**
* The user display name that received the event.
*/
private String toUserName;

}
@@ -0,0 +1,26 @@
package com.github.twitch4j.eventsub.events;

import com.github.twitch4j.eventsub.domain.Whisper;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Setter;
import lombok.ToString;

@Data
@Setter(AccessLevel.PRIVATE)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WhisperReceivedEvent extends EventSubUserFromToEvent {

/**
* The whisper ID.
*/
private String whisperId;

/**
* Object containing whisper information.
*/
private Whisper whisper;

}
Expand Up @@ -74,6 +74,7 @@ public class SubscriptionTypes {
public final UserAuthorizationGrantType USER_AUTHORIZATION_GRANT;
public final UserAuthorizationRevokeType USER_AUTHORIZATION_REVOKE;
public final UserUpdateType USER_UPDATE;
public final WhisperReceivedType WHISPER_RECEIVE;

public SubscriptionType<?, ?, ?> getSubscriptionType(String subTypeName, String subTypeVersion) {
return SUBSCRIPTION_TYPES.get(subTypeName + ':' + subTypeVersion);
Expand Down Expand Up @@ -141,7 +142,8 @@ public class SubscriptionTypes {
UNBAN_REQUEST_RESOLVE = new UnbanRequestResolveType(),
USER_AUTHORIZATION_GRANT = new UserAuthorizationGrantType(),
USER_AUTHORIZATION_REVOKE = new UserAuthorizationRevokeType(),
USER_UPDATE = new UserUpdateType()
USER_UPDATE = new UserUpdateType(),
WHISPER_RECEIVE = new WhisperReceivedType()
).collect(Collectors.toMap(type -> type.getName() + ':' + type.getVersion(), Function.identity()))
);
}
Expand Down
@@ -0,0 +1,34 @@
package com.github.twitch4j.eventsub.subscriptions;

import com.github.twitch4j.eventsub.condition.UserEventSubCondition;
import com.github.twitch4j.eventsub.events.WhisperReceivedEvent;

/**
* Fires when anyone whispers the specified user.
* <p>
* Must have oauth scope user:read:whispers or user:manage:whispers.
*
* @see com.github.twitch4j.auth.domain.TwitchScopes#HELIX_USER_WHISPERS_READ
* @see com.github.twitch4j.auth.domain.TwitchScopes#HELIX_USER_WHISPERS_MANAGE
*/
public class WhisperReceivedType implements SubscriptionType<UserEventSubCondition, UserEventSubCondition.UserEventSubConditionBuilder<?, ?>, WhisperReceivedEvent> {
@Override
public String getName() {
return "user.whisper.message";
}

@Override
public String getVersion() {
return "1";
}

@Override
public UserEventSubCondition.UserEventSubConditionBuilder<?, ?> getConditionBuilder() {
return UserEventSubCondition.builder();
}

@Override
public Class<WhisperReceivedEvent> getEventClass() {
return WhisperReceivedEvent.class;
}
}