app

package
v0.0.0-...-b38937d Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryBool

func QueryBool(c echo.Context, name string) bool

QueryBool retrieves a boolean param from the gin request querystring

func QueryDefaultInteger

func QueryDefaultInteger(c echo.Context, name string, def int) (int, error)

QueryDefaultInt retrieves an integer param from the gin request querystring defaults to def argument if not found

func QueryInt

func QueryInt(c echo.Context, name string) int

QueryInt retrieves an integer param from the gin request querystring

func QueryString

func QueryString(c echo.Context, name string) string

QueryString retrieves a string param from the gin request querystring

func Setup

func Setup() error

func Start

func Start() error

func WithTimeout

func WithTimeout(delegate func() interface{}, timeout time.Duration) (ret interface{}, ok bool)

WithTimeout runs a delegate function with a timeout,

Example: Wait for a channel

if value, ok := WithTimeout(func()interface{}{return <- inbox}, time.Second); ok {
    // returned
} else {
    // didn't return
}

Example: To send to a channel

_, ok := WithTimeout(func()interface{}{outbox <- myValue; return nil}, time.Second)
if !ok {
    // didn't send
}

Types

type Application

type Application struct {
	Config *Config
	Log    *zap.SugaredLogger

	//golem:template:app/app_partial_definitions
	// DO NOT EDIT. This section is managed by github.com/dashotv/golem.
	// Models
	DB *Connector

	Bot *Bot
}

func (*Application) Health

func (a *Application) Health() (map[string]bool, error)

type Bot

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

func NewBot

func NewBot(token, helpText string, log *zap.SugaredLogger) (*Bot, error)

func (*Bot) Start

func (b *Bot) Start(ctx context.Context) error

type Channels

type Channels struct {
	grimoire.Document `bson:",inline"` // includes default model settings
	//ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	//CreatedAt time.Time          `bson:"created_at" json:"created_at"`
	//UpdatedAt time.Time          `bson:"updated_at" json:"updated_at"`
	GuildId   string `bson:"guild_id" json:"guild_id"`
	ChannelId string `bson:"channel_id" json:"channel_id"`
	Name      string `bson:"name" json:"name"`
}

type Config

type Config struct {
	Mode   string `env:"MODE" envDefault:"dev"`
	Logger string `env:"LOGGER" envDefault:"dev"`
	Port   int    `env:"PORT" envDefault:"9999"`

	Token    string `env:"TOKEN" required:"true"`
	HelpText string

	//golem:template:app/config_partial_struct
	// DO NOT EDIT. This section is managed by github.com/dashotv/golem.
	// Models (Database)
	Connections ConnectionSet `env:"CONNECTIONS"`
}

func (*Config) ConnectionFor

func (c *Config) ConnectionFor(name string) (*Connection, error)

func (*Config) Validate

func (c *Config) Validate() error

type Connection

type Connection struct {
	URI        string `yaml:"uri,omitempty"`
	Database   string `yaml:"database,omitempty"`
	Collection string `yaml:"collection,omitempty"`
}

func (*Connection) UnmarshalText

func (c *Connection) UnmarshalText(text []byte) error

type ConnectionSet

type ConnectionSet map[string]*Connection

func (*ConnectionSet) UnmarshalText

func (c *ConnectionSet) UnmarshalText(text []byte) error

type Connector

type Connector struct {
	Log      *zap.SugaredLogger
	Channels *grimoire.Store[*Channels]
	Watches  *grimoire.Store[*Watches]
}

func NewConnector

func NewConnector(app *Application) (*Connector, error)

func (*Connector) ChannelsByChannelID

func (c *Connector) ChannelsByChannelID(channel_id string) (*Channels, error)

func (*Connector) ChannelsCreateUpdate

func (c *Connector) ChannelsCreateUpdate(channel_id, channel_name, guild_id string) error

func (*Connector) ChannelsDelete

func (c *Connector) ChannelsDelete(channel_id string) error

func (*Connector) ChannelsGet

func (c *Connector) ChannelsGet(id string) (*Channels, error)

func (*Connector) ChannelsList

func (c *Connector) ChannelsList(guildID string) ([]*Channels, error)

func (*Connector) WatchesByUserID

func (c *Connector) WatchesByUserID(user_id string) (*Watches, error)

func (*Connector) WatchesGame

func (c *Connector) WatchesGame(user_id, game string) error

func (*Connector) WatchesGet

func (c *Connector) WatchesGet(id string) (*Watches, error)

func (*Connector) WatchesList

func (c *Connector) WatchesList() ([]*Watches, error)

func (*Connector) WatchesUnwatch

func (c *Connector) WatchesUnwatch(user_id string) error

func (*Connector) WatchesWatch

func (c *Connector) WatchesWatch(user_id, username string) error

func (*Connector) WatchesWatching

func (c *Connector) WatchesWatching(user_id string) (bool, error)

type H

type H map[string]any

stolen from gin gonic H is a shortcut for map[string]any

func (H) MarshalXML

func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML allows type H to be used with xml.Marshal.

type Watches

type Watches struct {
	grimoire.Document `bson:",inline"` // includes default model settings
	//ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	//CreatedAt time.Time          `bson:"created_at" json:"created_at"`
	//UpdatedAt time.Time          `bson:"updated_at" json:"updated_at"`
	Id        string `bson:"id" json:"id"`
	UserId    string `bson:"user_id" json:"user_id"`
	Username  string `bson:"username" json:"username"`
	GuildId   string `bson:"guild_id" json:"guild_id"`
	ChannelId string `bson:"channel_id" json:"channel_id"`
	Game      string `bson:"game" json:"game"`
}

Jump to

Keyboard shortcuts

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