Class ChatMessage

java.lang.Object
com.github.twitch4j.helix.domain.ChatMessage

public class ChatMessage extends Object
  • Constructor Details

    • ChatMessage

      @Deprecated public ChatMessage(@NotNull @NotNull String broadcasterId, @NotNull @NotNull String senderId, @NotNull @NotNull String message, @Nullable @Nullable String replyParentMessageId)
      Legacy Constructor
      Parameters:
      broadcasterId - The ID of the broadcaster whose chat room the message will be sent to.
      senderId - The ID of the user sending the message.
      message - The message to send.
      replyParentMessageId - The ID of the chat message being replied to, if any.
    • ChatMessage

      public ChatMessage()
    • ChatMessage

      public ChatMessage(@NotNull @NotNull String broadcasterId, @NotNull @NotNull String senderId, @NotNull @NotNull String message, @Nullable @Nullable String replyParentMessageId, @Nullable @Nullable Boolean forSourceOnly)
      Creates a new ChatMessage instance.
      Parameters:
      broadcasterId - The ID of the broadcaster whose chat room the message will be sent to.
      senderId - The ID of the user sending the message.

      This ID must match the user ID in the user access token (if not using an app access token).

      message - The message to send.

      The message is limited to a maximum of 500 characters.

      replyParentMessageId - The ID of the chat message being replied to, if any.
      forSourceOnly - Whether the chat message is sent only to the source channel (broadcaster_id) during a shared chat session.

      NOTE: Can only be set when utilizing an App Access Token at the top. Cannot be specified when a User Access Token is used and will result in a 400 error.

      Has no effect if the message is not sent during a shared chat session.

      Introduced in April 2025, the default is temporarily “false”. On May 19, 2025 the default value for the for_source_only parameter will be updated to “true” (i.e. chat messages will be only shared with the source channel by default). If you prefer to send a chat message to both channels in a shared chat session, make sure this parameter is explicitly set to “false” in your API request before May 19.

  • Method Details

    • builder

      public static ChatMessage.ChatMessageBuilder builder()
    • toBuilder

      public ChatMessage.ChatMessageBuilder toBuilder()
    • withBroadcasterId

      public ChatMessage withBroadcasterId(@NotNull @NotNull String broadcasterId)
      The ID of the broadcaster whose chat room the message will be sent to.
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withSenderId

      public ChatMessage withSenderId(@NotNull @NotNull String senderId)
      The ID of the user sending the message.

      This ID must match the user ID in the user access token (if not using an app access token).

      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withMessage

      public ChatMessage withMessage(@NotNull @NotNull String message)
      The message to send.

      The message is limited to a maximum of 500 characters.

      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withReplyParentMessageId

      public ChatMessage withReplyParentMessageId(@Nullable @Nullable String replyParentMessageId)
      The ID of the chat message being replied to, if any.
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withForSourceOnly

      public ChatMessage withForSourceOnly(@Nullable @Nullable Boolean forSourceOnly)
      Whether the chat message is sent only to the source channel (broadcaster_id) during a shared chat session.

      NOTE: Can only be set when utilizing an App Access Token at the top. Cannot be specified when a User Access Token is used and will result in a 400 error.

      Has no effect if the message is not sent during a shared chat session.

      Introduced in April 2025, the default is temporarily “false”. On May 19, 2025 the default value for the for_source_only parameter will be updated to “true” (i.e. chat messages will be only shared with the source channel by default). If you prefer to send a chat message to both channels in a shared chat session, make sure this parameter is explicitly set to “false” in your API request before May 19.

      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • getBroadcasterId

      @NotNull public @NotNull String getBroadcasterId()
      The ID of the broadcaster whose chat room the message will be sent to.
    • getSenderId

      @NotNull public @NotNull String getSenderId()
      The ID of the user sending the message.

      This ID must match the user ID in the user access token (if not using an app access token).

    • getMessage

      @NotNull public @NotNull String getMessage()
      The message to send.

      The message is limited to a maximum of 500 characters.

    • getReplyParentMessageId

      @Nullable public @Nullable String getReplyParentMessageId()
      The ID of the chat message being replied to, if any.
    • getForSourceOnly

      @Nullable public @Nullable Boolean getForSourceOnly()
      Whether the chat message is sent only to the source channel (broadcaster_id) during a shared chat session.

      NOTE: Can only be set when utilizing an App Access Token at the top. Cannot be specified when a User Access Token is used and will result in a 400 error.

      Has no effect if the message is not sent during a shared chat session.

      Introduced in April 2025, the default is temporarily “false”. On May 19, 2025 the default value for the for_source_only parameter will be updated to “true” (i.e. chat messages will be only shared with the source channel by default). If you prefer to send a chat message to both channels in a shared chat session, make sure this parameter is explicitly set to “false” in your API request before May 19.

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object