router

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MentionRoute

type MentionRoute struct {
	Route
	// Plugin func(api slack.Client, router *Router, ev slackevents.AppMentionEvent, message string)
	Plugin func(router Router, route Route, api slack.Client, ev slackevents.AppMentionEvent, message string)
}

func (MentionRoute) Execute

func (route MentionRoute) Execute(api slack.Client, router Router, ev slackevents.AppMentionEvent, message string)

Execute calls the Plugin function provided

type Route

type Route struct {
	Name        string
	Pattern     string
	Description string
	Help        string
	Permissions []string
	Priority    int
}

Route The primary type used by event specific routes

type Router

type Router struct {
	MentionRoutes       map[string]MentionRoute
	DefaultMentionRoute MentionRoute
	DeniedMentionRoute  MentionRoute
	DbConnection        *gorm.DB
}

Router the HTTP router which handles Events from Slack

func NewRouter

func NewRouter() *Router

NewRouter returns a new Router

func (Router) AddMentionRoute

func (router Router) AddMentionRoute(route MentionRoute)

func (Router) AddMentionRoutes

func (router Router) AddMentionRoutes(routes []MentionRoute)

func (Router) Can

func (router Router) Can(u models.User, permissions []string) bool

Can Returns true if `u` possesses the provided permissions

func (Router) FindMentionRouteByMessage

func (router Router) FindMentionRouteByMessage(message string) (MentionRoute, bool)

Find MentionRouteByMessage Returns the route to execute based on the first matched Route.Pattern.

func (Router) FindMentionRouteByName

func (router Router) FindMentionRouteByName(name string) (MentionRoute, bool)

Find MentionRouteByName Returns the named mention route

func (Router) SetupDb

func (router Router) SetupDb()

SetupDb migrates the shcemas

Jump to

Keyboard shortcuts

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