public-ip-tracker/tracker/main.go
Melora Hugues 54de3b84cd
All checks were successful
continuous-integration/drone/push Build is passing
Add link to Telegram
Ref #2

This commit adds a link to a Go Telegram API to send messages to a given
telegram channel provided with a JSON config file. At the moment the
program sends a simple status message to the bot when starting up, but
this allows testing whether the link to Telegram is correctly working.
2023-01-25 20:42:43 +01:00

47 lines
782 B
Go

package main
import (
"context"
"flag"
"fmt"
"git.faercol.me/faercol/public-ip-tracker/tracker/bot"
"git.faercol.me/faercol/public-ip-tracker/tracker/config"
)
func testMethod(a int) int {
return a + 2
}
type cliArgs struct {
configPath string
}
func parseArgs() *cliArgs {
configPath := flag.String("config", "", "Path to the JSON configuration file")
flag.Parse()
return &cliArgs{
configPath: *configPath,
}
}
func main() {
fmt.Println("Parsing arguments")
args := parseArgs()
fmt.Println("Parsing config")
conf, err := config.New(args.configPath)
if err != nil {
panic(err)
}
fmt.Println("Initializing bot")
notifBot := bot.New(context.Background(), conf)
if err := notifBot.SendInitMessage(); err != nil {
panic(err)
}
fmt.Println("OK")
}