aboutsummaryrefslogtreecommitdiffstats
path: root/typings/slack_api/slack_conversations_history.pyi
blob: 809e7c6fce3cf2fcd298e4fd311beaa275097fdb (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
from __future__ import annotations

from typing import Dict, List

from slack_api.slack_common import SlackErrorResponse
from slack_rtm.slack_rtm_message import SlackMessageRtm
from typing_extensions import Literal, NotRequired, TypedDict, final

@final
class SlackMessageBlockElement(TypedDict):
    type: str
    url: NotRequired[str]
    text: str

@final
class SlackMessageBlockElementParent(TypedDict):
    type: str
    elements: List[SlackMessageBlockElement]

@final
class SlackMessageBlock(TypedDict):
    type: str
    block_id: str
    elements: List[SlackMessageBlockElementParent]

@final
class SlackMessageAttachment(TypedDict):
    from_url: str
    image_url: str
    image_width: int
    image_height: int
    image_bytes: int
    service_icon: str
    id: int
    original_url: str
    fallback: str
    text: str
    title: str
    title_link: str
    service_name: str

@final
class SlackMessageReaction(TypedDict):
    name: str
    users: List[str]
    count: int

@final
class SlackMessageFile(TypedDict):
    id: str
    created: int
    timestamp: int
    name: str
    title: str
    mimetype: str
    filetype: str
    pretty_type: str
    user: str
    user_team: str
    editable: bool
    size: int
    mode: str
    is_external: bool
    external_type: str
    is_public: bool
    public_url_shared: bool
    display_as_bot: bool
    username: str
    url_private: str
    url_private_download: str
    permalink: str
    permalink_public: str
    preview: str
    editor: None
    last_editor: str
    non_owner_editable: bool
    updated: int
    is_starred: bool
    has_rich_preview: bool
    file_access: str
    media_progress: None

class SlackMessageCommon(TypedDict):
    type: Literal["message"]
    text: str
    ts: str
    reactions: NotRequired[List[SlackMessageReaction]]

class SlackMessageStandardCommon(SlackMessageCommon):
    client_msg_id: NotRequired[str]
    user: str
    blocks: List[SlackMessageBlock]
    attachments: NotRequired[List[SlackMessageAttachment]]
    team: str

@final
class SlackMessageStandardFinal(SlackMessageStandardCommon):
    pass

class SlackMessageThreadParentCommon(SlackMessageStandardCommon):
    thread_ts: str
    reply_count: int
    reply_users_count: int
    latest_reply: str
    reply_users: List[str]
    is_locked: bool

class SlackMessageThreadParentNotSubscribed(SlackMessageThreadParentCommon):
    subscribed: Literal[False]

@final
class SlackMessageThreadParentNotSubscribedFinal(SlackMessageThreadParentNotSubscribed):
    pass

class SlackMessageThreadParentSubscribed(SlackMessageThreadParentCommon):
    subscribed: Literal[True]
    last_read: str

@final
class SlackMessageThreadParentSubscribedFinal(SlackMessageThreadParentSubscribed):
    pass

class SlackMessageWithFiles(SlackMessageCommon):
    user: str
    files: List[SlackMessageFile]
    upload: bool
    display_as_bot: bool

@final
class SlackMessageWithFilesFinal(SlackMessageWithFiles):
    pass

# TODO: Add other subtypes
class SlackMessageSubtypeBotMessage(SlackMessageCommon):
    subtype: Literal["bot_message"]
    bot_id: str
    username: NotRequired[str]
    icons: NotRequired[Dict[str, str]]

@final
class SlackMessageSubtypeBotMessageFinal(SlackMessageSubtypeBotMessage):
    pass

class SlackMessageSubtypeBotRemove(SlackMessageCommon):
    subtype: Literal["bot_remove"]
    user: str
    bot_id: str
    bot_link: str

@final
class SlackMessageSubtypeBotRemoveFinal(SlackMessageSubtypeBotRemove):
    pass

class SlackMessageSubtypeBotAdd(SlackMessageCommon):
    subtype: Literal["bot_add"]
    user: str
    bot_id: str
    bot_link: str

@final
class SlackMessageSubtypeBotAddFinal(SlackMessageSubtypeBotAdd):
    pass

class SlackMessageSubtypeChannelJoin(SlackMessageCommon):
    subtype: Literal["channel_join", "group_join"]
    user: str
    inviter: NotRequired[str]

@final
class SlackMessageSubtypeChannelJoinFinal(SlackMessageSubtypeChannelJoin):
    pass

class SlackMessageSubtypeChannelLeave(SlackMessageCommon):
    subtype: Literal["channel_leave", "group_leave"]
    user: str

@final
class SlackMessageSubtypeChannelLeaveFinal(SlackMessageSubtypeChannelLeave):
    pass

SlackMessage = (
    SlackMessageStandardFinal
    | SlackMessageThreadParentNotSubscribedFinal
    | SlackMessageThreadParentSubscribedFinal
    | SlackMessageWithFilesFinal
    | SlackMessageSubtypeBotMessageFinal
    | SlackMessageSubtypeBotRemoveFinal
    | SlackMessageSubtypeBotAddFinal
    | SlackMessageSubtypeChannelJoinFinal
    | SlackMessageSubtypeChannelLeaveFinal
    | SlackMessageRtm
)

@final
class SlackConversationsHistorySuccessResponse(TypedDict):
    ok: Literal[True]
    messages: List[SlackMessage]
    has_more: bool
    is_limited: NotRequired[bool]
    pin_count: int
    channel_actions_ts: None
    channel_actions_count: int

SlackConversationsHistoryResponse = (
    SlackConversationsHistorySuccessResponse | SlackErrorResponse
)