Created
February 28, 2018 20:15
-
-
Save chasetb/c94baee469f4807b64c54af4ee7cd2b5 to your computer and use it in GitHub Desktop.
Send a bot message to a Hangouts Chat room
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from json import dumps | |
def chat_message(url, name, avatar_url, message): | |
bot_message = { | |
'sender': { | |
'displayName': name, | |
'avatarUrl': avatar_url | |
}, | |
'text': message | |
} | |
headers = {'Content-Type': 'application/json; charset=UTF-8'} | |
response = requests.post(url, data=dumps(bot_message), headers=headers) | |
print(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment