1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//! # Slack SDK
//!
//! A comprehensive Rust SDK for the Slack API with support for both stealth mode
//! (xoxc/xoxd tokens) and regular OAuth tokens (xoxp/xoxb).
//!
//! ## Features
//!
//! - **Multiple Authentication Methods**: OAuth tokens (xoxp, xoxb) and stealth mode (xoxc/xoxd)
//! - **Complete API Coverage**: 24 API modules covering all Slack functionality
//! - **Real-time Messaging**: RTM API support via WebSocket
//! - **Block Kit Support**: Builders for rich message layouts
//! - **Type Safety**: Strongly typed API responses and requests
//! - **Async/Await**: Built on tokio for high-performance async operations
//! - **Rate Limit Handling**: Automatic detection with retry information
//!
//! ## Quick Start
//!
//! ```no_run
//! use slacko::{SlackClient, AuthConfig};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create client with bot token
//! let client = SlackClient::new(AuthConfig::bot("xoxb-your-token"))?;
//!
//! // Post a message
//! client.chat().post_message("#general", "Hello from Rust!").await?;
//!
//! // List channels
//! let channels = client.conversations().list().await?;
//! for channel in channels.channels {
//! println!("#{}", channel.name.unwrap_or_default());
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Authentication
//!
//! ### OAuth Tokens
//!
//! ```no_run
//! use slacko::{SlackClient, AuthConfig};
//!
//! // Bot token (xoxb-...)
//! let client = SlackClient::new(AuthConfig::bot("xoxb-token")).unwrap();
//!
//! // User token (xoxp-...)
//! let client = SlackClient::new(AuthConfig::oauth("xoxp-token")).unwrap();
//! ```
//!
//! ### Stealth Mode
//!
//! Stealth mode uses browser session tokens and does not require app installation:
//!
//! ```no_run
//! use slacko::{SlackClient, AuthConfig};
//!
//! let client = SlackClient::new(
//! AuthConfig::stealth("xoxc-token", "xoxd-cookie")
//! ).unwrap();
//! ```
//!
//! ### Environment Variables
//!
//! The SDK can auto-detect credentials from environment variables:
//!
//! ```no_run
//! use slacko::{SlackClient, AuthConfig};
//!
//! // Checks SLACK_XOXC_TOKEN/SLACK_XOXD_COOKIE, then SLACK_XOXP_TOKEN, then SLACK_BOT_TOKEN
//! let client = SlackClient::new(AuthConfig::from_env().unwrap()).unwrap();
//! ```
//!
//! ## API Modules
//!
//! The SDK provides access to all major Slack APIs:
//!
//! - [`api::admin`] - Enterprise Grid administration
//! - [`api::apps`] - App management and permissions
//! - [`api::auth`] - Authentication verification
//! - [`api::bookmarks`] - Channel bookmarks
//! - [`api::calls`] - Slack Calls integration
//! - [`api::chat`] - Messages and threads
//! - [`api::conversations`] - Channels, DMs, and groups
//! - [`api::dialog`] - Legacy dialogs
//! - [`api::dnd`] - Do Not Disturb settings
//! - [`api::emoji`] - Custom emoji
//! - [`api::files`] - File uploads and management
//! - [`api::oauth`] - OAuth token exchange
//! - [`api::openid`] - OpenID Connect authentication
//! - [`api::pins`] - Pinned messages
//! - [`api::reactions`] - Emoji reactions
//! - [`api::reminders`] - Reminders
//! - [`api::rtm`] - Real-time messaging via WebSocket
//! - [`api::socket_mode`] - Socket Mode for receiving events via WebSocket
//! - [`api::search`] - Message and file search
//! - [`api::stars`] - Starred items
//! - [`api::team`] - Team information
//! - [`api::usergroups`] - User groups
//! - [`api::users`] - User information and presence
//! - [`api::views`] - Modals and App Home
//! - [`api::workflows`] - Workflow Builder
//!
//! ## Block Kit
//!
//! Build rich messages using Block Kit builders:
//!
//! ```no_run
//! use slacko::{SlackClient, AuthConfig, MessageBuilder};
//!
//! let client = SlackClient::new(AuthConfig::bot("xoxb-token")).unwrap();
//!
//! let blocks = MessageBuilder::new()
//! .section("*Hello* from Block Kit")
//! .divider()
//! .build();
//!
//! // client.chat().post_message_with_blocks("#general", "Hello", blocks).await?;
//! ```
//!
//! ## Error Handling
//!
//! The SDK provides detailed error types:
//!
//! ```no_run
//! use slacko::{SlackClient, AuthConfig, SlackError};
//!
//! async fn example() {
//! let client = SlackClient::new(AuthConfig::bot("xoxb-token")).unwrap();
//!
//! match client.chat().post_message("#general", "Hello").await {
//! Ok(response) => println!("Message sent: {}", response.ts),
//! Err(SlackError::RateLimitExceeded { retry_after }) => {
//! println!("Rate limited, retry after {} seconds", retry_after);
//! }
//! Err(SlackError::ApiError { code, message }) => {
//! println!("API error {}: {}", code, message);
//! }
//! Err(e) => println!("Error: {}", e),
//! }
//! }
//! ```
// Re-export commonly used types
pub use ;
pub use SlackClient;
pub use ;
// Re-export Block Kit builders for convenience
pub use ;
// Re-export common types
pub use ;
// Re-export common API request types
pub use ConversationHistoryRequest;
pub use UsersListRequest;