common

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AttachmentTypeUnknown = ""
	AttachmentTypeText    = "text"
	AttachmentTypeImage   = "image"
	AttachmentTypeFile    = "file"
)
View Source
const (
	FileTypeUnknown = ""
	FileTypeText    = "text"
	FileTypeImage   = "image"
)
View Source
const (
	FieldTypeUnknown            = ""
	FieldTypeEdit               = "edit"
	FieldTypeMultiEdit          = "multiedit"
	FieldTypeInteger            = "integer"
	FieldTypeFloat              = "float"
	FieldTypeURL                = "url"
	FieldTypeDate               = "date"
	FieldTypeTime               = "time"
	FieldTypeSelect             = "select"
	FieldTypeMultiSelect        = "multiselect"
	FieldTypeDynamicSelect      = "dynamicselect"
	FieldTypeDynamicMultiSelect = "dynamicmultiselect"
	FieldTypeBool               = "bool"
)

Variables

This section is empty.

Functions

func GetStringKeys added in v0.1.1

func GetStringKeys(arr map[string]interface{}) []string

func IfDef added in v0.3.7

func IfDef(cond bool, v1, v2 interface{}) interface{}

func LoadTemplate

func LoadTemplate(name, tmpl string) (*template.Template, error)

func LoadYaml

func LoadYaml(config string, obj interface{}) (bool, error)

func MergeInterfaceMaps added in v0.3.4

func MergeInterfaceMaps(maps ...map[string]interface{}) map[string]interface{}

func RemoveEmptyStrings added in v0.0.3

func RemoveEmptyStrings(items []string) []string

func Render added in v0.5.0

func Render(def string, obj interface{}, observability *Observability) string

func RenderTemplate added in v0.5.0

func RenderTemplate(tpl *toolsRender.TextTemplate, def string, obj interface{}) (string, error)

Types

type Approval added in v0.6.2

type Approval interface {
	Channel() string
	Message(bot Bot, message Message, params ExecuteParams) string
}

type Attachment

type Attachment struct {
	Title string
	Text  string
	Data  []byte
	Type  AttachmentType
}

type AttachmentType added in v0.0.2

type AttachmentType string

type Bot

type Bot interface {
	Start(wg *sync.WaitGroup)
	Name() string
	Command(channel, text string, user User, parent Message, response Response) error
	Post(channel string, message string, attachments []*Attachment, user User, parent Message, response Response) error
	Delete(channel, message string) error
	AddReaction(channel, message, name string) error
}

type Bots

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

func NewBots

func NewBots() *Bots

func (*Bots) Add

func (bs *Bots) Add(b Bot)

func (*Bots) Start

func (bs *Bots) Start(wg *sync.WaitGroup)

type Channel added in v0.2.0

type Channel interface {
	ID() string
}

type Command

type Command interface {
	Name() string
	Description() string
	Params() []string
	Aliases() []string
	Confirmation() string
	Priority() int
	Wrapper() bool
	Schedule() string
	Channel() string
	Response() Response
	Execute(bot Bot, message Message, params ExecuteParams) (Executor, string, []*Attachment, error)
	Fields(bot Bot, message Message, only []string) []Field
	Approval() Approval
}

type ExecuteParams

type ExecuteParams = map[string]interface{}

type Executor added in v0.2.0

type Executor interface {
	Response() Response
	After(message Message) error
}

type Field added in v0.1.0

type Field struct {
	Name     string
	Type     FieldType
	Label    string
	Default  string
	Hint     string
	Required bool
	Values   []string
	Template string
}

type FieldType added in v0.1.0

type FieldType string

type Message added in v0.2.0

type Message interface {
	ID() string
	Visible() bool
	User() User
	Channel() Channel
	ParentID() string
}

type Observability

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

func NewObservability

func NewObservability(logs *sre.Logs, metrics *sre.Metrics) *Observability

func (*Observability) Debug

func (o *Observability) Debug(obj interface{}, args ...interface{})

func (*Observability) Error

func (o *Observability) Error(obj interface{}, args ...interface{})

func (*Observability) Info

func (o *Observability) Info(obj interface{}, args ...interface{})

func (*Observability) Logs

func (o *Observability) Logs() *sre.Logs

func (*Observability) Metrics

func (o *Observability) Metrics() *sre.Metrics

func (*Observability) Warn

func (o *Observability) Warn(obj interface{}, args ...interface{})

type Processor

type Processor interface {
	Name() string
	Commands() []Command
}

type Processors

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

func NewProcessors

func NewProcessors() *Processors

func (*Processors) Add

func (ps *Processors) Add(p Processor)

func (*Processors) AddList

func (ps *Processors) AddList(list []Processor)

func (*Processors) Exists added in v0.5.0

func (ps *Processors) Exists(processor string) bool

func (*Processors) FindCommand added in v0.5.0

func (ps *Processors) FindCommand(processor, command string) Command

func (*Processors) FindCommandByAlias added in v0.5.1

func (ps *Processors) FindCommandByAlias(alias string) (string, Command)

func (*Processors) Items

func (ps *Processors) Items() []Processor

type Response added in v0.1.0

type Response interface {
	Visible() bool  // visible for others, not only you
	Duration() bool // show duration in replay
	Original() bool // show orignal as quote
	Error() bool    // show as error
}

type User

type User interface {
	ID() string
	Name() string
	TimeZone() string
}

Jump to

Keyboard shortcuts

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