chat_sdk-slack 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chat_sdk/slack/adapter.rb +63 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e7d8fc2f1b7131a6077f09cf438093c889cacbd14e714ce5c755e431b06100e
|
|
4
|
+
data.tar.gz: bd5d7332ecdd4ee0a703653672199eea4895c97b1dbdee6415bcf1af565c41f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6562ff69a5097cbfd41951eb0bd1a23cd44b2a9d8b0e37757d273cb8efaf782342b6a6bc9e8fcd744c3e17e692aa09c0d9f1bc3cf1fbdfdaae07ca60113b0d20
|
|
7
|
+
data.tar.gz: f6fb9463be08054efcc0f94c95f6f50e94b787db295cbe667011d9a7f73203ebc4edbca9221d2dae5a4e6e703276d2f02cd5bd11ed1289d68c37bccb807d4b68
|
|
@@ -5,7 +5,8 @@ module ChatSDK
|
|
|
5
5
|
class Adapter < ChatSDK::Adapter::Base
|
|
6
6
|
capabilities :edit_messages, :delete_messages, :ephemeral_messages,
|
|
7
7
|
:file_uploads, :reactions, :modals, :typing_indicator,
|
|
8
|
-
:streaming_edit, :threads, :direct_messages, :message_history
|
|
8
|
+
:streaming_edit, :threads, :direct_messages, :message_history,
|
|
9
|
+
:scheduled_messages
|
|
9
10
|
|
|
10
11
|
attr_reader :client
|
|
11
12
|
|
|
@@ -135,11 +136,44 @@ module ChatSDK
|
|
|
135
136
|
@client.reactions_remove(channel: channel_id, timestamp: message_id, name: emoji)
|
|
136
137
|
end
|
|
137
138
|
|
|
139
|
+
def get_user(user_id)
|
|
140
|
+
result = @client.users_info(user: user_id)
|
|
141
|
+
return nil unless result&.dig("user", "id")
|
|
142
|
+
|
|
143
|
+
ChatSDK::Author.new(
|
|
144
|
+
id: result.dig("user", "id"),
|
|
145
|
+
name: result.dig("user", "name"),
|
|
146
|
+
platform: :slack,
|
|
147
|
+
bot: result.dig("user", "is_bot") || false,
|
|
148
|
+
raw: result
|
|
149
|
+
)
|
|
150
|
+
end
|
|
151
|
+
|
|
138
152
|
def open_dm(user_id)
|
|
139
153
|
result = @client.conversations_open(users: user_id)
|
|
140
154
|
result["channel"]["id"]
|
|
141
155
|
end
|
|
142
156
|
|
|
157
|
+
def schedule_message(channel_id:, message:, post_at:, thread_id: nil)
|
|
158
|
+
msg = ChatSDK::PostableMessage.from(message)
|
|
159
|
+
text = msg.text || ""
|
|
160
|
+
|
|
161
|
+
params = {channel: channel_id, text: text, post_at: post_at.to_i}
|
|
162
|
+
params[:thread_ts] = thread_id if thread_id
|
|
163
|
+
|
|
164
|
+
result = @client.chat_scheduleMessage(**params)
|
|
165
|
+
|
|
166
|
+
ChatSDK::Message.new(
|
|
167
|
+
id: result["scheduled_message_id"],
|
|
168
|
+
text: text,
|
|
169
|
+
author: ChatSDK::Author.new(id: "bot", name: "bot", platform: :slack, bot: true),
|
|
170
|
+
thread_id: thread_id || result["scheduled_message_id"],
|
|
171
|
+
channel_id: channel_id,
|
|
172
|
+
platform: :slack,
|
|
173
|
+
raw: result
|
|
174
|
+
)
|
|
175
|
+
end
|
|
176
|
+
|
|
143
177
|
def fetch_messages(channel_id:, thread_id: nil, cursor: nil, limit: 50)
|
|
144
178
|
result = if thread_id
|
|
145
179
|
@client.conversations_replies(channel: channel_id, ts: thread_id, cursor: cursor, limit: limit)
|
|
@@ -155,6 +189,34 @@ module ChatSDK
|
|
|
155
189
|
@client.views_open(trigger_id: trigger_id, view: view)
|
|
156
190
|
end
|
|
157
191
|
|
|
192
|
+
def publish_home_view(user_id:, view:)
|
|
193
|
+
@client.views_publish(user_id: user_id, view: view)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def set_suggested_prompts(channel_id:, thread_id:, prompts:)
|
|
197
|
+
@client.assistant_threads_setSuggestedPrompts(
|
|
198
|
+
channel_id: channel_id,
|
|
199
|
+
thread_ts: thread_id,
|
|
200
|
+
prompts: prompts
|
|
201
|
+
)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def set_assistant_status(channel_id:, thread_id:, status:)
|
|
205
|
+
@client.assistant_threads_setStatus(
|
|
206
|
+
channel_id: channel_id,
|
|
207
|
+
thread_ts: thread_id,
|
|
208
|
+
status: status
|
|
209
|
+
)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def set_assistant_title(channel_id:, thread_id:, title:)
|
|
213
|
+
@client.assistant_threads_setTitle(
|
|
214
|
+
channel_id: channel_id,
|
|
215
|
+
thread_ts: thread_id,
|
|
216
|
+
title: title
|
|
217
|
+
)
|
|
218
|
+
end
|
|
219
|
+
|
|
158
220
|
def start_typing(channel_id:, thread_id: nil)
|
|
159
221
|
# Slack doesn't have a native typing indicator API for bots
|
|
160
222
|
# This is a no-op but the capability is declared for streaming support
|