weather

package
v0.0.0-...-33fa7f0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleWeatherMessage

func HandleWeatherMessage(client Client, session *discordgo.Session, message *discordgo.MessageCreate, cmdMatches []string) error

func InitWeatherLogger

func InitWeatherLogger()

Types

type Client

type Client struct {
	APIKey  string
	BaseURL string
}

func NewClient

func NewClient(apiKey, baseUrl string) *Client

func (*Client) CurrentWeather

func (c *Client) CurrentWeather(city string) (*WeatherResponse, error)

func (*Client) ForecastWeather

func (c *Client) ForecastWeather(city string, days int) (*WeatherResponse, error)

type CurrentData

type CurrentData struct {
	Temp      float64 `json:"temp"`
	Condition string  `json:"conditions"`
}

type ForecastDay

type ForecastDay struct {
	Datetime  string  `json:"datetime"`
	TempMax   float64 `json:"tempmax"`
	TempMin   float64 `json:"tempmin"`
	Condition string  `json:"conditions"`
	SunRise   string  `json:"sunrise"`
	SunSet    string  `json:"sunset"`
}

type WeatherApi

type WeatherApi interface {
	CurrentWeather(city string) (*WeatherResponse, error)
	ForecastWeather(city string, days int) (*WeatherResponse, error)
}

type WeatherResponse

type WeatherResponse struct {
	ResolvedAddress   string        `json:"resolvedAddress"`
	CurrentConditions CurrentData   `json:"currentConditions"`
	Days              []ForecastDay `json:"days"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL