function

package module
v0.0.0-...-94717a0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 14 Imported by: 0

README

clubhouse-to-discord

This project is no longer maintained, and has been replaced with https://github.com/Courtsite/shortcut-to-teams

📝 A simple Google Cloud Function in Go to transform / proxy Clubhouse (Project Management) webhooks to Discord.

This project is still under development, and it does not handle many cases. It has been tested with the Go 1.13 runtime.

Webhook in Discord

Getting Started

Prerequisites
  • Ensure you have gcloud installed:
  • Ensure you have authenticated with Google Cloud: gcloud init
  • (Optional) Set your current working project: gcloud config set project <project>
Deployment
  1. Clone / download a copy of this repository
  2. Copy .env.sample.yaml to .env.yaml, and modify the environment variables declared in the file
  3. Run ./deploy.sh
  4. Configure Clubhouse webhooks integration in https://app.clubhouse.io/<workspace>/settings/integrations/outgoing-webhook

Clubhouse's Generic Outgoing Webhook Integration

Clubhouse Generate API Token

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func F

Types

type ClubhouseAction

type ClubhouseAction struct {
	Action          string           `json:"action"`
	AppURL          string           `json:"app_url"`
	AuthorID        string           `json:"author_id"`
	Changes         ClubhouseChanges `json:"changes"`
	Complete        bool             `json:"complete,omitempty"`
	Description     string           `json:"description"`
	EntityType      string           `json:"entity_type"`
	EpicID          int              `json:"epic_id"`
	Estimate        int              `json:"estimate,omitempty"`
	FollowerIds     []string         `json:"follower_ids"`
	ID              int              `json:"id"`
	IterationID     int              `json:"iteration_id"`
	MilestoneID     int              `json:"milestone_id"`
	Name            string           `json:"name"`
	OwnerIds        []string         `json:"owner_ids"`
	Position        int64            `json:"position"`
	ProjectID       int              `json:"project_id"`
	RequestedByID   string           `json:"requested_by_id"`
	StoryType       string           `json:"story_type"`
	TaskIds         []int            `json:"task_ids,omitempty"`
	Town            *string          `json:"town,omitempty"`
	Text            string           `json:"text"`
	URL             string           `json:"url"`
	WorkflowStateID int              `json:"workflow_state_id"`
}

type ClubhouseApiClient

type ClubhouseApiClient struct {
	ApiToken string
}

func (*ClubhouseApiClient) GetMember

func (c *ClubhouseApiClient) GetMember(memberPublicID string) (*GetMemberResponse, error)

type ClubhouseChanges

type ClubhouseChanges struct {
	Archived *struct {
		New bool `json:"new"`
		Old bool `json:"old"`
	} `json:"archived,omitempty"`
	Blocker *struct {
		New bool `json:"new"`
		Old bool `json:"old"`
	} `json:"blocker,omitempty"`
	CommentIds *struct {
		Adds    []int `json:"adds"`
		Removes []int `json:"removes"`
	} `json:"comment_ids,omitempty"`
	Completed *struct {
		New bool `json:"new"`
		Old bool `json:"old"`
	} `json:"completed,omitempty"`
	CompletedAt *struct {
		New time.Time `json:"new"`
	} `json:"completed_at,omitempty"`
	Deadline *struct {
		New *time.Time `json:"new,omitempty"`
		Old *time.Time `json:"old,omitempty"`
	} `json:"deadline,omitempty"`
	EpicID *struct {
		New *int `json:"new,omitempty"`
		Old *int `json:"old,omitempty"`
	} `json:"epic_id,omitempty"`
	Estimate *struct {
		New *int `json:"new,omitempty"`
		Old *int `json:"old,omitempty"`
	} `json:"estimate,omitempty"`
	FollowerIds *struct {
		Adds []string `json:"adds"`
	} `json:"follower_ids,omitempty"`
	IterationID *struct {
		New *int `json:"new,omitempty"`
		Old *int `json:"old,omitempty"`
	} `json:"iteration_id,omitempty"`
	LabelIds *struct {
		Adds    []int `json:"adds"`
		Removes []int `json:"removes"`
	} `json:"label_ids,omitempty"`
	OwnerIds *struct {
		Adds    []string `json:"adds"`
		Removes []string `json:"removes"`
	} `json:"owner_ids,omitempty"`
	Position *struct {
		New int64 `json:"new"`
		Old int64 `json:"old"`
	} `json:"position,omitempty"`
	ProjectID *struct {
		New int `json:"new"`
		Old int `json:"old"`
	} `json:"project_id,omitempty"`
	Started *struct {
		New bool `json:"new"`
		Old bool `json:"old"`
	} `json:"started,omitempty"`
	StartedAt *struct {
		New time.Time `json:"new"`
	} `json:"started_at,omitempty"`
	StoryType *struct {
		New string `json:"new"`
		Old string `json:"old"`
	} `json:"story_type,omitempty"`
	Text *struct {
		New string `json:"new"`
		Old string `json:"old"`
	} `json:"text,omitempty"`
	WorkflowStateID *struct {
		New int `json:"new"`
		Old int `json:"old"`
	} `json:"workflow_state_id,omitempty"`
}

type ClubhouseReference

type ClubhouseReference struct {
	AppURL     string `json:"app_url"`
	EntityType string `json:"entity_type"`
	ID         int    `json:"id"`
	Name       string `json:"name"`
	Type       string `json:"type"`
}

type ClubhouseWebhook

type ClubhouseWebhook struct {
	Actions    []ClubhouseAction    `json:"actions"`
	ChangedAt  time.Time            `json:"changed_at"`
	ID         string               `json:"id"`
	MemberID   string               `json:"member_id"`
	PrimaryID  int                  `json:"primary_id"`
	References []ClubhouseReference `json:"references"`
	Paper      *string              `json:"paper,omitempty"`
	Version    string               `json:"version"`
}

Expanded from https://clubhouse.io/api/webhook/v1/#Webhook-Format

type DiscordWebhook

type DiscordWebhook struct {
	Content string  `json:"content"`
	Embeds  []Embed `json:"embeds,omitempty"`
}

type Embed

type Embed struct {
	Title       string  `json:"title"`
	URL         string  `json:"url"`
	Description string  `json:"description"`
	Color       int     `json:"color"`
	Fields      []Field `json:"fields,omitempty"`
}

type Field

type Field struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Inline bool   `json:"inline"`
}

type GetMemberResponse

type GetMemberResponse struct {
	CreatedAt  time.Time `json:"created_at"`
	Disabled   bool      `json:"disabled"`
	EntityType string    `json:"entity_type"`
	GroupIds   []string  `json:"group_ids"`
	ID         string    `json:"id"`
	Profile    struct {
		Deactivated bool `json:"deactivated"`
		DisplayIcon struct {
			CreatedAt  time.Time `json:"created_at"`
			EntityType string    `json:"entity_type"`
			ID         string    `json:"id"`
			UpdatedAt  time.Time `json:"updated_at"`
			URL        string    `json:"url"`
		} `json:"display_icon"`
		EmailAddress           string `json:"email_address"`
		EntityType             string `json:"entity_type"`
		GravatarHash           string `json:"gravatar_hash"`
		ID                     string `json:"id"`
		MentionName            string `json:"mention_name"`
		Name                   string `json:"name"`
		TwoFactorAuthActivated bool   `json:"two_factor_auth_activated"`
	} `json:"profile"`
	Role      string    `json:"role"`
	UpdatedAt time.Time `json:"updated_at"`
}

https://clubhouse.io/api/rest/v3/#Get-Member

type OverallAction

type OverallAction int
const (
	OverallAction_UNKNOWN OverallAction = iota
	OverallAction_Create
	OverallAction_Update
)

Jump to

Keyboard shortcuts

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