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: support new mod announcement command #556
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
chat/src/main/java/com/github/twitch4j/chat/enums/AnnouncementColor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.github.twitch4j.chat.enums; | ||
|
||
import com.fasterxml.jackson.annotation.JsonEnumDefaultValue; | ||
import com.github.twitch4j.common.annotation.Unofficial; | ||
|
||
@Unofficial | ||
public enum AnnouncementColor { | ||
|
||
@JsonEnumDefaultValue | ||
PRIMARY, | ||
BLUE, | ||
GREEN, | ||
ORANGE, | ||
PURPLE; | ||
|
||
private static final AnnouncementColor[] COLORS = values(); | ||
|
||
@Unofficial | ||
public static AnnouncementColor parseColor(String colorStr) { | ||
for (AnnouncementColor color : COLORS) { | ||
if (color.toString().equalsIgnoreCase(colorStr)) | ||
return color; | ||
} | ||
return PRIMARY; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
chat/src/main/java/com/github/twitch4j/chat/events/channel/ModAnnouncementEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.github.twitch4j.chat.events.channel; | ||
|
||
import com.github.twitch4j.chat.enums.AnnouncementColor; | ||
import com.github.twitch4j.chat.events.AbstractChannelEvent; | ||
import com.github.twitch4j.common.annotation.Unofficial; | ||
import com.github.twitch4j.common.events.domain.EventChannel; | ||
import com.github.twitch4j.common.events.domain.EventUser; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
import lombok.Value; | ||
|
||
/** | ||
* Fired when the broadcaster or a moderator publishes an accented message via {@code /announce}. | ||
* <p> | ||
* Since this event is not officially documented in the IRC guide, it could change or stop working at any time. | ||
* | ||
* @see <a href="https://twitter.com/TwitchSupport/status/1509634525982302208">Official Announcement</a> | ||
*/ | ||
@Value | ||
@ToString(callSuper = true) | ||
@EqualsAndHashCode(callSuper = true) | ||
@Unofficial | ||
public class ModAnnouncementEvent extends AbstractChannelEvent { | ||
|
||
/** | ||
* The raw message event. | ||
*/ | ||
@ToString.Exclude | ||
IRCMessageEvent messageEvent; | ||
|
||
/** | ||
* The user that made the announcement. | ||
*/ | ||
EventUser announcer; | ||
|
||
/** | ||
* The message being announced. | ||
*/ | ||
String message; | ||
|
||
/** | ||
* The color accent for the announcement. | ||
*/ | ||
AnnouncementColor color; | ||
|
||
/** | ||
* Event Constructor | ||
* | ||
* @param messageEvent The raw message event. | ||
* @param channel The channel that this event originates from. | ||
* @param announcer The user that made the announcement. | ||
* @param message The message being announced. | ||
* @param color The color accent for the announcement. | ||
*/ | ||
public ModAnnouncementEvent(IRCMessageEvent messageEvent, EventChannel channel, EventUser announcer, String message, AnnouncementColor color) { | ||
super(channel); | ||
this.messageEvent = messageEvent; | ||
this.announcer = announcer; | ||
this.message = message; | ||
this.color = color; | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Robust to twitchdev/issues#591