dinny

package module
v0.0.0-...-56269a8 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: MIT Imports: 2 Imported by: 0

README

dinny

about

dinny is a slack bot meant to organize a dinner rotation between my friends and me.

  • It keeps track of meals eaten, meals cooked, and the meals eaten to meals cooked ratio.
  • It can post status updates within slack to show each member's ratio, which will also encourage those with the worst ratios to cook next.
  • It can send out a 'who's eating tomorrow' message the day before someone cooks so those eating will be able to signal their intentions by liking the message.

See here for a sample dinnyd (server) config file. See here for a sample dinny (cli) config file.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Application error codes

Functions

This section is empty.

Types

type Date

type Date struct {
	Year  int        `json:"year"`
	Month time.Month `json:"month"`
	Day   int        `json:"day"`
}

Date represents the year, month, and day of the meal.

type Meal

type Meal struct {
	ID             int64  `json:"id"`
	CookSlackUID   string `json:"cookSlackUID"`
	Date           Date   `json:"date"`
	Description    string `json:"description"`
	SlackMessageID string `json:"slackMessageID"`
}

Meal represents a meal in dinner rotation.

func (*Meal) Expired

func (m *Meal) Expired() bool

Expired determines if a meal is expired if it's after the date the meal was supposed to occur.

type MealService

type MealService interface {
	// FindMealByID retrieves a meal by ID.
	// Returns ErrNotFound if meal does not exist.
	FindMealByID(id int64) (*Meal, error)

	// FindMealByDate retrieves a meal by Date.
	// Returns ErrNotFound if meal does not exist.
	FindMealByDate(date Date) (*Meal, error)

	// FindMealBySlackMessageID retrieves a meal by SlackMessageID.
	// Returns ErrNotFound if meal does not exist.
	FindMealBySlackMessageID(slackMessageID string) (*Meal, error)

	// CreateMeal creates a new meal.
	CreateMeal(m *Meal) error

	// UpdateMeal updates a meal object.
	UpdateMeal(id int64, upd MealUpdate) error

	// DeleteMeal permanently deletes a meal.
	DeleteMeal(id int64) error
}

MealService represents a service for managing meals.

type MealUpdate

type MealUpdate struct {
	ChefSlackUID   *string
	Description    *string
	SlackMessageID *string
}

MealUpdate represents a set of fields to be updated via UpdateMeal().

type Member

type Member struct {
	ID          int64  `json:"id"`
	SlackUID    string `json:"slackUID"`
	FullName    string `json:"fullName"`
	MealsEaten  int64  `json:"mealsEaten"`
	MealsCooked int64  `json:"mealsCooked"`
	Leader      bool   `json:"leader"`
}

Member represents a member of dinner rotation.

type MemberService

type MemberService interface {
	// FindMemberByID retrieves a member by ID.
	// Returns ErrNotFound if meal does not exist.
	FindMemberByID(id int64) (*Member, error)

	// FindMemberBySlackUID retrieves a member by SlackID.
	// Returns ErrNotFound if meal does not exist.
	FindMemberBySlackUID(slackUID string) (*Member, error)

	// ListMembers retrieves a list of members.
	ListMembers() ([]*Member, error)

	// CreateMember creates a new member.
	CreateMember(m *Member) error

	// UpdateMember updates a member object.
	UpdateMember(id int64, upd MemberUpdate) error

	// DeleteMember permanently deletes a member.
	DeleteMember(id int64) error
}

MemberService represents a service for managing members.

type MemberUpdate

type MemberUpdate struct {
	MealsEaten  *int64
	MealsCooked *int64
	Leader      *bool
}

MemberUpdate represents a set of fields to be updated via UpdateMember().

Directories

Path Synopsis
cmd
gen

Jump to

Keyboard shortcuts

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