pub struct SlackPlugin { /* private fields */ }Expand description
Slack plugin.
autumn_web::app()
.plugin(
SlackPlugin::new()
.on_event("app_mention", on_mention)
.command("/deploy", deploy),
)
.run()
.await;Implementations§
Source§impl SlackPlugin
impl SlackPlugin
Sourcepub fn with_config(config: SlackConfig) -> Self
pub fn with_config(config: SlackConfig) -> Self
Makes the plugin with this config. It reads no files.
Sourcepub fn base_path(self, path: &str) -> Self
pub fn base_path(self, path: &str) -> Self
Sets the base path of the routes. Default: /slack.
autumn mounts routes before it loads config. So this is a builder setting, not a config key.
Sourcepub const fn readiness(self, on: bool) -> Self
pub const fn readiness(self, on: bool) -> Self
Puts the health indicator in /ready too. Default: only in
/actuator/health.
Sourcepub fn with_signing_secret(self, secret: impl Into<String>) -> Self
pub fn with_signing_secret(self, secret: impl Into<String>) -> Self
Uses this signing secret, not the env var.
Sourcepub fn with_previous_signing_secret(self, secret: impl Into<String>) -> Self
pub fn with_previous_signing_secret(self, secret: impl Into<String>) -> Self
Also accepts this old signing secret. Use during rotation.
Sourcepub fn with_bot_token(self, token: impl Into<String>) -> Self
pub fn with_bot_token(self, token: impl Into<String>) -> Self
Uses this bot token, not the env var.
Sourcepub fn with_transport(self, transport: impl HttpTransport) -> Self
pub fn with_transport(self, transport: impl HttpTransport) -> Self
Uses this transport. Default: crate::transport::ReqwestTransport.
Sourcepub fn with_transport_arc(self, transport: Arc<dyn HttpTransport>) -> Self
pub fn with_transport_arc(self, transport: Arc<dyn HttpTransport>) -> Self
Uses this shared transport.
Sourcepub fn with_clock(self, clock: Arc<dyn ClockSource>) -> Self
pub fn with_clock(self, clock: Arc<dyn ClockSource>) -> Self
Uses this clock for the timestamp check. Default: the system clock.
Sourcepub fn with_replay_store(self, store: Arc<dyn WebhookReplayStore>) -> Self
pub fn with_replay_store(self, store: Arc<dyn WebhookReplayStore>) -> Self
Uses this store to drop event retries. Default: in memory, per process. Use a Redis store for many replicas.
Sourcepub fn on_event<F, Fut>(self, event_type: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, EventCallback) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<()>> + Send + 'static,
pub fn on_event<F, Fut>(self, event_type: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, EventCallback) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<()>> + Send + 'static,
Runs handler for Events API events of event_type, after the ack.
Sourcepub fn command<F, Fut>(self, name: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, SlashCommand) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<CommandResponse>> + Send + 'static,
pub fn command<F, Fut>(self, name: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, SlashCommand) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<CommandResponse>> + Send + 'static,
Runs handler for the slash command name, for example /deploy.
Sourcepub fn action<F, Fut>(self, action_id: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, BlockAction) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<Option<Message>>> + Send + 'static,
pub fn action<F, Fut>(self, action_id: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, BlockAction) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<Option<Message>>> + Send + 'static,
Runs handler for a block action with this action_id, after the
ack. A returned message goes to the response_url.
Sourcepub fn view_submission<F, Fut>(self, callback_id: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, ViewPayload) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<ViewResponse>> + Send + 'static,
pub fn view_submission<F, Fut>(self, callback_id: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, ViewPayload) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<ViewResponse>> + Send + 'static,
Runs handler for a modal submit with this callback_id.
Sourcepub fn view_closed<F, Fut>(self, callback_id: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, ViewPayload) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<()>> + Send + 'static,
pub fn view_closed<F, Fut>(self, callback_id: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, ViewPayload) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<()>> + Send + 'static,
Runs handler when a user closes a modal with this callback_id.
The modal must set notify_on_close.
Sourcepub fn shortcut<F, Fut>(self, callback_id: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, Shortcut) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<()>> + Send + 'static,
pub fn shortcut<F, Fut>(self, callback_id: &str, handler: F) -> Selfwhere
F: Fn(SlackContext, Shortcut) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HandlerResult<()>> + Send + 'static,
Runs handler for a global or message shortcut with this
callback_id, after the ack.
Sourcepub fn metrics(&self) -> Arc<SlackMetrics> ⓘ
pub fn metrics(&self) -> Arc<SlackMetrics> ⓘ
The metrics. They are shared with the started runtime.
Sourcepub fn start(self, state: &AppState) -> Result<SlackRuntime, SlackError>
pub fn start(self, state: &AppState) -> Result<SlackRuntime, SlackError>
Starts the plugin outside an app build. Use it in tests, with
SlackRuntime::router. Plugin::build does the same at startup.
§Errors
Returns a config error.
Sourcepub fn start_with_role(
self,
state: &AppState,
role: impl Into<Role>,
) -> Result<SlackRuntime, SlackError>
pub fn start_with_role( self, state: &AppState, role: impl Into<Role>, ) -> Result<SlackRuntime, SlackError>
Starts the plugin as if the process has role. A role that serves no
HTTP (worker, or a preset without HTTP) needs no signing secret and
no CSRF exemption. A ProcessRole converts into a Role.
§Errors
Same as Self::start.
Trait Implementations§
Source§impl Debug for SlackPlugin
impl Debug for SlackPlugin
Source§impl Default for SlackPlugin
impl Default for SlackPlugin
Source§impl Plugin for SlackPlugin
impl Plugin for SlackPlugin
Source§fn name(&self) -> Cow<'static, str>
fn name(&self) -> Cow<'static, str>
Source§fn contract(&self) -> Option<PluginContract>
fn contract(&self) -> Option<PluginContract>
autumn-web versions this plugin supports, and any
experimental surface it knowingly depends on. Read moreSource§fn build(self, app: AppBuilder) -> AppBuilder
fn build(self, app: AppBuilder) -> AppBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for SlackPlugin
impl !UnwindSafe for SlackPlugin
impl Forget for SlackPlugin
impl Freeze for SlackPlugin
impl Send for SlackPlugin
impl Sync for SlackPlugin
impl Unpin for SlackPlugin
impl UnsafeUnpin for SlackPlugin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<P> Plugins for Pwhere
P: Plugin,
impl<P> Plugins for Pwhere
P: Plugin,
Source§fn apply(self, app: AppBuilder) -> AppBuilder
fn apply(self, app: AppBuilder) -> AppBuilder
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.