repository

package
v0.0.0-...-a9e5fbf Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BotTableName DB table name for bots.
	BotTableName = "Bots"

	// ChannelTableName DB table name for channels.
	ChannelTableName = "Channels"

	// PluginDataTableName DB table name for plugin data
	PluginDataTableName = "PluginData"
)

Variables

View Source
var (
	// ErrCommandNotFound when command name is not found in channelMap
	ErrCommandNotFound = errors.New("Command name is not found")

	// ErrCommandAlreadyExists when a duplicate command name is added
	ErrCommandAlreadyExists = errors.New("Command name already exists")

	// ErrChannelNotFound when an accessed channel is not found
	ErrChannelNotFound = errors.New("Channel is not found")

	// ErrChannelAlreadyExists when a duplicate channel is added
	ErrChannelAlreadyExists = errors.New("Channel already exists")

	// ErrBotAlreadyExists when a duplicate bot is added
	ErrBotAlreadyExists = errors.New("Bot already exists")

	// ErrBotAlreadyInChannel when a bot tries to join a channel where it already is
	ErrBotAlreadyInChannel = errors.New("Bot is already running in the channel")
)

Functions

This section is empty.

Types

type BaseRepository

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

BaseRepository is the base repository of all repository structs. All other repository struct should have a reference to this base repository.

func NewBaseRepository

func NewBaseRepository() *BaseRepository

NewBaseRepository creates a new base reposiroty from flag values

func NewBaseRepositoryCustomDB

func NewBaseRepositoryCustomDB(db *dynamo.DB) *BaseRepository

NewBaseRepositoryCustomDB creates a new base repository from custom DynamoDB struct

func (*BaseRepository) AddBotToChannel

func (repo *BaseRepository) AddBotToChannel(botInfo *models.Bot, channelToAdd *models.Channel) error

AddBotToChannel adds the bot to the channel. It assumes that the bot is not already running in the channel. TODO: needs testing TODO: This doesn't update channelMap

func (*BaseRepository) AddCommand

func (repo *BaseRepository) AddCommand(channel string, commandToAdd *models.Command) error

AddCommand adds a new command

func (*BaseRepository) CreateNewBot

func (repo *BaseRepository) CreateNewBot(botInfo *models.Bot) error

CreateNewBot adds a new bot to DynamoDB. The function assumes that bot with the same key (TwitchID) does not already exist

func (*BaseRepository) CreateNewChannel

func (repo *BaseRepository) CreateNewChannel(channelToAdd *models.Channel) error

CreateNewChannel adds a new channel to DynamoDB. The function assumes that channel with the same key (TwitchID) does not already exist

func (*BaseRepository) DeleteCommand

func (repo *BaseRepository) DeleteCommand(channel string, commandToDelete *models.Command) error

DeleteCommand deletes an existing command

func (*BaseRepository) EditCommand

func (repo *BaseRepository) EditCommand(channel string, commandToEdit *models.Command) error

EditCommand edits an existing command

func (*BaseRepository) GetAllBots

func (repo *BaseRepository) GetAllBots() []*models.Bot

GetAllBots returns all Bot models in the database.

func (*BaseRepository) GetAllChannels

func (repo *BaseRepository) GetAllChannels() []*models.Channel

GetAllChannels returns all Channel models in the database.

func (*BaseRepository) GetAllChannelsForBot

func (repo *BaseRepository) GetAllChannelsForBot(botID int64) []*models.Channel

GetAllChannelsForBot returns all channels for this bot.

func (*BaseRepository) GetCommand

func (repo *BaseRepository) GetCommand(botID int64, channel string, commandName string) *models.Command

GetCommand gets command by unique combination of (botID, channel, commandName) returns nil if command does not exist with the combination

func (*BaseRepository) ListCommands

func (repo *BaseRepository) ListCommands(channel string) ([]*models.Command, error)

ListCommands lists commands

type BaseRepositoryT

type BaseRepositoryT interface {
	GetAllBots() []*models.Bot
	GetAllChannels() []*models.Channel
	GetAllChannelsForBot(botID int64) []*models.Channel
	GetCommand(botID int64, channel string, commandName string) *models.Command
	CreateNewBot(botInfo *models.Bot) error
	CreateNewChannel(chanInfo *models.Channel) error
	AddBotToChannel(botInfo *models.Bot, channelToAdd *models.Channel) error
	AddCommand(channel string, commandToAdd *models.Command) error
	EditCommand(channel string, commandToEdit *models.Command) error
	DeleteCommand(channel string, commandToDelete *models.Command) error
	ListCommands(channel string) ([]*models.Command, error)
}

BaseRepositoryT interface to deal with persistent data

type SingleBotRepository

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

SingleBotRepository repository for a single bot

func NewSingleBotRepository

func NewSingleBotRepository(botInfo *models.Bot, baseRepo BaseRepositoryT) *SingleBotRepository

NewSingleBotRepository creates a new single bor repository with given bot and base repo.

func (*SingleBotRepository) AddCommand

func (repo *SingleBotRepository) AddCommand(channel string, command *models.Command) error

AddCommand adds command.

func (*SingleBotRepository) DeleteCommand

func (repo *SingleBotRepository) DeleteCommand(channel string, command *models.Command) error

DeleteCommand deletes command

func (*SingleBotRepository) EditCommand

func (repo *SingleBotRepository) EditCommand(channel string, command *models.Command) error

EditCommand edits command

func (*SingleBotRepository) GetAllChannels

func (repo *SingleBotRepository) GetAllChannels() []*models.Channel

GetAllChannels returns all channels for this bot.

func (*SingleBotRepository) GetBotInfo

func (repo *SingleBotRepository) GetBotInfo() *models.Bot

GetBotInfo returns bot model struct

func (*SingleBotRepository) GetCommandByChannelAndName

func (repo *SingleBotRepository) GetCommandByChannelAndName(
	channel string, commandName string) *models.Command

GetCommandByChannelAndName gets commands by channel name and command name

func (*SingleBotRepository) ListCommands

func (repo *SingleBotRepository) ListCommands(channel string) ([]*models.Command, error)

ListCommands lists command TODO: Eventually, point this to a web page

type SingleBotRepositoryT

type SingleBotRepositoryT interface {
	GetBotInfo() *models.Bot
	GetAllChannels() []*models.Channel
	GetCommandByChannelAndName(channel string, commandName string) *models.Command
	AddCommand(channel string, command *models.Command) error
	EditCommand(channel string, command *models.Command) error
	DeleteCommand(channel string, command *models.Command) error
	ListCommands(channel string) ([]*models.Command, error)
}

SingleBotRepositoryT interface for single bot repository

type SingleChannelRepository

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

SingleChannelRepository repo for a single channel

func (*SingleChannelRepository) GetAllBots

func (repo *SingleChannelRepository) GetAllBots() []int64

GetAllBots returns all bots for this channel

type SingleChannelRepositoryT

type SingleChannelRepositoryT interface {
	GetAllBots() []int64
}

SingleChannelRepositoryT repository for a single channel

Directories

Path Synopsis
Package mock_repository is a generated GoMock package.
Package mock_repository is a generated GoMock package.

Jump to

Keyboard shortcuts

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