Skip to content

Commit c67e017

Browse files
committed
docs: update for impl refactor
1 parent 1560d2c commit c67e017

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Archive bot needs a bit of data to get started:
1919
- Configure how small a channel has to be before it's considered "small."
2020

2121
```rust
22-
let config = archive_bot::Config {
22+
let bot = ArchiveBot {
2323
// Bot tokens look like: xoxb-xxxxxxxyourtokenxxxxxxx.
2424
token: env::var("SLACK_BOT_TOKEN").expect("Error: environment variable SLACK_BOT_TOKEN is not set."),
2525
// Use the channel ID and not the name.
@@ -32,7 +32,7 @@ let config = archive_bot::Config {
3232
"Hey boss, take a look at these, will ya?",
3333
],
3434
// How long before a channel is stale (in seconds).
35-
stale_after: 2 * 7 * 24 * 60 * 60,
35+
stale_after: 6 * 7 * 24 * 60 * 60,
3636
// How small a "small" channel is.
3737
small_channel_threshold: 3,
3838
// Whether to send a secondary notification to a different channel (message only).
@@ -44,17 +44,17 @@ let config = archive_bot::Config {
4444
"Hey folks! I, uh... made a list for you. Of channels. That you should archive. Maybe.",
4545
"Hey everyone! If you want the satisfaction of crossing a task off your list, I have one!",
4646
],
47-
..archive_bot::Config::default()
47+
..ArchiveBot::default()
4848
};
4949
```
5050

5151
Or, using default values:
5252

5353
```rust
54-
let config = archive_bot::Config {
54+
let bot = ArchiveBot {
5555
token: env::var("SLACK_BOT_TOKEN").expect("Error: environment variable SLACK_BOT_TOKEN is not set."),
5656
notification_channel_id: "C01A02A03A04".to_string(),
57-
..archive_bot::Config::default()
57+
..ArchiveBot::default()
5858
};
5959
```
6060

@@ -64,7 +64,7 @@ Currently this bot consists of a single runtime, with a single action. Further a
6464
config options TBD.
6565

6666
```rust
67-
match archive_bot::run(&config).await {
67+
match bot.run().await {
6868
Ok(_) => println!("Success!"),
6969
Err(e) => panic!("Uhoh! {:}", e),
7070
}

examples/basic.rs.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::env;
2-
use archive_bot;
2+
use archive_bot::ArchiveBot;
33

44
#[tokio::main]
55
async fn main() {
6-
let config = archive_bot::Config {
6+
let bot = ArchiveBot {
77
token: env::var("SLACK_BOT_TOKEN").expect("Error: environment variable SLACK_BOT_TOKEN is not set."),
88
notification_channel_id: env::var("SLACK_CHANNEL_ID").expect("Error: environment variable SLACK_CHANNEL_ID is not set."),
99
filter_prefixes: vec!["-"],
@@ -13,10 +13,10 @@ async fn main() {
1313
],
1414
stale_after: 2 * 7 * 24 * 60 * 60,
1515
small_channel_threshold: 3,
16-
..archive_bot::Config::default()
16+
..ArchiveBot::default()
1717
};
1818

19-
match archive_bot::run(&config).await {
19+
match bot.run().await {
2020
Ok(_) => println!("Success!"),
2121
Err(e) => panic!("Uhoh! {:}", e),
2222
}

examples/lambda-netlify.rs.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use simplelog::*;
55
use lambda_runtime::{service_fn, Error, LambdaEvent};
66
use serde::Serialize;
77
use serde_json::{json, Value};
8-
use archive_bot;
8+
use archive_bot::ArchiveBot;
99

1010
/// Enable logger and add Lambda function handler.
1111
#[tokio::main]
@@ -51,13 +51,13 @@ pub(crate) async fn archive_bot_handler(_event: LambdaEvent<Value>) -> Result<Re
5151
}
5252
};
5353

54-
let config = archive_bot::Config {
54+
let bot = ArchiveBot {
5555
token: bot_token,
5656
notification_channel_id: "C0123456789".to_string(),
57-
..archive_bot::Config::default()
57+
..ArchiveBot::default()
5858
};
5959

60-
match archive_bot::run(&config).await {
60+
match bot.run().await {
6161
Ok(_) => info!("Run complete."),
6262
Err(e) => error!("Run failed: {:}", e),
6363
}

0 commit comments

Comments
 (0)