A simple python package to send messages to Google Chats via Webhooks
Project description
PyGoChook
A simple Python wrapper to send message to Google Chats.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
About The Project
Python Google Chat Webhook is a simple Python wrapper to send messages to Google Chat via their Incoming Webhooks (https://developers.google.com/hangouts/chat/how-tos/webhooks). As for now Google Chat is only available for G Suite Customers.
Getting Started
Requirements
The package depends on the following packages:
Installation
Install the package via pip
pip install pygochook
Usage
Send a message to a Google Chat...
>>> import pygochook
>>> message = "This is awesome!"
>>> gchat_webhook_url = "https://chat.googleapis.com/..."
>>> gchat_msg_sender = pygochook.MsgSender(message, gchat_webhook_url)
>>> gchat_msg_sender.send()
[{...}] # response message from google chat
Or send a message to multiple Google Chats...
>>> import pygochook
>>> message = "This is awesome! I can send even to multiple chats!"
>>> gchat_webhook_urls = ["https://chat.googleapis.com/...", "https://chat.googleapis.com/..."]
>>> gchat_msg_sender = pygochook.MsgSender(message, gchat_webhook_urls)
>>> gchat_msg_sender.send()
[{...}, {...}] # response message from google chat
With the use of aiohttp the requests will be performed asynchronously. Hence, it does not matter if you send the message to one or multiple Google Chats with respect to response time. An example:
>>> import pygochook
>>> @timer
... def to_one_chat(msg, url):
... gchat_sender = pygochook.MsgSender(msg, url)
... return gchat_sender.send()
...
>>> @timer
... def to_multi_chats(msg, urls):
... gchat_sender = pygochook.MsgSender(msg, urls)
... return gchat_sender.send()
...
>>> message = "Time does not even matter!"
>>> url = "https://chat.googleapis.com/..."
>>> urls = ["https://chat.googleapis.com/...", ..., "https://chat.googleapis.com/..."] # 10 Chat API-URLs
>>>
>>> to_one_chat(message, url) # send to one chat
Total execution time: 454 ms
>>>
>>> to_multi_chat(message, url) # send to 10 chats
Total execution time: 2007 ms
Because of the asynchronous structure, the total function execution time is as long as the longest response time.
Roadmap
See the open issues for a list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE for more information.
Contact
Project Link: https://github.com/Lars147/pygochook
Acknowledgements
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygochook-0.0.2.tar.gz.
File metadata
- Download URL: pygochook-0.0.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93c293125efa97752a1fd12cc6a97fd70d184be3bfdcc638142515e72fdf9941
|
|
| MD5 |
12fac0a92289f9ee41e57b94f9e343f8
|
|
| BLAKE2b-256 |
de002ddda9a7a834ef2ef3479933c3dea97df3eb8de11ea26816a93bc52f1d11
|
File details
Details for the file pygochook-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pygochook-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3c22b3732a26b4099f3932e6653c0e54acb11157920c333c560a5809d6ede5f
|
|
| MD5 |
ec7fbf510d4d3e9c0f5deded15e00a15
|
|
| BLAKE2b-256 |
344898f60fc83d6e125719bb028abcf4decddc7e50d5674662b8079270fad46e
|