Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type ClientOptDebugReconnects
- type ClientOptDialerTimeout
- type ClientOptLogLevel
- type ClientOptMaxRetries
- type ClientOptPingTimeout
- type ClientOptRetryWaitTime
- type ConnectionInfo
- type DebugInfo
- type Event
- type Handler
- type Middleware
- type OptDebugReconnects
- type OptLogLevel
- type Request
- type RequestType
- type Response
- type Router
- func (r *Router) Close() error
- func (r *Router) Handle(requestType RequestType, handler Handler, m ...Middleware)
- func (r *Router) HandleBlockAction(actionId string, handler Handler, m ...Middleware)
- func (r *Router) HandleEventsApi(eventType slackevents.EventsAPIType, handler Handler, m ...Middleware)
- func (r *Router) HandleInteractive(interactionType slack.InteractionType, handler Handler, m ...Middleware)
- func (r *Router) HandleShortcut(callbackId string, handler Handler, m ...Middleware)
- func (r *Router) HandleSlashCommand(command string, handler Handler, m ...Middleware)
- func (r *Router) Start(ctx context.Context) error
- func (r *Router) Use(m Middleware)
- type RouterOptParralel
Constants ¶
const ( RequestTypeDisconnect = "disconnect" RequestTypeHello = "hello" RequestTypeEventsAPI = "events_api" RequestTypeInteractive = "interactive" RequestTypeSlashCommands = "slash_commands" )
Variables ¶
var ( ErrPingTimeout = fmt.Errorf("timeout waiting for pings from Slack") ErrDisconnectRequest = fmt.Errorf("received disconnected request from Slack") ErrNilRequest = fmt.Errorf("received nil request") ErrUnexpectedRequestType = fmt.Errorf("unexpected Request type") ErrConnClosed = fmt.Errorf("websocket connection is closed") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Slack's API Client Api *slack.Client // contains filtered or unexported fields }
Client interacts with Slack in socketmode.
type ClientOptDebugReconnects ¶ added in v0.1.3
type ClientOptDebugReconnects struct{}
ClientOptDebugReconnects sets the `debugReconnects` flag to true
type ClientOptDialerTimeout ¶ added in v0.1.3
ClientOptDialerTimeout sets the timeout duration for the websocket dialer. 0 or negative durations are ignored.
type ClientOptLogLevel ¶ added in v0.1.3
ClientOptLogLevel sets the log level. Level should be of type `slog.Level`.
type ClientOptMaxRetries ¶ added in v0.1.3
type ClientOptMaxRetries struct {
MaxRetries int
}
ClientOptMaxRetries sets the number of times to retry connecting to Slack before giving up. 0 or negative numbers are ignored.
type ClientOptPingTimeout ¶ added in v0.1.3
ClientOptPingTimeout sets the maximum duration between pings from Slack before timing out. 0 or negative durations are ignored.
type ClientOptRetryWaitTime ¶ added in v0.1.3
ClientOptRetryWaitTime sets the duration between retries. 0 or negative durations are ignored.
type ConnectionInfo ¶
type ConnectionInfo struct {
AppId string `json:"app_id"`
}
ConnectionInfo is the `connection_info` portion of the incoming Request from Slack
type DebugInfo ¶
type DebugInfo struct { Host string `json:"host"` BuildNumber int `json:"build_number"` ApproximateConnectionTime int `json:"approximate_connection_time"` }
DebugInfo is the `debug_info` portion of the incoming Request from Slack
type Event ¶
type Event struct { Request Request Payload any Context context.Context // contains filtered or unexported fields }
Event contains the original request from Slack as well as the appropriately typed payload. It also contains a cancellable context that allows the enforcement that each Event be acknowledged at most once.
type OptDebugReconnects ¶
type OptDebugReconnects struct{}
OptDebugReconnects sets the `debugReconnects` flag to true.
type Request ¶
type Request struct { Type RequestType `json:"type"` Reason string `json:"reason"` NumConnections int `json:"num_connections"` DebugInfo DebugInfo `json:"debug_info"` ConnectionInfo ConnectionInfo `json:"connection_info"` EnvelopeId string `json:"envelope_id"` Payload json.RawMessage `json:"payload"` ResponsePayload bool `json:"response_paload"` RetryAttempt int `json:"retry_attempt"` RetryReason string `json:"retry_reason"` }
Request is the incoming request from slack
type RequestType ¶
type RequestType string
type Response ¶
type Response struct { EnvelopeId string `json:"envelope_id"` Payload json.RawMessage `json:"payload"` }
Response is what slack expects as a response. It should be called with `Ack` once.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router routes incoming requests from slack
func (*Router) Handle ¶
func (r *Router) Handle(requestType RequestType, handler Handler, m ...Middleware)
Handle registers generic handlers
func (*Router) HandleBlockAction ¶ added in v0.1.3
func (r *Router) HandleBlockAction(actionId string, handler Handler, m ...Middleware)
HandleBlockAction registers block actions handlers
func (*Router) HandleEventsApi ¶
func (r *Router) HandleEventsApi(eventType slackevents.EventsAPIType, handler Handler, m ...Middleware)
HandleEventsApi registers events api handlers
func (*Router) HandleInteractive ¶ added in v0.1.3
func (r *Router) HandleInteractive(interactionType slack.InteractionType, handler Handler, m ...Middleware)
HandleInteractive registers interactive handlers
func (*Router) HandleShortcut ¶ added in v0.1.3
func (r *Router) HandleShortcut(callbackId string, handler Handler, m ...Middleware)
HandleShortcut registers shortcuts handlers
func (*Router) HandleSlashCommand ¶
func (r *Router) HandleSlashCommand(command string, handler Handler, m ...Middleware)
HandleSlashCommand registers slash command handlers
type RouterOptParralel ¶ added in v0.1.3
type RouterOptParralel struct {
Parralel int
}
RouterOptParralel sets the number of concurrent workers for the router. This is ignored if the number is 0 or negative.