-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from dten/release-0.23
Release 0.23
- Loading branch information
Showing
4 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use slack_api::sync as slack; | ||
|
||
use std::env; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// You can generate a legacy token to quickly test these apis | ||
// https://api.slack.com/custom-integrations/legacy-tokens | ||
let token = env::var("SLACK_API_TOKEN").map_err(|_| "SLACK_API_TOKEN env var must be set")?; | ||
let client = slack::default_client().map_err(|_| "Could not get default_client")?; | ||
|
||
let response = slack::channels::history( | ||
&client, | ||
&token, | ||
&slack::channels::HistoryRequest { | ||
channel: &env::args() | ||
.nth(1) | ||
.ok_or("must specify channel id as argument e.g. C09123456")?, | ||
..slack::channels::HistoryRequest::default() | ||
}, | ||
); | ||
|
||
if let Ok(response) = response { | ||
if let Some(messages) = response.messages { | ||
for message in &messages { | ||
println!("{:?}", message); | ||
} | ||
println!("Got {} messages:", messages.len()); | ||
} | ||
} else { | ||
println!("{:?}", response); | ||
} | ||
Ok(()) | ||
} |