Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support new mod announcement command (#556)
* feat: create and fire ModAnnouncementEvent * feat: add ITwitchChat#sendAnnouncement
- Loading branch information
Showing
4 changed files
with
120 additions
and
0 deletions.
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; | ||
} | ||
|
||
} |