67 lines
1.8 KiB
Markdown
67 lines
1.8 KiB
Markdown
|
# Go Google Space Bot
|
||
|
|
||
|
A simple Go application to send messages to a Google Chat space using its webhook URL.
|
||
|
|
||
|
## Prerequisites
|
||
|
|
||
|
To use this application, ensure you have the following installed:
|
||
|
1. Go version `1.23` or later.
|
||
|
2. A properly configured `.env` file with the following variables:
|
||
|
- `SPACE_ID`: The ID of the Google Chat space you want to send messages to.
|
||
|
- `KEY`: The key provided in your Google Chat webhook URL.
|
||
|
- `TOKEN`: The token provided in your Google Chat webhook URL.
|
||
|
|
||
|
For more info on setting up Google Chat webhooks, see [Sending Chat messages using webhooks](https://developers.google.com/chat/how-tos/webhooks).
|
||
|
|
||
|
## Installation
|
||
|
|
||
|
Clone this repository, navigate into the directory, and build the project:
|
||
|
|
||
|
```bash
|
||
|
git clone <repository-url>
|
||
|
cd go-google-space
|
||
|
go build -o go-google-space
|
||
|
```
|
||
|
|
||
|
## Configuration
|
||
|
|
||
|
Create a `.env` file in the root directory with the following contents:
|
||
|
|
||
|
```dotenv
|
||
|
SPACE_ID=<your-space-id>
|
||
|
KEY=<your-key>
|
||
|
TOKEN=<your-token>
|
||
|
```
|
||
|
|
||
|
Replace `<your-space-id>`, `<your-key>`, and `<your-token>` with the respective values from your Google Chat webhook URL.
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
Run the built executable, passing the message you want to send as an argument:
|
||
|
|
||
|
```bash
|
||
|
./go-google-space "Hello, Google Chat!"
|
||
|
```
|
||
|
|
||
|
## Example Output
|
||
|
|
||
|
When the command runs successfully, the message will appear in your configured Google Chat space.
|
||
|
|
||
|
If any errors occur (e.g., if the `.env` file is missing or the webhook URL configuration is incorrect), error messages will be displayed in the terminal.
|
||
|
|
||
|
## Dependencies
|
||
|
|
||
|
This project uses the following dependencies:
|
||
|
- [godotenv](https://github.com/joho/godotenv) for loading environment variables from a `.env` file.
|
||
|
|
||
|
To install the dependency, run:
|
||
|
|
||
|
```bash
|
||
|
go get github.com/joho/godotenv
|
||
|
```
|
||
|
|
||
|
## License
|
||
|
|
||
|
This project is licensed under the MIT License. See the LICENSE file for details.
|
||
|
|
||
|
---
|