Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webhook-to-matrix-hookshot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
isgphys
webhook-to-matrix-hookshot
Commits
b10b710c
Commit
b10b710c
authored
2 years ago
by
Sven Mäder
Browse files
Options
Downloads
Patches
Plain Diff
Adapt /slack api for checkmk, return 200 plaintext ok
parent
6bd3e87c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app.py
+11
-1
11 additions, 1 deletion
app.py
with
11 additions
and
1 deletion
app.py
+
11
−
1
View file @
b10b710c
...
...
@@ -19,6 +19,7 @@ def slack(hook):
title
=
str
(
attachment
.
get
(
'
title
'
,
''
))
title_link
=
str
(
attachment
.
get
(
'
title_link
'
,
''
))
text
=
str
(
attachment
.
get
(
'
text
'
,
''
))
footer
=
str
(
attachment
.
get
(
'
footer
'
,
''
))
fields
=
attachment
.
get
(
'
fields
'
,
[])
html
+=
'
<font color=
"'
+
color
+
'"
>
'
if
color
else
''
...
...
@@ -26,6 +27,9 @@ def slack(hook):
if
title
and
title_link
:
plain
+=
title
+
'
'
+
title_link
+
'
\n
'
html
+=
'
<b><a href=
"'
+
title_link
+
'"
>
'
+
title
+
'
</a></b><br/>
\n
'
elif
title
:
plain
+=
title
+
'
\n
'
html
+=
'
<b>
'
+
title
+
'
</b><br/>
\n
'
if
text
:
plain
+=
text
+
'
\n
'
...
...
@@ -38,6 +42,10 @@ def slack(hook):
plain
+=
title
+
'
:
'
+
value
+
'
\n
'
html
+=
'
<b>
'
+
title
+
'
</b>:
'
+
value
+
'
<br/>
\n
'
if
footer
:
plain
+=
footer
+
'
\n
'
html
+=
footer
+
'
<br/>
\n
'
html
+=
'
</font>
'
if
color
else
''
if
plain
and
html
:
...
...
@@ -51,7 +59,9 @@ def slack(hook):
print
(
'
Invalid format, sending unmodified.
'
)
r
=
requests
.
post
(
url
+
hook
,
json
=
incoming
)
return
{
"
ok
"
:
True
}
response
=
make_response
(
'
ok
'
,
200
)
response
.
mimetype
=
"
text/plain
"
return
response
@app.route
(
"
/webhook/grafana/<hook>
"
,
methods
=
[
'
POST
'
,
'
PUT
'
])
def
grafana
(
hook
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment