csc-cia-stne 0.1.26__py3-none-any.whl → 0.1.27__py3-none-any.whl
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.
- csc_cia_stne/slack.py +62 -21
- {csc_cia_stne-0.1.26.dist-info → csc_cia_stne-0.1.27.dist-info}/METADATA +1 -1
- {csc_cia_stne-0.1.26.dist-info → csc_cia_stne-0.1.27.dist-info}/RECORD +6 -6
- {csc_cia_stne-0.1.26.dist-info → csc_cia_stne-0.1.27.dist-info}/WHEEL +0 -0
- {csc_cia_stne-0.1.26.dist-info → csc_cia_stne-0.1.27.dist-info}/licenses/LICENCE +0 -0
- {csc_cia_stne-0.1.26.dist-info → csc_cia_stne-0.1.27.dist-info}/top_level.txt +0 -0
csc_cia_stne/slack.py
CHANGED
@@ -85,6 +85,7 @@ class SendSlackMessageParamsValidator(BaseModel):
|
|
85
85
|
message:str
|
86
86
|
highlights:list
|
87
87
|
file_list:list
|
88
|
+
thread:Union[str,None] = None
|
88
89
|
|
89
90
|
@field_validator('message')
|
90
91
|
def validate_message(cls, value, info):
|
@@ -97,6 +98,12 @@ class SendSlackMessageParamsValidator(BaseModel):
|
|
97
98
|
if not isinstance(value, list):
|
98
99
|
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
99
100
|
return value
|
101
|
+
|
102
|
+
@field_validator('thread')
|
103
|
+
def validate_thread(cls, value, info):
|
104
|
+
if value is not None and (not isinstance(value, str) or not value.strip()):
|
105
|
+
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
106
|
+
return value
|
100
107
|
|
101
108
|
|
102
109
|
class Slack():
|
@@ -129,13 +136,14 @@ class Slack():
|
|
129
136
|
self.client = WebClient(self.token_slack)
|
130
137
|
|
131
138
|
|
132
|
-
def send_message(self, message:str, highlights:list=[] , file_list:list=[]):
|
139
|
+
def send_message(self, message:str, highlights:list=[] , file_list:list=[], thread:str=None):
|
133
140
|
"""
|
134
141
|
Envia uma mensagem para o canal do Slack.
|
135
142
|
Parâmetros:
|
136
143
|
- message: str - A mensagem a ser enviada.
|
137
144
|
- highlights: list - Uma lista de destaques (attachments) a serem exibidos junto com a mensagem.
|
138
145
|
- files: list (opcional) - Uma lista de arquivos a serem anexados à mensagem.
|
146
|
+
- thread: str (opcional) - O ID da thread onde a mensagem deve ser enviada.
|
139
147
|
Retorna:
|
140
148
|
Um dicionário com as seguintes chaves:
|
141
149
|
- status: bool - Indica se o envio da mensagem foi bem-sucedido.
|
@@ -151,7 +159,7 @@ class Slack():
|
|
151
159
|
|
152
160
|
try:
|
153
161
|
|
154
|
-
SendSlackMessageParamsValidator(message=message, highlights=highlights, file_list=file_list)
|
162
|
+
SendSlackMessageParamsValidator(message=message, highlights=highlights, file_list=file_list, thread=thread)
|
155
163
|
|
156
164
|
except ValidationError as e:
|
157
165
|
|
@@ -162,20 +170,42 @@ class Slack():
|
|
162
170
|
|
163
171
|
success_attachments = []
|
164
172
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
173
|
+
if thread is not None:
|
174
|
+
|
175
|
+
# Enviar mensagem em uma thread específica
|
176
|
+
|
177
|
+
result_message = self.client.chat_postMessage(
|
178
|
+
channel=self.channel_id,
|
179
|
+
text=message,
|
180
|
+
thread_ts=thread,
|
181
|
+
blocks=[
|
182
|
+
{
|
183
|
+
"type": "section",
|
184
|
+
"text": {
|
185
|
+
"type": "mrkdwn",
|
186
|
+
"text": message
|
187
|
+
}
|
188
|
+
},
|
189
|
+
],
|
190
|
+
attachments=highlights
|
191
|
+
)
|
192
|
+
|
193
|
+
else:
|
194
|
+
|
195
|
+
result_message = self.client.chat_postMessage(
|
196
|
+
channel=self.channel_id,
|
197
|
+
text=message,
|
198
|
+
blocks=[
|
199
|
+
{
|
200
|
+
"type": "section",
|
201
|
+
"text": {
|
202
|
+
"type": "mrkdwn",
|
203
|
+
"text": message
|
204
|
+
}
|
205
|
+
},
|
206
|
+
],
|
207
|
+
attachments=highlights
|
208
|
+
)
|
179
209
|
|
180
210
|
if file_list is not None and len(file_list) > 0:
|
181
211
|
|
@@ -201,11 +231,22 @@ class Slack():
|
|
201
231
|
|
202
232
|
# Enviar mensagem com anexos
|
203
233
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
234
|
+
if thread is not None:
|
235
|
+
|
236
|
+
result_message = self.client.files_upload_v2(
|
237
|
+
channel=self.channel_id,
|
238
|
+
initial_comment="anexos",
|
239
|
+
file_uploads=success_attachments,
|
240
|
+
thread_ts=thread
|
241
|
+
)
|
242
|
+
|
243
|
+
else:
|
244
|
+
|
245
|
+
result_message = self.client.files_upload_v2(
|
246
|
+
channel=self.channel_id,
|
247
|
+
initial_comment="anexos",
|
248
|
+
file_uploads=success_attachments
|
249
|
+
)
|
209
250
|
|
210
251
|
if result_message.get('ok', True):
|
211
252
|
|
@@ -11,7 +11,7 @@ csc_cia_stne/logger_json.py,sha256=CXxSCOFGMymDi8XE9SKnPKjW4D0wJLqDLnxqePS26i8,3
|
|
11
11
|
csc_cia_stne/logger_rich.py,sha256=fklgkBb4rblKQd7YZ3q-eWfhGg9eflO2k2-z4pGh_yo,5201
|
12
12
|
csc_cia_stne/provio.py,sha256=G-pDnHYLSp97joc7S7dvwjNvl3omnTmvdi3rOPQf5GA,3987
|
13
13
|
csc_cia_stne/servicenow.py,sha256=PUGN6bjcQ25hf-bwVuuKsnRKdqYTaYZ1Uh7QHn9OM24,35350
|
14
|
-
csc_cia_stne/slack.py,sha256=
|
14
|
+
csc_cia_stne/slack.py,sha256=9re_--1DfZM2cr5Uaxu2tnWLd8lswHgCIWowoZ1wF-I,9580
|
15
15
|
csc_cia_stne/stne_admin.py,sha256=tbRN_l3y---GHlQoAAjlZP92wnVA73hUmk9hQxKavH8,28753
|
16
16
|
csc_cia_stne/wacess.py,sha256=g-bWZNpm_tU7UsW1G_rqh_2fW2KShvxZHGOerX8DuQw,26768
|
17
17
|
csc_cia_stne/web.py,sha256=TBXUJ5eS36fytU3oFDuJsogi0sgw_qKgK-uphx4Nvxo,2506
|
@@ -38,8 +38,8 @@ csc_cia_stne/utilitarios/web_screen/__init__.py,sha256=5QcOPXKd95SvP2DoZiHS0gaU6
|
|
38
38
|
csc_cia_stne/utilitarios/web_screen/web_screen_abstract.py,sha256=PjL8Vgfj_JdKidia7RFyCkro3avYLQu4RZRos41sh3w,3241
|
39
39
|
csc_cia_stne/utilitarios/web_screen/web_screen_botcity.py,sha256=Xi5YJjl2pcxlX3OimqcBWRNXZEpAE7asyUjDJ4Oho5U,12297
|
40
40
|
csc_cia_stne/utilitarios/web_screen/web_screen_selenium.py,sha256=JLIcPJE9ZX3Pd6zG6oTRMqqUAY063UzLY3ReRlxmiSM,15581
|
41
|
-
csc_cia_stne-0.1.
|
42
|
-
csc_cia_stne-0.1.
|
43
|
-
csc_cia_stne-0.1.
|
44
|
-
csc_cia_stne-0.1.
|
45
|
-
csc_cia_stne-0.1.
|
41
|
+
csc_cia_stne-0.1.27.dist-info/licenses/LICENCE,sha256=LPGMtgKki2C3KEZP7hDhA1HBrlq5JCHkIeStUCLEMx4,1073
|
42
|
+
csc_cia_stne-0.1.27.dist-info/METADATA,sha256=MdHxPiFFEt6tkCVCgk3qnDqOyO4g4nybP43vHJ-5cl0,1464
|
43
|
+
csc_cia_stne-0.1.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
44
|
+
csc_cia_stne-0.1.27.dist-info/top_level.txt,sha256=ldo7GVv3tQx5KJvwBzdZzzQmjPys2NDVVn1rv0BOF2Q,13
|
45
|
+
csc_cia_stne-0.1.27.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|