controller

package
v0.0.0-...-d726a1a Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

The controller package implements the Team type.

Index

Constants

View Source
const ConfTurnOffModule = "off"

Variables

This section is empty.

Functions

func MigrateModuleConfig

func MigrateModuleConfig(c *database.Conn) error

Types

type AllProtectedModuleConfig

type AllProtectedModuleConfig struct {
	*DBModuleConfig
}

func (AllProtectedModuleConfig) GetIsDefaultNotProtected

func (c AllProtectedModuleConfig) GetIsDefaultNotProtected(key string) (string, bool, error)

type DBModuleConfig

type DBModuleConfig struct {
	ModuleIdentifier marvin.ModuleID

	// All writes to the maps must happen during the Load() phase.
	// DefaultsLocked is set afterwards, in single-thread code.
	DefaultsLocked bool
	// contains filtered or unexported fields
}

func (*DBModuleConfig) Add

func (c *DBModuleConfig) Add(key string, defaultValue string)

func (*DBModuleConfig) AddProtect

func (c *DBModuleConfig) AddProtect(key string, defaultValue string, protect bool)

func (*DBModuleConfig) Get

func (c *DBModuleConfig) Get(key string) (string, error)

func (*DBModuleConfig) GetIsDefault

func (c *DBModuleConfig) GetIsDefault(key string) (string, bool, error)

GetIsDefault gets a module configuration value, but does not require the key have been initialized.

1) If the key was not initialized with Add(), value is the empty string, isDefault is true, and err is ErrConfNoDefault. 2) If the key was initialized, but has no override, value is the default value, isDefault is true, and err is nil. 3) If the key has an override, value is the override, isDefault is false, and err is nil.

implements marvin.ModuleConfig.GetIsDefault

func (*DBModuleConfig) GetIsDefaultNotProtected

func (c *DBModuleConfig) GetIsDefaultNotProtected(key string) (string, bool, error)

func (*DBModuleConfig) ListDefaults

func (c *DBModuleConfig) ListDefaults() map[string]string

func (*DBModuleConfig) ListProtected

func (c *DBModuleConfig) ListProtected() map[string]bool

func (*DBModuleConfig) LockDefaults

func (c *DBModuleConfig) LockDefaults()

func (*DBModuleConfig) OnModify

func (c *DBModuleConfig) OnModify(f func(key string))

func (*DBModuleConfig) Set

func (c *DBModuleConfig) Set(key, value string) error

func (*DBModuleConfig) SetDefault

func (c *DBModuleConfig) SetDefault(key string) error

type Team

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

func NewTeam

func NewTeam(cfg *marvin.TeamConfig) (*Team, error)

func (*Team) AbsoluteURL

func (t *Team) AbsoluteURL(path string) string

MakeURL takes a (non-rooted) path to the webserver and makes it absolute.

func (*Team) ArchiveURL

func (t *Team) ArchiveURL(msgID slack.MessageID) string

func (*Team) BotUser

func (t *Team) BotUser() slack.UserID

func (*Team) ChannelIDByName

func (t *Team) ChannelIDByName(chName string) slack.ChannelID

func (*Team) ChannelMemberCount

func (t *Team) ChannelMemberCount(channel slack.ChannelID) int

func (*Team) ChannelMemberList

func (t *Team) ChannelMemberList(channel slack.ChannelID) []slack.UserID

func (*Team) ChannelName

func (t *Team) ChannelName(channel slack.ChannelID) string

func (*Team) ConnectHTTP

func (t *Team) ConnectHTTP(l net.Listener)

func (*Team) ConnectRTM

func (t *Team) ConnectRTM(c *rtm.Client)

func (*Team) DB

func (t *Team) DB() *database.Conn

func (*Team) DependModule

func (t *Team) DependModule(self marvin.Module, dependID marvin.ModuleID, ptr *marvin.Module) int

DependModule places the instance of the requested module in the given pointer.

If the requested module is already enabled, the pointer is filled immediately and the function returns 1. If the requested module has errored, the pointer is left along and the function returns -2. During loading, when the requested module has not been enabled yet, the function returns 0 and remembers the pointer. If the requested module is not known, the function returns -1.

func (*Team) DisableModule

func (t *Team) DisableModule(ident marvin.ModuleID) error

func (*Team) DispatchCommand

func (t *Team) DispatchCommand(args *marvin.CommandArguments) marvin.CommandResult

func (*Team) Domain

func (t *Team) Domain() string

func (*Team) EnableModule

func (t *Team) EnableModule(ident marvin.ModuleID) error

func (*Team) EnableModules

func (t *Team) EnableModules() bool

func (*Team) FormatChannel

func (t *Team) FormatChannel(channel slack.ChannelID) string

func (*Team) GetAllEnabledModules

func (t *Team) GetAllEnabledModules() []marvin.ModuleStatus

func (*Team) GetAllModules

func (t *Team) GetAllModules() []marvin.ModuleStatus

func (*Team) GetIM

func (t *Team) GetIM(user slack.UserID) (slack.ChannelID, error)

func (*Team) GetIMOtherUser

func (t *Team) GetIMOtherUser(im slack.ChannelID) (slack.UserID, error)

func (*Team) GetModule

func (t *Team) GetModule(ident marvin.ModuleID) marvin.Module

func (*Team) GetModuleStatus

func (t *Team) GetModuleStatus(ident marvin.ModuleID) marvin.ModuleStatus

func (*Team) GetRTMClient

func (t *Team) GetRTMClient() interface{}

func (*Team) HTTPMiddleware

func (t *Team) HTTPMiddleware(f func(http.Handler) http.Handler)

func (*Team) HandleHTTP

func (t *Team) HandleHTTP(folder string, handler http.Handler) *mux.Route

HandleHTTP must be called as follows:

team.HandleHTTP("/links/", module)

func (*Team) Help

func (*Team) ModuleConfig

func (t *Team) ModuleConfig(ident marvin.ModuleID) marvin.ModuleConfig

func (*Team) ModuleConfigList

func (t *Team) ModuleConfigList() []marvin.ModuleID

func (*Team) OffAllEvents

func (t *Team) OffAllEvents(mod marvin.ModuleID)

func (*Team) OnEvent

func (t *Team) OnEvent(mod marvin.ModuleID, event string, f func(slack.RTMRawMessage))

func (*Team) OnEveryEvent

func (t *Team) OnEveryEvent(mod marvin.ModuleID, f func(slack.RTMRawMessage))

func (*Team) OnNormalMessage

func (t *Team) OnNormalMessage(mod marvin.ModuleID, f func(slack.RTMRawMessage))

func (*Team) OnSpecialMessage

func (t *Team) OnSpecialMessage(mod marvin.ModuleID, msgSubtype []string, f func(slack.RTMRawMessage))

func (*Team) PrivateChannelInfo

func (t *Team) PrivateChannelInfo(channel slack.ChannelID) (*slack.Channel, error)

func (*Team) PublicChannelInfo

func (t *Team) PublicChannelInfo(channel slack.ChannelID) (*slack.Channel, error)

func (*Team) ReactMessage

func (t *Team) ReactMessage(msgID slack.MessageID, emojiName string) error

func (*Team) RegisterCommand

func (t *Team) RegisterCommand(name string, c marvin.SubCommand)

func (*Team) RegisterCommandFunc

func (t *Team) RegisterCommandFunc(name string, c marvin.SubCommandFunc, help string) marvin.SubCommand

func (*Team) ReportError

func (t *Team) ReportError(err error, source marvin.ActionSource)

func (*Team) ResolveChannelName

func (t *Team) ResolveChannelName(input string) slack.ChannelID

func (*Team) ResolveUserName

func (t *Team) ResolveUserName(input string) slack.UserID

func (*Team) Router

func (t *Team) Router() *mux.Router

func (*Team) SendComplexMessage

func (t *Team) SendComplexMessage(channelID slack.ChannelID, message slack.OutgoingSlackMessage) (slack.MessageTS, slack.RTMRawMessage, error)

func (*Team) SendMessage

func (t *Team) SendMessage(channel slack.ChannelID, message string) (slack.MessageTS, slack.RTMRawMessage, error)

func (*Team) Shutdown

func (t *Team) Shutdown()

func (*Team) SlackAPIPostJSON

func (t *Team) SlackAPIPostJSON(method string, form url.Values, result interface{}) error

func (*Team) SlackAPIPostRaw

func (t *Team) SlackAPIPostRaw(method string, form url.Values) (*http.Response, error)

func (*Team) TeamConfig

func (t *Team) TeamConfig() *marvin.TeamConfig

func (*Team) TeamID

func (t *Team) TeamID() slack.TeamID

func (*Team) UnregisterCommand

func (t *Team) UnregisterCommand(name string)

func (*Team) UserInChannels

func (t *Team) UserInChannels(user slack.UserID, channels ...slack.ChannelID) map[slack.ChannelID]bool

func (*Team) UserInfo

func (t *Team) UserInfo(user slack.UserID) (*slack.User, error)

func (*Team) UserLevel

func (t *Team) UserLevel(user slack.UserID) marvin.AccessLevel

func (*Team) UserName

func (t *Team) UserName(user slack.UserID) string

Jump to

Keyboard shortcuts

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