Skip to main content

Contributors Forks Stargazers Issues MIT License


PyGoChook

A simple Python wrapper to send message to Google Chats.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgements

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Project Link: https://github.com/Lars147/pygochook

Acknowledgements

Metadata

Release files for pygochook 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygochook 0.0.2
File Size Uploaded
pygochook-0.0.2.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygochook 0.0.2
File Interpreter ABI Platform
pygochook-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / pygochook-0.0.2.tar.gz

Download URL pygochook-0.0.2.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
93c293125efa97752a1fd12cc6a97fd70d184be3bfdcc638142515e72fdf9941
BLAKE2b-256 checksum
How to use checksums
de002ddda9a7a834ef2ef3479933c3dea97df3eb8de11ea26816a93bc52f1d11
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pygochook-0.0.2-py3-none-any.whl

Download URL pygochook-0.0.2-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3c22b3732a26b4099f3932e6653c0e54acb11157920c333c560a5809d6ede5f
BLAKE2b-256 checksum
How to use checksums
344898f60fc83d6e125719bb028abcf4decddc7e50d5674662b8079270fad46e
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page