aboutsummaryrefslogtreecommitdiffstats
path: root/typings/slack_rtm/slack_rtm_message.pyi
blob: 63103520bacb388e36867313eb4d874fe316e054 (plain) (blame)
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
from slack_api.slack_conversations_history import (
    SlackMessage,
    SlackMessageMe,
    SlackMessageStandardCommon,
    SlackMessageSubtypeBotAdd,
    SlackMessageSubtypeBotMessage,
    SlackMessageSubtypeBotRemove,
    SlackMessageSubtypeChannelJoin,
    SlackMessageSubtypeChannelLeave,
    SlackMessageSubtypeChannelTopic,
    SlackMessageSubtypeHuddleThread,
    SlackMessageSubtypeHuddleThreadRoom,
    SlackMessageThreadBroadcast,
    SlackMessageThreadParentCommon,
    SlackMessageThreadParentNotSubscribed,
    SlackMessageThreadParentSubscribed,
    SlackMessageWithFiles,
)
from slack_api.slack_conversations_info import SlackConversationsInfo
from slack_api.slack_conversations_replies import SlackMessageThreadCommon
from slack_api.slack_users_info import SlackUserInfoPerson
from typing_extensions import Literal, NotRequired, TypedDict, final

class SlackRtmHello(TypedDict):
    type: Literal["hello"]
    fast_reconnect: bool
    region: str
    start: bool
    host_id: str

@final
class SlackMessageStandardRtm(SlackMessageStandardCommon):
    channel: str

@final
class SlackMessageMeRtm(SlackMessageMe):
    channel: str

@final
class SlackMessageThreadParentNotSubscribedRtm(SlackMessageThreadParentNotSubscribed):
    channel: str

@final
class SlackMessageThreadParentSubscribedRtm(SlackMessageThreadParentSubscribed):
    channel: str

@final
class SlackMessageThreadRtm(SlackMessageThreadCommon):
    channel: str
    event_ts: str
    source_team: str
    suppress_notification: NotRequired[bool]
    user_team: str

@final
class SlackMessageThreadBroadcastRtm(SlackMessageThreadBroadcast):
    channel: str
    event_ts: str
    source_team: str
    suppress_notification: NotRequired[bool]
    user_team: str

@final
class SlackMessageWithFilesRtm(SlackMessageWithFiles):
    channel: str

@final
class SlackMessageSubtypeHuddleThreadRtm(SlackMessageSubtypeHuddleThread):
    event_ts: str
    suppress_notification: NotRequired[bool]

@final
class SlackMessageSubtypeBotMessageRtm(SlackMessageSubtypeBotMessage):
    channel: str

@final
class SlackMessageSubtypeBotRemoveRtm(SlackMessageSubtypeBotRemove):
    channel: str

@final
class SlackMessageSubtypeBotAddRtm(SlackMessageSubtypeBotAdd):
    channel: str

@final
class SlackMessageSubtypeChannelJoinRtm(SlackMessageSubtypeChannelJoin):
    channel: str

@final
class SlackMessageSubtypeChannelLeaveRtm(SlackMessageSubtypeChannelLeave):
    channel: str

@final
class SlackMessageSubtypeChannelTopicRtm(SlackMessageSubtypeChannelTopic):
    channel: str
    team: str
    event_ts: str

@final
class SlackMessageChanged(TypedDict):
    type: Literal["message"]
    subtype: Literal["message_changed"]
    message: SlackMessage
    previous_message: SlackMessage
    channel: str
    hidden: bool
    ts: str
    event_ts: str

@final
class SlackMessageDeleted(TypedDict):
    type: Literal["message"]
    subtype: Literal["message_deleted"]
    previous_message: SlackMessage
    channel: str
    hidden: bool
    ts: str
    deleted_ts: str
    event_ts: str

@final
class SlackMessageReplied(TypedDict):
    type: Literal["message"]
    subtype: Literal["message_replied"]
    message: SlackMessageThreadParentCommon
    channel: str
    hidden: bool
    ts: str
    event_ts: str

@final
class SlackReactionItem(TypedDict):
    type: Literal["message", "file", "file_comment"]
    channel: str
    ts: str

@final
class SlackReactionAdded(TypedDict):
    type: Literal["reaction_added"]
    user: str
    reaction: str
    item: SlackReactionItem
    item_user: NotRequired[str]
    event_ts: str
    ts: str

@final
class SlackReactionRemoved(TypedDict):
    type: Literal["reaction_removed"]
    user: str
    reaction: str
    item: SlackReactionItem
    item_user: NotRequired[str]
    event_ts: str
    ts: str

@final
class SlackImOpen(TypedDict):
    type: Literal["im_open"]
    user: str
    channel: str
    event_ts: str

@final
class SlackImClose(TypedDict):
    type: Literal["im_close"]
    user: str
    channel: str
    event_ts: str

@final
class SlackMpimOpen(TypedDict):
    type: Literal["mpim_open", "group_open"]
    is_mpim: Literal[True]
    user: str
    channel: str
    event_ts: str

@final
class SlackMpimClose(TypedDict):
    type: Literal["mpim_close", "group_close"]
    is_mpim: Literal[True]
    user: str
    channel: str
    event_ts: str

@final
class SlackChannelJoined(TypedDict):
    type: Literal["channel_joined", "group_joined"]
    channel: SlackConversationsInfo

@final
class SlackChannelLeft(TypedDict):
    type: Literal["channel_left", "group_left"]
    channel: str
    actor_id: str
    event_ts: str

class SlackNotImMarked(TypedDict):
    channel: str
    ts: str
    unread_count: int
    unread_count_display: int
    num_mentions: int
    num_mentions_display: int
    mention_count: int
    mention_count_display: int
    event_ts: str

@final
class SlackChannelMarked(SlackNotImMarked):
    type: Literal["channel_marked"]

@final
class SlackGroupMarked(SlackNotImMarked):
    type: Literal["group_marked"]
    is_mpim: Literal[False]

@final
class SlackMpImMarked(SlackNotImMarked):
    type: Literal["mpim_marked"]
    is_mpim: Literal[True]

@final
class SlackImMarked(TypedDict):
    type: Literal["im_marked"]
    channel: str
    ts: str
    dm_count: int
    unread_count_display: int
    num_mentions_display: int
    mention_count_display: int
    event_ts: str

class SlackThreadSubscription(TypedDict):
    type: Literal["thread"]
    channel: str
    thread_ts: str
    date_create: int
    active: bool
    last_read: str

# Dummy event to make sure we check that subscription is of type thead when used
class SlackThreadSubscriptionUnknown(TypedDict):
    type: Literal["unknown"]

@final
class SlackThreadMarked(TypedDict):
    type: Literal["thread_marked"]
    subscription: SlackThreadSubscription | SlackThreadSubscriptionUnknown
    event_ts: str

@final
class SlackThreadSubscribed(TypedDict):
    type: Literal["thread_subscribed"]
    subscription: SlackThreadSubscription | SlackThreadSubscriptionUnknown
    event_ts: str

@final
class SlackThreadUnsubscribed(TypedDict):
    type: Literal["thread_unsubscribed"]
    subscription: SlackThreadSubscription | SlackThreadSubscriptionUnknown
    event_ts: str

class SlackShRoomHuddle(TypedDict):
    channel_id: str

@final
class SlackShRoomJoin(TypedDict):
    type: Literal["sh_room_join"]
    room: SlackMessageSubtypeHuddleThreadRoom
    user: str
    huddle: SlackShRoomHuddle
    event_ts: str
    ts: str

@final
class SlackShRoomUpdate(TypedDict):
    type: Literal["sh_room_update"]
    room: SlackMessageSubtypeHuddleThreadRoom
    user: str
    huddle: SlackShRoomHuddle
    event_ts: str
    ts: str

@final
class SlackUserTyping(TypedDict):
    type: Literal["user_typing"]
    channel: str
    thread_ts: NotRequired[str]
    id: int
    user: str

@final
class SlackPrefChange(TypedDict):
    type: Literal["pref_change"]
    name: str
    value: str

@final
class SlackUserStatusChanged(TypedDict):
    type: Literal["user_status_changed"]
    user: SlackUserInfoPerson
    cache_ts: str
    event_ts: str

class SlackUserInvalidatedUser(TypedDict):
    id: str

@final
class SlackUserInvalidated(TypedDict):
    type: Literal["user_invalidated"]
    user: SlackUserInvalidatedUser
    event_ts: str

SlackMessageRtm = (
    SlackMessageStandardRtm
    | SlackMessageMeRtm
    | SlackMessageThreadParentNotSubscribedRtm
    | SlackMessageThreadParentSubscribedRtm
    | SlackMessageThreadRtm
    | SlackMessageThreadBroadcastRtm
    | SlackMessageWithFilesRtm
    | SlackMessageSubtypeHuddleThreadRtm
    | SlackMessageSubtypeBotMessageRtm
    | SlackMessageSubtypeBotRemoveRtm
    | SlackMessageSubtypeBotAddRtm
    | SlackMessageSubtypeChannelJoinRtm
    | SlackMessageSubtypeChannelLeaveRtm
    | SlackMessageSubtypeChannelTopicRtm
)

SlackRtmMessage = (
    SlackRtmHello
    | SlackMessageRtm
    | SlackMessageChanged
    | SlackMessageDeleted
    | SlackMessageReplied
    | SlackReactionAdded
    | SlackReactionRemoved
    | SlackImOpen
    | SlackImClose
    | SlackMpimOpen
    | SlackMpimClose
    | SlackChannelJoined
    | SlackChannelLeft
    | SlackChannelMarked
    | SlackGroupMarked
    | SlackMpImMarked
    | SlackImMarked
    | SlackThreadMarked
    | SlackThreadSubscribed
    | SlackThreadUnsubscribed
    | SlackShRoomJoin
    | SlackShRoomUpdate
    | SlackUserTyping
    | SlackPrefChange
    | SlackUserStatusChanged
    | SlackUserInvalidated
)