admin管理员组文章数量:1336293
I want to send a custom message to teams that is going is looking like the image attached. I am doing it by this code in python. But I would the code part of my message to be formatted in sql and have the copy code button like the other image. I havent found any reference on how I should send this information. properly I have found regarding how to send the code.
html_table = spark.sql(query+ " LIMIT 10").toPandas().to_html(index=False,justify='center',float_format="{:,.2f}".format).replace('<td>','<td style="text-align: center;">')
if num_outliers > 10:
n = 10
else:
n = num_outliers
html_message = f"""<strong>{CONS_CATALOG.upper()}.{CONS_SCHEMA_BUILD.upper()}.{CONS_TABLE_CONVIVA_HISTORICAL_COST.upper()}</strong><br>
<hr>
A total of {num_outliers} outliers has been detected on {date} for <em><a href="{CONS_TABLE_URL}">{CONS_CATALOG}.{CONS_SCHEMA_BUILD}.{CONS_TABLE_CONVIVA_HISTORICAL_COST}</a></em><br>
<br>The TOP {n} outliers are: <br> <br>
{html_table}
<br> To see the outliers run the following script on <em><a href="{CONS_TABLE_URL}">{CONS_CATALOG}.{CONS_SCHEMA_BUILD}.{CONS_TABLE_CONVIVA_HISTORICAL_COST}</a></em>: <br>
<pre>{query}
</pre>
payload ={"text":html_message,
'parse_mode': 'HTML'
}
# Set the headers for the request
headers = {
"Content-Type": "application/json"
}
# Make the POST request
response = requests.post(CONS_TEAMS_WEBHOOK_URL, headers=headers, data=json.dumps(payload))
# Print the response
if response.status_code == 200:
print("Alert created successfully:", response.json())
else:
print("Failed to create alert:", response.status_code, response.text)
本文标签: pythonSend code to teams group through webhooksStack Overflow
版权声明:本文标题:python - Send code to teams group through webhooks - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742406825a2468991.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论