shipany.bot
shipany.bot package
Subpackages
This package contains the following subpackages:
- Supported actions / shipany.bot.actions
- Command line interface / shipany.bot.cli
- Contrib modules
- shipany.bot.conversation package
- shipany.bot.errors package
- Scheduler jobs / shipany.bot.jobs
- JSONLogic implementation / shipany.bot.jsonlogic
- Persistency / shipany.bot.persistency
- shipany.bot.providers package
- Runtime / shipany.bot.runtime
- Servers / shipany.bot.servers
Submodules
shipany.bot.config module
Bot configuration settings.
Normally, you would have a .env file with the following content:
BOT_TOKEN=your_bot_token_hereTELEGRAM_API_URL=https://api.telegram.orgIn case you want to use a Telegram webhook instead of polling, you would have the following content:
BOT_TOKEN=your_bot_token_hereTELEGRAM_API_URL=https://api.telegram.orgTELEGRAM_WEBHOOK_URL=https://your-webhook-url-hereTELEGRAM_WEBHOOK_SECRET=your_webhook_secret_hereThe variable TELEGRAM_WEBHOOK_SECRET is optional and can be used to secure the webhook endpoint.
The webhook URL should be a public URL that Telegram can reach. For more information, see the Telegram documentation.
For testing purposes, you can use a service like ngrok to create a public URL for your local development server.
When you run the bot inside a Docker container, you may want to change the WEB_SERVER_HOST to 0.0.0.0.
Checkout shipany.bot.cli.main for an example of how to use these settings.
pydantic settings shipany.bot.config.ApplicationConfig
Application settings consumed on start.
Show JSON schema
```json { "title": "ApplicationConfig", "description": "Application settings consumed on start.", "type": "object", "properties": { "BOT_TOKEN": { "format": "password", "title": "Bot Token", "type": "string", "writeOnly": true }, "TELEGRAM_API_URL": { "default": "https://api.telegram.org", "title": "Telegram Api Url", "type": "string" }, "TELEGRAM_WEBHOOK_URL": { "anyOf": [ { "format": "uri", "maxLength": 2083, "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "title": "Telegram Webhook Url" }, "TELEGRAM_WEBHOOK_SECRET": { "default": "", "format": "password", "title": "Telegram Webhook Secret", "type": "string", "writeOnly": true }, "WEB_SERVER_HOST": { "default": "127.0.0.1", "title": "Web Server Host", "type": "string" }, "WEB_SERVER_PORT": { "default": 8000, "title": "Web Server Port", "type": "integer" } }, "additionalProperties": false, "required": [ "BOT_TOKEN" ] } ```field bot_token : SecretStr [Required] (alias ‘BOT_TOKEN’)
Reads BOT_TOKEN from env.
The Telegram bot token. This is a secret value and should be kept confidential. You can get this token from the BotFather.
field telegram_api_url : str = ‘https://api.telegram.org’ (alias ‘TELEGRAM_API_URL’)
Reads TELEGRAM_API_URL from env. Optional (default is https://api.telegram.org).
The base URL for the Telegram API. This is the default value and should not be changed unless you know what you are doing.
field telegram_webhook_url : HttpUrl | None = None (alias ‘TELEGRAM_WEBHOOK_URL’)
Reads TELEGRAM_WEBHOOK_URL from env. Optional.
The URL where Telegram will send updates. This is optional and should be set only if you want to use a webhook mode.
field telegram_webhook_secret : SecretStr = SecretStr(”) (alias ‘TELEGRAM_WEBHOOK_SECRET’)
Reads TELEGRAM_WEBHOOK_SECRET from env. Optional.
The secret value that Telegram will send with each update. This is optional and should be set only if you want to secure the webhook endpoint.
field web_server_host : str = ‘127.0.0.1’ (alias ‘WEB_SERVER_HOST’)
Reads WEB_SERVER_HOST from env. Optional (default is 127.0.0.1).
The host where the web server will listen for incoming requests. This can be set to localhost or 0.0.0.0.
field web_server_port : int = 8000 (alias ‘WEB_SERVER_PORT’)
Reads WEB_SERVER_PORT from env. Optional (default is 8000).
The port where the web server will listen for incoming requests.