Record Class WebhookBotSettings

java.lang.Object
java.lang.Record
org.teleight.teleightbots.bot.settings.WebhookBotSettings
Record Components:
url - The full webhook URL used for setting up the bot's webhook with Telegram.
path - The URL path on your server where the webhook will be received. By default, this is set to the bot's username.
certificate - Public key certificate for the webhook. The certificate supplied should be PEM encoded (ASCII BASE64), the pem file should only contain the public key (including BEGIN and END portions). When converting from a bundle format, please split the file to only include the public key.
ipAddress - The fixed IP address used to send webhook requests.
maxConnections - The maximum number of simultaneous HTTPS connections the bot can use.
allowedUpdates - A list of update types the bot will receive (e.g., messages, callbacks).
dropPendingUpdates - Whether pending updates should be discarded when setting up the webhook.
secretToken - A secret token for verifying the origin of the webhook requests.
silentlyThrowMethodExecution - Whether to silently throw method execution errors.
extensionsEnabled - Whether bot extensions are enabled.
All Implemented Interfaces:
BotSettings

public record WebhookBotSettings(String url, String path, InputFile certificate, String ipAddress, int maxConnections, String[] allowedUpdates, boolean dropPendingUpdates, String secretToken, boolean silentlyThrowMethodExecution, boolean extensionsEnabled) extends Record implements BotSettings
Settings for configuring a webhook-based Telegram bot.

Example usage:


 WebhookBotSettings settings = WebhookBotSettings.ofBuilder("https://your.webhook.url/", "/bot-webhook")
           .maxConnections(100)
           .allowedUpdates(new String[]{"message", "callback_query"})
           .dropPendingUpdates(true)
           .secretToken("your_secret_token")
           .build();
 
  • Constructor Details

    • WebhookBotSettings

      public WebhookBotSettings(String url, String path, InputFile certificate, String ipAddress, int maxConnections, String[] allowedUpdates, boolean dropPendingUpdates, String secretToken, boolean silentlyThrowMethodExecution, boolean extensionsEnabled)
      Creates an instance of a WebhookBotSettings record class.
      Parameters:
      url - the value for the url record component
      path - the value for the path record component
      certificate - the value for the certificate record component
      ipAddress - the value for the ipAddress record component
      maxConnections - the value for the maxConnections record component
      allowedUpdates - the value for the allowedUpdates record component
      dropPendingUpdates - the value for the dropPendingUpdates record component
      secretToken - the value for the secretToken record component
      silentlyThrowMethodExecution - the value for the silentlyThrowMethodExecution record component
      extensionsEnabled - the value for the extensionsEnabled record component
  • Method Details

    • ofBuilder

      @NotNull public static @NotNull WebhookBotSettings.Builder ofBuilder(@NotNull @NotNull String url, @NotNull @NotNull String path)
      Creates a new WebhookBotSettings.Builder instance with the specified webhook URL.
      Parameters:
      url - the webhook URL for registering with Telegram. Cannot be null.
      path - the URL path on your server where the webhook will be received. Cannot be null.
      Returns:
      a new WebhookBotSettings.Builder instance pre-configured with the provided URL
      Throws:
      NullPointerException - if the url is null
    • of

      @NotNull public static @NotNull WebhookBotSettings of(@NotNull @NotNull String url, @NotNull @NotNull String path)
      Creates a new instance of WebhookBotSettings with the specified URL.
      Parameters:
      url - the webhook URL for registering with Telegram. Cannot be null.
      path - the URL path on your server where the webhook will be received. Cannot be null.
      Returns:
      a new WebhookBotSettings instance
      Throws:
      NullPointerException - if the url is null
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • url

      public String url()
      Returns the value of the url record component.
      Returns:
      the value of the url record component
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • certificate

      public InputFile certificate()
      Returns the value of the certificate record component.
      Returns:
      the value of the certificate record component
    • ipAddress

      public String ipAddress()
      Returns the value of the ipAddress record component.
      Returns:
      the value of the ipAddress record component
    • maxConnections

      public int maxConnections()
      Returns the value of the maxConnections record component.
      Returns:
      the value of the maxConnections record component
    • allowedUpdates

      public String[] allowedUpdates()
      Returns the value of the allowedUpdates record component.
      Returns:
      the value of the allowedUpdates record component
    • dropPendingUpdates

      public boolean dropPendingUpdates()
      Returns the value of the dropPendingUpdates record component.
      Returns:
      the value of the dropPendingUpdates record component
    • secretToken

      public String secretToken()
      Returns the value of the secretToken record component.
      Returns:
      the value of the secretToken record component
    • silentlyThrowMethodExecution

      public boolean silentlyThrowMethodExecution()
      Returns the value of the silentlyThrowMethodExecution record component.
      Specified by:
      silentlyThrowMethodExecution in interface BotSettings
      Returns:
      the value of the silentlyThrowMethodExecution record component
    • extensionsEnabled

      public boolean extensionsEnabled()
      Returns the value of the extensionsEnabled record component.
      Specified by:
      extensionsEnabled in interface BotSettings
      Returns:
      the value of the extensionsEnabled record component