| Server IP : 198.38.94.67 / Your IP : 216.73.217.178 Web Server : LiteSpeed System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64 User : azfilmst ( 1070) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/ |
Upload File : |
"""
Module for sending messages to google chat.
.. versionadded:: 2019.2.0
To use this module you need to configure a webhook in the google chat room
where you would like the message to be sent, see:
https://developers.google.com/hangouts/chat/how-tos/webhooks
"""
import json
# ------------------------------------------------------------------------------
# module properties
# ------------------------------------------------------------------------------
__virtualname__ = "google_chat"
# ------------------------------------------------------------------------------
# property functions
# ------------------------------------------------------------------------------
def __virtual__():
return __virtualname__
# ------------------------------------------------------------------------------
# callable functions
# ------------------------------------------------------------------------------
def send_message(url, message):
"""
Send a message to the google chat room specified in the webhook url.
.. code-block:: bash
salt '*' google_chat.send_message "https://chat.googleapis.com/v1/spaces/example_space/messages?key=example_key" "This is a test message"
"""
headers = {"Content-Type": "application/json"}
data = {"text": message}
result = __utils__["http.query"](
url,
"POST",
data=json.dumps(data),
header_dict=headers,
decode=True,
status=True,
)
if result.get("status", 0) == 200:
return True
else:
return False