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();
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface org.teleight.teleightbots.bot.settings.BotSettings
DEFAULT_BOT_API_URL -
Constructor Summary
ConstructorsConstructorDescriptionWebhookBotSettings(String url, String path, InputFile certificate, String ipAddress, int maxConnections, String[] allowedUpdates, boolean dropPendingUpdates, String secretToken, boolean silentlyThrowMethodExecution, boolean extensionsEnabled) Creates an instance of aWebhookBotSettingsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionString[]Returns the value of theallowedUpdatesrecord component.Returns the value of thecertificaterecord component.booleanReturns the value of thedropPendingUpdatesrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of theextensionsEnabledrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of theipAddressrecord component.intReturns the value of themaxConnectionsrecord component.static @NotNull WebhookBotSettingsCreates a new instance ofWebhookBotSettingswith the specified URL.static @NotNull WebhookBotSettings.BuilderCreates a newWebhookBotSettings.Builderinstance with the specified webhook URL.path()Returns the value of thepathrecord component.Returns the value of thesecretTokenrecord component.booleanReturns the value of thesilentlyThrowMethodExecutionrecord component.final StringtoString()Returns a string representation of this record class.url()Returns the value of theurlrecord component.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.teleight.teleightbots.bot.settings.BotSettings
endpointUrl
-
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 aWebhookBotSettingsrecord class.- Parameters:
url- the value for theurlrecord componentpath- the value for thepathrecord componentcertificate- the value for thecertificaterecord componentipAddress- the value for theipAddressrecord componentmaxConnections- the value for themaxConnectionsrecord componentallowedUpdates- the value for theallowedUpdatesrecord componentdropPendingUpdates- the value for thedropPendingUpdatesrecord componentsecretToken- the value for thesecretTokenrecord componentsilentlyThrowMethodExecution- the value for thesilentlyThrowMethodExecutionrecord componentextensionsEnabled- the value for theextensionsEnabledrecord component
-
-
Method Details
-
ofBuilder
@NotNull public static @NotNull WebhookBotSettings.Builder ofBuilder(@NotNull @NotNull String url, @NotNull @NotNull String path) Creates a newWebhookBotSettings.Builderinstance with the specified webhook URL.- Parameters:
url- the webhook URL for registering with Telegram. Cannot benull.path- the URL path on your server where the webhook will be received. Cannot benull.- Returns:
- a new
WebhookBotSettings.Builderinstance pre-configured with the provided URL - Throws:
NullPointerException- if theurlisnull
-
of
@NotNull public static @NotNull WebhookBotSettings of(@NotNull @NotNull String url, @NotNull @NotNull String path) Creates a new instance ofWebhookBotSettingswith the specified URL.- Parameters:
url- the webhook URL for registering with Telegram. Cannot benull.path- the URL path on your server where the webhook will be received. Cannot benull.- Returns:
- a new
WebhookBotSettingsinstance - Throws:
NullPointerException- if theurlisnull
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
url
Returns the value of theurlrecord component.- Returns:
- the value of the
urlrecord component
-
path
Returns the value of thepathrecord component.- Returns:
- the value of the
pathrecord component
-
certificate
Returns the value of thecertificaterecord component.- Returns:
- the value of the
certificaterecord component
-
ipAddress
Returns the value of theipAddressrecord component.- Returns:
- the value of the
ipAddressrecord component
-
maxConnections
public int maxConnections()Returns the value of themaxConnectionsrecord component.- Returns:
- the value of the
maxConnectionsrecord component
-
allowedUpdates
Returns the value of theallowedUpdatesrecord component.- Returns:
- the value of the
allowedUpdatesrecord component
-
dropPendingUpdates
public boolean dropPendingUpdates()Returns the value of thedropPendingUpdatesrecord component.- Returns:
- the value of the
dropPendingUpdatesrecord component
-
secretToken
Returns the value of thesecretTokenrecord component.- Returns:
- the value of the
secretTokenrecord component
-
silentlyThrowMethodExecution
public boolean silentlyThrowMethodExecution()Returns the value of thesilentlyThrowMethodExecutionrecord component.- Specified by:
silentlyThrowMethodExecutionin interfaceBotSettings- Returns:
- the value of the
silentlyThrowMethodExecutionrecord component
-
extensionsEnabled
public boolean extensionsEnabled()Returns the value of theextensionsEnabledrecord component.- Specified by:
extensionsEnabledin interfaceBotSettings- Returns:
- the value of the
extensionsEnabledrecord component
-