chat_sdk-discord 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/discord/adapter.rb +19 -1
- data/lib/chat_sdk/discord/api_client.rb +10 -0
- 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: 48fe551dfea184269a21798805245389d7ddced76cff1f575000583d884541a6
|
|
4
|
+
data.tar.gz: 5a26bbdba497b93dbb2a99f0fff5cd7a98eb5d0b37ca729e7179792d5f2ae099
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ccb7efe2bd35ab8f88f6d3b7644c1b386b20955053062056978d617e6bfd5240e4890bc4a791e60826a0cadfb4c4fd9ba4d5d0462df634fae5d19c9165bc2a69
|
|
7
|
+
data.tar.gz: d6346f57703d07dbf352abd490ea682f01dc175a4410de307242f28d406c65f655838c75b9d872c3a37a08d3371c83077f08254725ee0a004f5804d94e47a2d8
|
|
@@ -4,7 +4,8 @@ module ChatSDK
|
|
|
4
4
|
module Discord
|
|
5
5
|
class Adapter < ChatSDK::Adapter::Base
|
|
6
6
|
capabilities :edit_messages, :delete_messages, :reactions, :file_uploads,
|
|
7
|
-
:threads, :direct_messages, :message_history, :streaming_edit
|
|
7
|
+
:threads, :direct_messages, :message_history, :streaming_edit,
|
|
8
|
+
:typing_indicator
|
|
8
9
|
|
|
9
10
|
attr_reader :client
|
|
10
11
|
|
|
@@ -116,6 +117,19 @@ module ChatSDK
|
|
|
116
117
|
@client.remove_reaction(channel_id, message_id, emoji)
|
|
117
118
|
end
|
|
118
119
|
|
|
120
|
+
def get_user(user_id)
|
|
121
|
+
data = @client.get_user(user_id)
|
|
122
|
+
return nil unless data && data["id"]
|
|
123
|
+
|
|
124
|
+
ChatSDK::Author.new(
|
|
125
|
+
id: data["id"],
|
|
126
|
+
name: data["username"],
|
|
127
|
+
platform: :discord,
|
|
128
|
+
bot: data["bot"] || false,
|
|
129
|
+
raw: data
|
|
130
|
+
)
|
|
131
|
+
end
|
|
132
|
+
|
|
119
133
|
def open_dm(user_id)
|
|
120
134
|
@dm_channels[user_id] ||= @client.create_dm(user_id)["id"]
|
|
121
135
|
end
|
|
@@ -132,6 +146,10 @@ module ChatSDK
|
|
|
132
146
|
[messages, next_cursor]
|
|
133
147
|
end
|
|
134
148
|
|
|
149
|
+
def start_typing(channel_id:, thread_id: nil)
|
|
150
|
+
@client.trigger_typing(channel_id)
|
|
151
|
+
end
|
|
152
|
+
|
|
135
153
|
def mention(user_id)
|
|
136
154
|
"<@#{user_id}>"
|
|
137
155
|
end
|
|
@@ -44,6 +44,11 @@ module ChatSDK
|
|
|
44
44
|
request(:delete, "#{API_PREFIX}/channels/#{channel_id}/messages/#{message_id}/reactions/#{encoded}/@me")
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
# Users
|
|
48
|
+
def get_user(user_id)
|
|
49
|
+
request(:get, "#{API_PREFIX}/users/#{user_id}")
|
|
50
|
+
end
|
|
51
|
+
|
|
47
52
|
# DMs
|
|
48
53
|
def create_dm(user_id)
|
|
49
54
|
request(:post, "#{API_PREFIX}/users/@me/channels", {"recipient_id" => user_id})
|
|
@@ -56,6 +61,11 @@ module ChatSDK
|
|
|
56
61
|
request(:get, path)
|
|
57
62
|
end
|
|
58
63
|
|
|
64
|
+
# Typing indicator
|
|
65
|
+
def trigger_typing(channel_id)
|
|
66
|
+
request(:post, "#{API_PREFIX}/channels/#{channel_id}/typing")
|
|
67
|
+
end
|
|
68
|
+
|
|
59
69
|
# File upload
|
|
60
70
|
def upload_file(channel_id, io, filename)
|
|
61
71
|
payload = {
|