in taskcluster/scripts/slack_notifier.py [0:0]
def send_slack_notification(template, values, channel_id, options):
"""
Sends a Slack notification based on the provided template and values.
:param template: Template object for the Slack message.
:param values: Dictionary containing values to substitute in the template.
:param channel_id: Slack channel ID to send the message to.
:param options: Taskcluster options for the notification service.
"""
slack_message = json.loads(template.safe_substitute(**values))
# workaround for https://github.com/taskcluster/taskcluster/issues/6801
duplicate_message_workaround = str(int(time.time()))
payload = {
"channelId": channel_id,
"text": duplicate_message_workaround,
"blocks": slack_message,
}
try:
response = taskcluster.Notify(options).slack(payload)
print("Response from API:", response)
except Exception as e:
print(f"Error sending Slack message: {e}")
traceback.print_exc()
if hasattr(e, "response"):
print("Response content:", e.response.text)