mirror of
https://github.com/idanoo/go-flat-finder
synced 2025-07-03 06:32:18 +00:00
Initial Commit
This commit is contained in:
commit
ee32ba1537
13 changed files with 583 additions and 0 deletions
72
cmd/flatfinder/main.go
Executable file
72
cmd/flatfinder/main.go
Executable file
|
@ -0,0 +1,72 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flatfinder/internal/flatfinder"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Load .env
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatal("Cannot load .env file in current directory")
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Load env vars and validate
|
||||
flatfinder.Conf = flatfinder.LocalConfig{}
|
||||
|
||||
// Load webhook
|
||||
flatfinder.Conf.DiscordWebhook = os.Getenv("DISCORD_WEBHOOK")
|
||||
if flatfinder.Conf.DiscordWebhook == "" {
|
||||
log.Fatal("DISCORD_WEBHOOK not set")
|
||||
}
|
||||
|
||||
// Load Google stuff
|
||||
flatfinder.Conf.GoogleApiToken = os.Getenv("GOOGLE_API_KEY")
|
||||
if flatfinder.Conf.GoogleApiToken == "" {
|
||||
log.Print("GOOGLE_API_KEY not set. Not using map logicc")
|
||||
}
|
||||
flatfinder.Conf.GoogleLocation1 = os.Getenv("GOOGLE_LOCATION_1")
|
||||
flatfinder.Conf.GoogleLocation2 = os.Getenv("GOOGLE_LOCATION_2")
|
||||
|
||||
// Load trademe config
|
||||
flatfinder.Conf.TradeMeKey = os.Getenv("TRADEME_API_KEY")
|
||||
flatfinder.Conf.TradeMeSecret = os.Getenv("TRADEME_API_SECRET")
|
||||
if flatfinder.Conf.TradeMeKey == "" || flatfinder.Conf.TradeMeSecret == "" {
|
||||
log.Fatal("TRADEME_API_KEY or TRADEME_API_SECRET not set")
|
||||
}
|
||||
|
||||
// Load filterse
|
||||
flatfinder.Conf.Suburbs = os.Getenv("SUBURBS")
|
||||
if flatfinder.Conf.Suburbs == "" {
|
||||
log.Fatal("SUBURBS not set")
|
||||
}
|
||||
|
||||
flatfinder.Conf.BedroomsMin = os.Getenv("BEDROOMS_MIN")
|
||||
if flatfinder.Conf.BedroomsMin == "" {
|
||||
log.Fatal("BEDROOMS_MIN not set")
|
||||
}
|
||||
|
||||
flatfinder.Conf.BedroomsMax = os.Getenv("BEDROOMS_MAX")
|
||||
if flatfinder.Conf.BedroomsMax == "" {
|
||||
log.Fatal("BEDROOMS_MAX not set")
|
||||
}
|
||||
|
||||
flatfinder.Conf.PriceMax = os.Getenv("PRICE_MAX")
|
||||
if flatfinder.Conf.PriceMax == "" {
|
||||
log.Fatal("PRICE_MAX not set")
|
||||
}
|
||||
|
||||
flatfinder.Conf.PropertyTypes = os.Getenv("PROPERTY_TYPE")
|
||||
if flatfinder.Conf.PropertyTypes == "" {
|
||||
log.Fatal("PROPERTY_TYPE not set")
|
||||
}
|
||||
|
||||
// Start the stuff
|
||||
flatfinder.Launch()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue