Documentation
¶
Index ¶
- type ChannelMessageRoute
- type EventMessageAuthorization
- type EventsAPICallbackEvent
- type MentionRoute
- type Route
- type Router
- func (router Router) AddChannelMessageRoute(route ChannelMessageRoute)
- func (router Router) AddChannelMessageRoutes(routes []ChannelMessageRoute)
- func (router Router) AddMentionRoute(route MentionRoute)
- func (router Router) AddMentionRoutes(routes []MentionRoute)
- func (router Router) Can(u models.User, permissions []string) bool
- func (router Router) FindChannelMessageRouteByMessage(message string) (ChannelMessageRoute, bool)
- func (router Router) FindChannelMessageRouteByName(name string) (ChannelMessageRoute, bool)
- func (router Router) FindMentionRouteByMessage(message string) (MentionRoute, bool)
- func (router Router) FindMentionRouteByName(name string) (MentionRoute, bool)
- func (router Router) SetupDb()
- func (r *Router) UpdateBotUID(body []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelMessageRoute ¶ added in v0.2.1
type ChannelMessageRoute struct { Route Plugin func(router Router, route Route, api slack.Client, ev slackevents.MessageEvent, message string) }
ChannelMessageRoute handles the `message.channels` Event
func (ChannelMessageRoute) Execute ¶ added in v0.2.1
func (route ChannelMessageRoute) Execute(api slack.Client, router Router, ev slackevents.MessageEvent, message string)
Execute calls Plugin()
type EventMessageAuthorization ¶ added in v0.2.1
type EventsAPICallbackEvent ¶ added in v0.2.1
type EventsAPICallbackEvent struct { Type string `json:"type"` Token string `json:"token"` TeamID string `json:"team_id"` APIAppID string `json:"api_app_id"` Authoritzations []EventMessageAuthorization `json:"authorizations"` EventID string `json:"event_id"` EventTime int `json:"event_time"` EventContext string `json:"event_context"` }
this is required because slack-go doesn't seem to provide a way to get the bot's own ID
type MentionRoute ¶
type MentionRoute struct { Route 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 Plugin()
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 ChannelMessageRoutes map[string]ChannelMessageRoute DefaultMentionRoute MentionRoute DeniedMentionRoute MentionRoute DbConnection *gorm.DB BotUID string }
Router the HTTP router which handles Events from Slack
func (Router) AddChannelMessageRoute ¶ added in v0.2.1
func (router Router) AddChannelMessageRoute(route ChannelMessageRoute)
AddChannelMessageRoute sets the key for ChannelMessages key to route.Name and it's value to route
func (Router) AddChannelMessageRoutes ¶ added in v0.2.1
func (router Router) AddChannelMessageRoutes(routes []ChannelMessageRoute)
AddChannelMessageRoutes same as AddChannelMessageRoute but plural
func (Router) AddMentionRoute ¶
func (router Router) AddMentionRoute(route MentionRoute)
AddMentionRoute sets upserts and element into `MentionRoutes` whose key is the provided `Name` field
func (Router) AddMentionRoutes ¶
func (router Router) AddMentionRoutes(routes []MentionRoute)
AddMentionRoutes calls `AddMentionRoute()` for each element in `routes`
func (Router) FindChannelMessageRouteByMessage ¶ added in v0.2.1
func (router Router) FindChannelMessageRouteByMessage(message string) (ChannelMessageRoute, bool)
FindChannelMessageRouteByMessage Returns the ChannelMessageRoute that matches the provided message
func (Router) FindChannelMessageRouteByName ¶ added in v0.2.1
func (router Router) FindChannelMessageRouteByName(name string) (ChannelMessageRoute, bool)
FindChannelMessageRouteByName looks up and return the ChannelMessageRoute by the provided Name field value
func (Router) FindMentionRouteByMessage ¶
func (router Router) FindMentionRouteByMessage(message string) (MentionRoute, bool)
FindMentionRouteByMessage Returns the route to execute based on the first matched Route.Pattern.
func (Router) FindMentionRouteByName ¶
func (router Router) FindMentionRouteByName(name string) (MentionRoute, bool)
FindMentionRouteByName Returns the named mention route
func (*Router) UpdateBotUID ¶ added in v0.2.1
UpdateUID sets the UID field from an event body. Only updates if currently empty