slackbet

package module
v0.0.0-...-12e33ea Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

README

Simple bet integration for slack

This hobby project is used in my workplace. In this simple bet system, each employee tries to guess new user count of the month and half of the office buys coffee to the other half of the office at the end of the month.

This project needs to be run in a server continuously. There should be a bot user in Slack and proper configuration should be assigned. Our use-case runs on a combination of command line integration and bot user integration in Slack.

This project depends on a Redis instance and I just figured that the port is hard-coded. I'll make it more configurable later.

Future improvements

  • Make this readme more meaningful and state all features
  • Tests run on Redis now, they should run on a mock repository layer
  • Consider usage of a simpler persistence, like yaml
  • Make project more configurable
  • The related number regarding the bet result is post to a channel in Slack. With the help of an awesome regex find out the number and update winnerScore of the bet over a chat-bot
  • Instead of /bet command usage, use chat bot's dm support to save bets

Documentation

Index

Constants

View Source
const TimeFormat = "02-01-2006"

Variables

View Source
var Months = [...]string{"january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"}

Functions

This section is empty.

Types

type BetService

type BetService interface {
	ParseRequestAndCheckToken(*http.Request) error
	StartNewBet(string) (string, error)
	EndBet(string) (string, error)
	SaveBet(string, int, string) (string, error)
	ListBets() (string, error)
	GetBetInfo(int) (string, error)
	GetBetInfoForMonth(int) (string, error)
	CalculateWhoWins(int) (string, error)
	SaveWinner(int, int) (string, error)
	GetLastEndedBetInfo() (string, error)
	ListAbsentUsers() (string, error)
	IsAuthorizedUser(string) bool
}

type Conf

type Conf struct {
	Admins            []string `json:admins`
	PostToken         string   `json:postToken`
	Channel           string   `json:channel`
	ChannelID         string   `json:channelId`
	SlashCommandToken string   `json:slashCommandToken`
	RedisUrl          string   `json:redisUrl`
	Port              string   `json:port`
}

type SlackService

type SlackService interface {
	GetChannelMembers(string) ([]string, error)
	SendCallback(string, string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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