diff --git a/cmd/root.go b/cmd/root.go index 0c68cc9..c99a2ce 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -54,7 +54,7 @@ func Execute() { func init() { cobra.OnInitialize() - rootCmd.Flags().StringP("bot token", "b", "", "Enter a valid telegram bot token") + rootCmd.Flags().StringP("bot-token", "b", "", "Enter a valid telegram bot token") rootCmd.Flags().StringP("time", "t", "17:00", "Enter a valid time") rootCmd.Flags().StringP("timezone", "z", "Africa/Cairo", "Enter a valid timezone") } diff --git a/internal/bot.go b/internal/bot.go index 1351e2c..6517cc2 100644 --- a/internal/bot.go +++ b/internal/bot.go @@ -18,7 +18,7 @@ type Bot struct { } // NewBot creates new bot with a valid bot api and communication channels -func NewBot(token string, t string, timezone string) (Bot, error) { +func NewBot(token string, inputTime string, timezone string) (Bot, error) { bot := Bot{} botAPI, err := tgbotapi.NewBotAPI(token) @@ -33,7 +33,8 @@ func NewBot(token string, t string, timezone string) (Bot, error) { return bot, err } - parsedTime, err := time.ParseInLocation("02 Jan 06 15:04", time.Now().Format("02 Jan 06 ")+t, loc) + inputTime = time.Now().Format("02 Jan 06 ") + inputTime + parsedTime, err := time.ParseInLocation("02 Jan 06 15:04", inputTime, loc) if err != nil { return bot, err }