Documentation ¶
Overview ¶
Package googlechat implements the Google Chat API used by Cogito.
See the README and CONTRIBUTING files for additional information and reference to official documentation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RedactErrorURL ¶
RedactErrorURL returns a _best effort_ redacted copy of err. See RedactURL for caveats and limitations. In case err is not of type url.Error, then it returns the error untouched.
Taken from https://github.com/marco-m/lanterna
func RedactURL ¶
RedactURL returns a _best effort_ redacted copy of theURL.
Use this workaround only when you are forced to use an API that encodes secrets in the URL instead of setting them in the request header. If you have control of the API, please never encode secrets in the URL.
Redaction is applied as follows: - removal of all query parameters - removal of "username:password@" HTTP Basic Authentication
Warning: it is still possible that the redacted URL contains secrets, for example if the secret is encoded in the path. Don't do this.
Taken from https://github.com/marco-m/lanterna
func RedactURLString ¶
RedactURLString returns a _best effort_ redacted copy of theURL. See RedactURL for caveats and limitations. In case theURL cannot be parsed, then return the parse error string.
Taken from https://github.com/marco-m/lanterna
Types ¶
type BasicMessage ¶ added in v0.8.0
type BasicMessage struct {
Text string `json:"text"`
}
BasicMessage is the request for a Google Chat basic message.
type MessageReply ¶ added in v0.8.1
type MessageReply struct { Name string `json:"name"` // Absolute message ID. Sender MessageSender `json:"sender"` Text string `json:"text"` // The message text, as sent. Thread MessageThread `json:"thread"` Space MessageSpace `json:"space"` CreateTime time.Time `json:"createTime"` }
MessageReply is the reply to TextMessage. Compared to the full API reply, some uninteresting fields are removed.
func TextMessage ¶
func TextMessage(ctx context.Context, theURL, threadKey, text string) (MessageReply, error)
TextMessage sends the one-off message `text` with `threadKey` to webhook `theURL` and returns an abridged response.
Note that the Google Chat API encodes the secret in the webhook itself.
Implementation note: if instead we need to send multiple messages, we should reuse the http.Client, so we should add another API function to do so.
References: REST Resource: v1.spaces.messages https://developers.google.com/chat/api/reference/rest webhooks: https://developers.google.com/chat/how-tos/webhooks payload: https://developers.google.com/chat/api/guides/message-formats/basic threadKey: https://developers.google.com/chat/reference/rest/v1/spaces.messages/create
type MessageSender ¶ added in v0.8.1
type MessageSender struct { Name string `json:"name"` // Absolute user ID. DisplayName string `json:"displayName"` // Name of the webhook in the UI. Type string `json:"type"` // "BOT", ... }
MessageSender is part of MessageReply. Compared to the full API reply, some uninteresting fields are removed.
type MessageSpace ¶ added in v0.8.1
type MessageSpace struct { Name string `json:"name"` // Absolute space ID. Type string `json:"type"` // "ROOM", ... Threaded bool `json:"threaded"` // Has the space been created as "threaded"? DisplayName string `json:"displayName"` // Name of the space in the UI. }
MessageSpace is part of MessageReply. Compared to the full API reply, some uninteresting fields are removed.
type MessageThread ¶ added in v0.8.1
type MessageThread struct {
Name string `json:"name"` // Absolute thread ID.
}
MessageThread is part of MessageReply. Compared to the full API reply, some uninteresting fields are removed.