@ -42,6 +42,25 @@ Now that we support ARM64 for Linux:
You may modify this by using the option below:
- `--webhook-secret="secret"`
## Configuration
You can configure the application using either command-line flags (shown above) or environment variables. Configuration can be set in three ways (in order of priority):
1. Command-line flags (highest priority)
2. Environment variables
3. `.env` file (lowest priority)
### Environment Variables
To use environment variables:
1. Copy `.env.example` to `.env` in your project root
2. Modify the values in `.env` according to your needs
3. Or set the same variables as system environment variables
See [.env.example](./src/.env.example) for all available configuration options.
Note: Command-line flags will override any values set in environment variables or `.env` file.
// initFlags sets up command line flags that override environment variables
funcinitFlags(){
rootCmd.CompletionOptions.DisableDefaultCmd=true
rootCmd.PersistentFlags().StringVarP(&config.AppPort,"port","p",config.AppPort,"change port number with --port <number> | example: --port=8080")
rootCmd.PersistentFlags().BoolVarP(&config.AppDebug,"debug","d",config.AppDebug,"hide or displaying log with --debug <true/false> | example: --debug=true")
rootCmd.PersistentFlags().StringVarP(&config.AppOs,"os","",config.AppOs,`os name --os <string> | example: --os="Chrome"`)
rootCmd.PersistentFlags().StringVarP(&config.WhatsappAutoReplyMessage,"autoreply","",config.WhatsappAutoReplyMessage,`auto reply when received message --autoreply <string> | example: --autoreply="Don't reply this message"`)
rootCmd.PersistentFlags().StringSliceVarP(&config.WhatsappWebhook,"webhook","w",config.WhatsappWebhook,`forward event to webhook --webhook <string> | example: --webhook="https://yourcallback.com/callback"`)
rootCmd.PersistentFlags().BoolVarP(&config.WhatsappAccountValidation,"account-validation","",config.WhatsappAccountValidation,`enable or disable account validation --account-validation <true/false> | example: --account-validation=true`)
rootCmd.PersistentFlags().StringVarP(&config.DBURI,"db-uri","",config.DBURI,`the database uri to store the connection data database uri (by default, we'll use sqlite3 under storages/whatsapp.db). database uri --db-uri <string> | example: --db-uri="file:storages/whatsapp.db?_foreign_keys=off or postgres://user:password@localhost:5432/whatsapp"`)
rootCmd.PersistentFlags().IntVarP(&config.AppChatFlushIntervalDays,"chat-flush-interval","",config.AppChatFlushIntervalDays,`the interval to flush the chat storage --chat-flush-interval <number> | example: --chat-flush-interval=7`)
// Application flags
rootCmd.PersistentFlags().StringVarP(
&config.AppPort,
"port","p",
config.AppPort,
"change port number with --port <number> | example: --port=8080",
)
rootCmd.PersistentFlags().BoolVarP(
&config.AppDebug,
"debug","d",
config.AppDebug,
"hide or displaying log with --debug <true/false> | example: --debug=true",
`the interval to flush the chat storage --chat-flush-interval <number> | example: --chat-flush-interval=7`,
)
// Database flags
rootCmd.PersistentFlags().StringVarP(
&config.DBURI,
"db-uri","",
config.DBURI,
`the database uri to store the connection data database uri (by default, we'll use sqlite3 under storages/whatsapp.db). database uri --db-uri <string> | example: --db-uri="file:storages/whatsapp.db?_foreign_keys=off or postgres://user:password@localhost:5432/whatsapp"`,
)
// WhatsApp flags
rootCmd.PersistentFlags().StringVarP(
&config.WhatsappAutoReplyMessage,
"autoreply","",
config.WhatsappAutoReplyMessage,
`auto reply when received message --autoreply <string> | example: --autoreply="Don't reply this message"`,
)
rootCmd.PersistentFlags().StringSliceVarP(
&config.WhatsappWebhook,
"webhook","w",
config.WhatsappWebhook,
`forward event to webhook --webhook <string> | example: --webhook="https://yourcallback.com/callback"`,
`enable or disable account validation --account-validation <true/false> | example: --account-validation=true`,
)
rootCmd.PersistentFlags().BoolVarP(
&config.WhatsappChatStorage,
"chat-storage","",
config.WhatsappChatStorage,
`enable or disable chat storage --chat-storage <true/false>. If you disable this, reply feature maybe not working properly | example: --chat-storage=true`,