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

chore: deprecate irc commands due to twitch announcement #645

Merged
merged 2 commits into from Sep 13, 2022
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
22 changes: 22 additions & 0 deletions chat/src/main/java/com/github/twitch4j/chat/ITwitchChat.java
Expand Up @@ -124,7 +124,9 @@ default boolean sendActionMessage(String channel, String message) {
* @param channel The target channel name.
* @param seconds The slow mode seconds.
* @return whether the command was added to the queue
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#updateChatSettings
*/
@Deprecated
default boolean setSlowMode(String channel, int seconds) {
if (seconds <= 0)
return this.sendMessage(channel, "/slowoff");
Expand All @@ -142,7 +144,9 @@ default boolean setSlowMode(String channel, int seconds) {
* @param channel The target channel name.
* @param time The amount of time users must be followed.
* @return whether the command was added to the queue
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#updateChatSettings
*/
@Deprecated
default boolean setFollowersOnly(String channel, Duration time) {
if (time == null || time.isNegative())
return this.sendMessage(channel, "/followersoff");
Expand All @@ -156,7 +160,9 @@ default boolean setFollowersOnly(String channel, Duration time) {
* @param channel The target channel name.
* @param enable Whether the setting should be enabled or disabled.
* @return whether the command was added to the queue
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#updateChatSettings
*/
@Deprecated
default boolean setSubscribersOnly(String channel, boolean enable) {
return this.sendMessage(channel, enable ? "/subscribers" : "/subscribersoff");
}
Expand All @@ -167,7 +173,9 @@ default boolean setSubscribersOnly(String channel, boolean enable) {
* @param channel The target channel name.
* @param enable Whether the setting should be enabled or disabled.
* @return whether the command was added to the queue
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#updateChatSettings
*/
@Deprecated
default boolean setUniqueChat(String channel, boolean enable) {
return this.sendMessage(channel, enable ? "/uniquechat" : "/uniquechatoff");
}
Expand All @@ -178,7 +186,9 @@ default boolean setUniqueChat(String channel, boolean enable) {
* @param channel The target channel name.
* @param enable Whether the setting should be enabled or disabled.
* @return whether the command was added to the queue
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#updateChatSettings
*/
@Deprecated
default boolean setEmoteOnly(String channel, boolean enable) {
return this.sendMessage(channel, enable ? "/emoteonly" : "/emoteonlyoff");
}
Expand All @@ -188,7 +198,9 @@ default boolean setEmoteOnly(String channel, boolean enable) {
*
* @param channel The target channel name.
* @return whether the command was added to the queue
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#deleteChatMessages
*/
@Deprecated
default boolean clearChat(String channel) {
return this.sendMessage(channel, "/clear");
}
Expand All @@ -200,7 +212,9 @@ default boolean clearChat(String channel) {
* @param targetMsgId the unique id of the message to be deleted.
* @return whether the command was added to the queue
* @see IRCMessageEvent#getMessageId()
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#deleteChatMessages
*/
@Deprecated
default boolean delete(String channel, String targetMsgId) {
return this.sendMessage(channel, String.format("/delete %s", targetMsgId));
}
Expand All @@ -213,7 +227,9 @@ default boolean delete(String channel, String targetMsgId) {
* @param duration duration
* @param reason reason
* @return whether the command was added to the queue
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#banUser
*/
@Deprecated
default boolean timeout(String channel, String user, Duration duration, String reason) {
StringBuilder sb = new StringBuilder(user).append(' ').append(duration.getSeconds());
if (reason != null) {
Expand All @@ -230,7 +246,9 @@ default boolean timeout(String channel, String user, Duration duration, String r
* @param user username
* @param reason reason
* @return whether the command was added to the queue
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#banUser
*/
@Deprecated
default boolean ban(String channel, String user, String reason) {
StringBuilder sb = new StringBuilder(user);
if (reason != null) {
Expand All @@ -246,7 +264,9 @@ default boolean ban(String channel, String user, String reason) {
* @param channel channel
* @param user username
* @return whether the command was added to the queue
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#banUser
*/
@Deprecated
default boolean unban(String channel, String user) {
return this.sendMessage(channel, String.format("/unban %s", user));
}
Expand All @@ -258,8 +278,10 @@ default boolean unban(String channel, String user) {
* @param message the message to be announced.
* @return whether the command was added to the queue
* @see <a href="https://twitter.com/TwitchSupport/status/1509634525982302208">Official Announcement</a>
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#sendChatAnnouncement
*/
@Unofficial
@Deprecated
default boolean sendAnnouncement(String channel, String message) {
return this.sendMessage(channel, String.format("/announce %s", message));
}
Expand Down
2 changes: 2 additions & 0 deletions chat/src/main/java/com/github/twitch4j/chat/TwitchChat.java
Expand Up @@ -782,7 +782,9 @@ public boolean sendMessage(String channel, String message, Map<String, Object> t
*
* @param targetUser username
* @param message message
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#sendWhisper
*/
@Deprecated
public void sendPrivateMessage(String targetUser, String message) {
log.debug("Adding private message for user [{}] with content [{}] to the queue.", targetUser, message);
BucketUtils.scheduleAgainstBucket(
Expand Down
Expand Up @@ -145,8 +145,12 @@ public class TwitchChatBuilder {

/**
* Custom RateLimit for Whispers
*
* @deprecated Twitch will decommission whispers over IRC on February 18, 2023;
* please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimit
*/
@With
@Deprecated
protected Bandwidth[] whisperRateLimit = TwitchChatLimitHelper.USER_WHISPER_LIMIT.toArray(new Bandwidth[2]);

/**
Expand Down Expand Up @@ -177,8 +181,12 @@ public class TwitchChatBuilder {

/**
* Shared bucket for whispers
*
* @deprecated Twitch will decommission whispers over IRC on February 18, 2023;
* please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimit
*/
@With
@Deprecated
protected Bucket ircWhisperBucket = null;

/**
Expand Down
Expand Up @@ -178,7 +178,9 @@ public boolean sendMessage(String channelToIdentifyChatInstance, String targetCh
* @param message the message to send in the whisper.
* @return whether a {@link TwitchChat} instance was identified to send the message from.
* @throws NullPointerException if the identified {@link TwitchChat} does not have a valid chatCredential
* @deprecated Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#updateChatSettings
*/
@Deprecated
public boolean sendPrivateMessage(final String channelToIdentifyChatInstance, final String toChannel, final String message) {
final TwitchChat chat;
if (channelToIdentifyChatInstance == null || (chat = subscriptions.get(channelToIdentifyChatInstance.toLowerCase())) == null)
Expand Down
Expand Up @@ -591,13 +591,15 @@ public void onInboundHostEvent(IRCMessageEvent event) {
}
}

@Deprecated
public void onListModsEvent(IRCMessageEvent event) {
if ("NOTICE".equals(event.getCommandType()) && event.getTagValue("msg-id").filter(s -> s.equals(NoticeTag.ROOM_MODS.toString()) || s.equals(NoticeTag.NO_MODS.toString())).isPresent()) {
List<String> names = extractItemsFromDelimitedList(event.getMessage(), "The moderators of this channel are: ", ", ");
eventManager.publish(new ListModsEvent(event.getChannel(), names));
}
}

@Deprecated
public void onListVipsEvent(IRCMessageEvent event) {
if ("NOTICE".equals(event.getCommandType()) && event.getTagValue("msg-id").filter(s -> s.equals(NoticeTag.VIPS_SUCCESS.toString()) || s.equals(NoticeTag.NO_VIPS.toString())).isPresent()) {
List<String> names = extractItemsFromDelimitedList(event.getMessage(), "The VIPs of this channel are: ", ", ");
Expand Down
Expand Up @@ -9,9 +9,15 @@

import java.util.List;

/**
* Called following a /mods message.
*
* @deprecated Twitch will decommission this event on February 18, 2023; migrate to TwitchHelix#getModerators
*/
@Value
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Deprecated
public class ListModsEvent extends AbstractChannelEvent {

/**
Expand Down
Expand Up @@ -9,9 +9,15 @@

import java.util.List;

/**
* Called following a /vips message.
*
* @deprecated Twitch will decommission this event on February 18, 2023; migrate to TwitchHelix#getChannelVips
*/
@Value
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Deprecated
public class ListVipsEvent extends AbstractChannelEvent {

/**
Expand Down
Expand Up @@ -182,8 +182,12 @@ public class TwitchClientBuilder {

/**
* Custom RateLimit for Whispers
*
* @deprecated Twitch will decommission whispers over IRC on February 18, 2023;
* please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimit
*/
@With
@Deprecated
protected Bandwidth[] chatWhisperLimit = TwitchChatLimitHelper.USER_WHISPER_LIMIT.toArray(new Bandwidth[2]);

/**
Expand Down
Expand Up @@ -199,8 +199,12 @@ public class TwitchClientPoolBuilder {

/**
* Custom RateLimit for Whispers
*
* @deprecated Twitch will decommission whispers over IRC on February 18, 2023;
* please migrate to TwitchHelix#sendWhisper and TwitchLimitRegistry#setLimit
*/
@With
@Deprecated
protected Bandwidth[] chatWhisperLimit = TwitchChatLimitHelper.USER_WHISPER_LIMIT.toArray(new Bandwidth[2]);

/**
Expand Down