From 690e552448e4bc31c095364c09daad003c84d1a4 Mon Sep 17 00:00:00 2001 From: Aldino Kemal Date: Sun, 13 Nov 2022 06:59:25 +0700 Subject: [PATCH] feat: update variable name become webhook --- src/cmd/root.go | 2 +- src/config/settings.go | 10 +++++----- src/utils/whatsapp.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cmd/root.go b/src/cmd/root.go index 64a6e43..87f4d02 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -37,7 +37,7 @@ func init() { rootCmd.PersistentFlags().BoolVarP(&config.AppDebug, "debug", "d", config.AppDebug, "hide or displaying log with --debug | example: --debug=true") rootCmd.PersistentFlags().StringVarP(&config.AppBasicAuthCredential, "basic-auth", "b", config.AppBasicAuthCredential, "basic auth credential | yourUsername:yourPassword") rootCmd.PersistentFlags().StringVarP(&config.WhatsappAutoReplyMessage, "autoreply", "", config.WhatsappAutoReplyMessage, `auto reply when received message --autoreply | example: --autoreply="Don't reply this message"`) - rootCmd.PersistentFlags().StringVarP(&config.WhatsappAutoReplyCallbackEndpoint, "callback", "c", config.WhatsappAutoReplyMessage, `auto reply when received message --callback | example: --callback="https://yourcallback.com/callback"`) + rootCmd.PersistentFlags().StringVarP(&config.WhatsappAutoReplyWebhook, "webhook", "w", config.WhatsappAutoReplyMessage, `auto reply when received message --webhook | example: --webhook="https://yourcallback.com/callback"`) } func runRest(cmd *cobra.Command, args []string) { diff --git a/src/config/settings.go b/src/config/settings.go index 875758b..0de12b2 100644 --- a/src/config/settings.go +++ b/src/config/settings.go @@ -20,9 +20,9 @@ var ( DBName string = "hydrogenWaCli.db" - WhatsappLogLevel string = "ERROR" - WhatsappAutoReplyMessage string - WhatsappAutoReplyCallbackEndpoint string - WhatsappSettingMaxFileSize int64 = 30000000 // 10MB - WhatsappSettingMaxVideoSize int64 = 30000000 // 30MB + WhatsappLogLevel string = "ERROR" + WhatsappAutoReplyMessage string + WhatsappAutoReplyWebhook string + WhatsappSettingMaxFileSize int64 = 30000000 // 10MB + WhatsappSettingMaxVideoSize int64 = 30000000 // 30MB ) diff --git a/src/utils/whatsapp.go b/src/utils/whatsapp.go index 0467e3a..516f48e 100644 --- a/src/utils/whatsapp.go +++ b/src/utils/whatsapp.go @@ -184,7 +184,7 @@ func handler(rawEvt interface{}) { _, _ = cli.SendMessage(context.Background(), evt.Info.Sender, "", &waProto.Message{Conversation: proto.String(config.WhatsappAutoReplyMessage)}) } - if config.WhatsappAutoReplyCallbackEndpoint != "" { + if config.WhatsappAutoReplyWebhook != "" { go func() { _ = sendAutoReplyCallback(evt) }() @@ -251,7 +251,7 @@ func sendAutoReplyCallback(evt *events.Message) error { "forwarded": evt.Message.GetGroupInviteMessage(), } postBody, _ := json.Marshal(body) - req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, config.WhatsappAutoReplyCallbackEndpoint, bytes.NewBuffer(postBody)) + req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, config.WhatsappAutoReplyWebhook, bytes.NewBuffer(postBody)) if err != nil { log.Errorf("error when create http object %v", err) return err