pub struct ThreadHandle { /* private fields */ }Expand description
A scoped handle to a conversation thread.
Holds a reference to the originating adapter, the thread identifier, and the
shared subscription map so handlers can interact with the thread without
needing access to the full ChatBot.
Implementations§
Source§impl ThreadHandle
impl ThreadHandle
Sourcepub fn adapter_name(&self) -> &str
pub fn adapter_name(&self) -> &str
Return the name of the adapter backing this handle.
Sourcepub async fn post(
&self,
message: impl Into<PostableMessage>,
) -> Result<SentMessage, ChatError>
pub async fn post( &self, message: impl Into<PostableMessage>, ) -> Result<SentMessage, ChatError>
Post a message to this thread.
For PostableMessage::Text and PostableMessage::Markdown, the message
is forwarded to the adapter via ChatAdapter::post_message.
§Errors
Returns an error if the adapter fails to post.
Sourcepub async fn post_ephemeral(
&self,
user_id: &str,
message: impl Into<AdapterPostableMessage>,
fallback_to_dm: bool,
) -> Result<Option<EphemeralMessage>, ChatError>
pub async fn post_ephemeral( &self, user_id: &str, message: impl Into<AdapterPostableMessage>, fallback_to_dm: bool, ) -> Result<Option<EphemeralMessage>, ChatError>
Post an ephemeral message visible only to the specified user.
If the adapter does not support ephemeral messages and
fallback_to_dm is true, falls back to opening a direct-message
channel with the user and posting there.
§Errors
Returns an error if both the ephemeral post and DM fallback fail.
Sourcepub async fn subscribe(&self)
pub async fn subscribe(&self)
Subscribe to follow-up messages in this thread.
Subsequent ChatEvent::Message events for this thread will be
routed to on_subscribed_message handlers instead of on_message.
Sourcepub async fn unsubscribe(&self)
pub async fn unsubscribe(&self)
Unsubscribe from this thread.
Sourcepub fn mention_user(&self, user_id: &str) -> String
pub fn mention_user(&self, user_id: &str) -> String
Format a platform-agnostic mention string for a user.
This is a simple helper that returns <@user_id>. Adapters that
need a different format should handle it at the rendering layer.