googlechat

package
v0.0.0-...-2b053e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(config *Config)

Run reads the config, establishes OAuth connection & Pub/Sub subscription to the message queue

Types

type ChatMessage

type ChatMessage struct {
	Type      string    `json:"type"`
	EventTime time.Time `json:"eventTime"`
	Token     string    `json:"token"`
	Message   struct {
		Name   string `json:"name"`
		Sender struct {
			Name        string `json:"name"`
			DisplayName string `json:"displayName"`
			AvatarURL   string `json:"avatarUrl"`
			Email       string `json:"email"`
			Type        string `json:"type"`
		} `json:"sender"`
		CreateTime time.Time `json:"createTime"`
		Text       string    `json:"text"`
		Thread     struct {
			Name              string `json:"name"`
			RetentionSettings struct {
				State string `json:"state"`
			} `json:"retentionSettings"`
		} `json:"thread"`
		Space struct {
			Name string `json:"name"`
			Type string `json:"type"`
		} `json:"space"`
		ArgumentText string `json:"argumentText"`
	} `json:"message"`
	User struct {
		Name        string `json:"name"`
		DisplayName string `json:"displayName"`
		AvatarURL   string `json:"avatarUrl"`
		Email       string `json:"email"`
		Type        string `json:"type"`
	} `json:"user"`
	Space struct {
		Name        string `json:"name"`
		Type        string `json:"type"`
		DisplayName string `json:"displayName"`
	} `json:"space"`
	ConfigCompleteRedirectURL string `json:"configCompleteRedirectUrl"`
}

ChatMessage is message type from Pub/Sub events

type Config

type Config struct {
	PubSubProject    string
	TopicName        string
	SubscriptionName string
	WelcomeMessage   string
}

Config must contain basic configuration for the bot to be able to work

type ReplyMessage

type ReplyMessage struct {
	Text   string       `json:"text"`
	Thread *ReplyThread `json:"thread,omitempty"`
}

ReplyMessage is partial hangouts format of messages used For details see https://developers.google.com/hangouts/chat/reference/rest/v1/spaces.messages#Message

type ReplyThread

type ReplyThread struct {
	Name string `json:"name,omitempty"`
}

ReplyThread is a part of reply messages

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL