cormorant

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 14 Imported by: 0

README

cormorant

Source code for the tymas discord server bot, which has /join /leave /color and /weather commands. Join and leave are for pingable roles for coordination of games and the like or updates on particular topics. Color is for assigning nick colors. Weather provides current conditions, today's forecast, and the weekly forecast using open-meteo.

Running via docker-compose

  1. Make a secrets.env in the following format:
appid=yourappid
authtoken=yourtoken
  1. Copy the included docker-compose.yml file from the root of this repo
  2. Replace the env_file path in the docker compose file with the path to your secrets.env
  3. docker-compose up

Documentation

Index

Constants

View Source
const (
	ColorCmd    = "color"
	JoinCmd     = "join"
	LeaveCmd    = "leave"
	WeatherCmd  = "weather"
	ShutdownCmd = "shutdown"

	ColorOption    = "color"
	GroupOption    = "group"
	LocationOption = "location"
	ForecastOption = "forecast"
)

Constants related to the bot's discord commands and their options

Variables

This section is empty.

Functions

func Fahrenheit

func Fahrenheit(celsius float64) float64

Fahrenheit converts celsius to fahrenheit

func Forecast

func Forecast(place string, forecast ForecastType) (ret string, err error)

Forecast returns a forecast for a location, or an error if something goes wrong. The forecast parameter specifies the type of forecast we want.

func Geocode

func Geocode(place string, extractState bool) (ret *pb.GeocodingApi_Geoname, err error)

Geocode calls the open-meteo geocoding API to get information a postal code or place name, and returns a struct containing that information unless an error occurred or we failed to find anything. If extractState is true, it splits the place string at a "," if one exists, searches for the left hand side, and looks through the results to try to find one whose geo.Admin1 matches the right hand side.

func Inches

func Inches(mm float64) float64

Inches converts millimeters to inches

func Mph

func Mph(kmPerH float64) float64

Mph converts km/h to MPH

Types

type DiscordUI

type DiscordUI struct {
	// contains filtered or unexported fields
}

DiscordUI holds data needed to interact with Discord.

func NewDiscordUI

func NewDiscordUI(appID string, botToken string, runningChan chan int) *DiscordUI

NewDiscordUI returns a new DiscordUI object.

func (*DiscordUI) FindRole

func (this *DiscordUI) FindRole(groles []*discordgo.Role, mrole string) *discordgo.Role

FindRole finds the role with the ID mrole in groles and returns it, or nil if it isn't found.

func (*DiscordUI) Run

func (this *DiscordUI) Run()

Run registers things and connects to discord.

type ForecastType

type ForecastType int

ForecastType indicates what type of forecast the user wants.

const (
	CurrentForecast ForecastType = iota // The current conditions
	TodayForecast                       // Today's forecast
	WeekForecast                        // The forecast for the next week
)

Constants representing which forecast the user is requesting

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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