| 1 |
// Package googlechat provides a service for sending notifications to Google Chat spaces via webhooks. |
| 2 |
// |
| 3 |
// The Google Chat service supports webhook integration for sending plain text messages |
| 4 |
// to Google Chat spaces using the Google Chat API. |
| 5 |
// |
| 6 |
// # URL Format |
| 7 |
// |
| 8 |
// The service URL follows the format: |
| 9 |
// |
| 10 |
// googlechat://chat.googleapis.com/v1/spaces/SPACE_ID/messages?key=KEY&token=TOKEN |
| 11 |
// |
| 12 |
// Where: |
| 13 |
// - SPACE_ID: The Google Chat space ID (included in the Path) |
| 14 |
// - KEY: The API key for authentication |
| 15 |
// - TOKEN: The webhook token for authentication |
| 16 |
// |
| 17 |
// # Basic Usage |
| 18 |
// |
| 19 |
// import "github.com/nicholas-fedor/shoutrrr/pkg/services/chat/googlechat" |
| 20 |
// |
| 21 |
// service := &googlechat.Service{} |
| 22 |
// err := service.Initialize(url, logger) |
| 23 |
// if err != nil { |
| 24 |
// // handle error |
| 25 |
// } |
| 26 |
// err = service.Send("Hello, Google Chat!", nil) |
| 27 |
// |
| 28 |
// # Configuration Options |
| 29 |
// |
| 30 |
// The service supports configuration via URL components: |
| 31 |
// |
| 32 |
// - Host: The API host (default: "chat.googleapis.com") |
| 33 |
// - Path: The webhook path including the space ID |
| 34 |
// - Key: The API key for authentication (query parameter) |
| 35 |
// - Token: The webhook token for authentication (query parameter) |
| 36 |
// |
| 37 |
// # Obtaining Webhook Credentials |
| 38 |
// |
| 39 |
// To obtain the webhook URL and credentials: |
| 40 |
// |
| 41 |
// 1. Open your Google Chat space |
| 42 |
// 2. Click the space name and select "Apps & integrations" |
| 43 |
// 3. Click "Add webhooks" |
| 44 |
// 4. Configure the webhook name and avatar (optional) |
| 45 |
// 5. Copy the webhook URL |
| 46 |
// 6. Extract the key and token from the URL query parameters |
| 47 |
// |
| 48 |
// # Important Notes |
| 49 |
// |
| 50 |
// - The service requires both key and token for authentication |
| 51 |
// - Messages are sent as plain text via the Google Chat API |
| 52 |
// - The API host defaults to "chat.googleapis.com" if not specified |
| 53 |
// - Webhook URLs can be obtained from Google Chat space settings |
| 54 |
// - The service returns ErrUnexpectedStatus for non-2xx HTTP responses |
| 55 |
// - Message formatting is limited to plain text (no rich formatting) |
| 56 |
package googlechat |