ArchiveBot

Struct ArchiveBot 

Source
pub struct ArchiveBot {
    pub token: String,
    pub notification_channel_id: String,
    pub filter_prefixes: Vec<&'static str>,
    pub message_headers: Vec<&'static str>,
    pub stale_after: u32,
    pub small_channel_threshold: u16,
    pub notify_secondary_channel: bool,
    pub secondary_notification_channel_id: String,
    pub secondary_message_headers: Vec<&'static str>,
}
Expand description

Archive bot.

Fields§

§token: String

Slack bot token.

§notification_channel_id: String

Channel id to send notifications.

§filter_prefixes: Vec<&'static str>

Vector of channel prefixes to filter out of results.

§message_headers: Vec<&'static str>

Vector of messages to send (one at random) at beginning of updates.

§stale_after: u32

How long until a channel is stale (in seconds).

§small_channel_threshold: u16

The threshold <= channels are considered “small”.

§notify_secondary_channel: bool

Whether to notify a secondary channel of updates (such as #general).

§secondary_notification_channel_id: String

Secondary channel id.

§secondary_message_headers: Vec<&'static str>

Secondary notification message options.

Implementations§

Source§

impl ArchiveBot

Source

pub async fn slack_query<'sq>( &self, method: &str, params: &mut Vec<(&'sq str, String)>, ) -> Result<String, Error>

Wrapper for reqwest client to make Slack API calls.

Source

pub async fn send<'sq>( &self, method: &str, params: &mut Vec<(&'sq str, String)>, ) -> Result<SlackResponse, SlackError<Error>>

Send specific API call and parse response.

Source§

impl ArchiveBot

Source

pub async fn get_channels(&self) -> Vec<Channel>

Get a comprehensive list of basic channel data.

Source

pub async fn get_history( &self, channel_id: &str, limit: u16, ) -> Option<Vec<Message>>

Get conversation history for.

Source§

impl ArchiveBot

Source

pub async fn post_message( &self, channel_id: &str, message: &str, ) -> Result<SlackResponse, SlackError<Error>>

Post a message to a channel.

Source

pub async fn join_channel( &self, channel_id: &str, ) -> Result<SlackResponse, SlackError<Error>>

Make Archive Bot join a channel.

Source§

impl ArchiveBot

Source

pub fn from_env() -> ArchiveBot

Create a configuration from environment variables.

Source

pub async fn run(&self) -> Result<(), Box<dyn Error>>

Run Archive Bot.

Trait Implementations§

Source§

impl Debug for ArchiveBot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ArchiveBot

Source§

fn default() -> ArchiveBot

To append to configuration to fill blank values with defaults.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,