Class SendPoll


public class SendPoll extends AbstractBaseRequest<SendPoll,Message>
SendPoll class. Returns sent Message on success.
Since:
3 March 2025
See Also:
  • Constructor Details

    • SendPoll

      public SendPoll(Object chat_id, String question, InputPollOption[] options, Api api)
      Required
      Parameters:
      chat_id - chat id
      question - question
      options - options
      api - api
  • Method Details

    • isAnonymous

      public SendPoll isAnonymous(boolean is_anonymous)
      Optional
      Parameters:
      is_anonymous - True, if the poll needs to be anonymous, defaults to True
      Returns:
      SendPoll
    • type

      public SendPoll type(PollType type)
      Optional
      Parameters:
      type - Poll type, PollType.QUIZ or PollType.REGULAR, defaults to PollType.REGULAR
      Returns:
      SendPoll
    • allowsMultipleAnswers

      public SendPoll allowsMultipleAnswers(boolean allows_multiple_answers)
      Optional
      Parameters:
      allows_multiple_answers - True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False
      Returns:
      SendPoll
    • correctOptionId

      public SendPoll correctOptionId(int correct_option_id)
      Optional
      Parameters:
      correct_option_id - 0-based identifier of the correct answer option, required for polls in quiz mode
      Returns:
      SendPoll
    • explanation

      public SendPoll explanation(String explanation)
      Optional
      Parameters:
      explanation - Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing
      Returns:
      SendPoll
    • explanationParseMode

      public SendPoll explanationParseMode(ParseMode explanation_parse_mode)
      Optional
      Parameters:
      explanation_parse_mode - Mode for parsing entities in the explanation.
      Returns:
      SendPoll
    • explanationEntities

      public SendPoll explanationEntities(MessageEntity[] explanation_entities)
      Optional
      Parameters:
      explanation_entities - A JSON-serialized list of special entities that appear in the poll explanation. It can be specified instead of explanation_parse_mode
      Returns:
      SendPoll
    • openPeriod

      public SendPoll openPeriod(int open_period)
      Optional
      Parameters:
      open_period - Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date.
      Returns:
      SendPoll
    • closeDate

      public SendPoll closeDate(int close_date)
      Optional
      Parameters:
      close_date - Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with open_period.
      Returns:
      SendPoll
    • isClosed

      public SendPoll isClosed(boolean is_closed)
      Optional
      Parameters:
      is_closed - Pass True if the poll needs to be immediately closed. This can be useful for poll preview.
      Returns:
      SendPoll
    • disableNotification

      public SendPoll disableNotification(boolean disable_notification)
      Optional
      Parameters:
      disable_notification - Sends the message silently. Users will receive a notification with no sound.
      Returns:
      SendPoll
    • protectContent

      public SendPoll protectContent(boolean protect_content)
      Optional
      Parameters:
      protect_content - Protects the contents of the sent message from forwarding and saving
      Returns:
      SendPoll
    • allowPaidBroadcast

      public SendPoll allowPaidBroadcast(boolean allow_paid_broadcast)
      Optional
      Parameters:
      allow_paid_broadcast - Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
      Returns:
      SendPoll
    • replyParameters

      public SendPoll replyParameters(ReplyParameters reply_parameters)
      Optional
      Parameters:
      reply_parameters - Description of the message to reply to
      Returns:
      SendPoll
    • replyMarkup

      public SendPoll replyMarkup(Markup reply_markup)
      Optional
      Parameters:
      reply_markup - Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
      Returns:
      SendPoll
    • businessConnectionId

      public SendPoll businessConnectionId(String business_connection_id)
      Optional
      Parameters:
      business_connection_id - Unique identifier of the business connection on behalf of which the message will be sent
      Returns:
      SendPoll
    • questionParseMode

      public SendPoll questionParseMode(ParseMode question_parse_mode)
      Optional
      Parameters:
      question_parse_mode - Mode for parsing entities in the question.
      Returns:
      SendPoll
    • questionEntities

      public SendPoll questionEntities(MessageEntity[] question_entities)
      Optional
      Parameters:
      question_entities - A JSON-serialized list of special entities that appear in the poll question. It can be specified instead of question_parse_mode
      Returns:
      SendPoll
    • messageEffectId

      public SendPoll messageEffectId(String message_effect_id)
      Optional
      Parameters:
      message_effect_id - Unique identifier of the message effect to be added to the message; for private chats only
      Returns:
      SendPoll