gitcord

package
v0.0.0-...-39763c8 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultColorScheme = ColorScheme{}

DefaultColorScheme is the default color scheme.

View Source
var DefaultStatusColors = StatusColors{
	Success: 0x00FF00,
	Error:   0xFF0000,
}

Functions

This section is empty.

Types

type Client

type Client struct {
	Issues         *IssuesClient
	Comments       *IssueCommentClient
	PRs            *PRsClient
	Reviews        *ReviewsClient
	ReviewComments *ReviewCommentsClient
	ReviewThreads  *ReviewThreadsClient
	// contains filtered or unexported fields
}

Client is the GitHub-Discord bot.

func NewClient

func NewClient(cfg Config) *Client

NewClient creates a new Client instance.

func (*Client) DoEvent

func (c *Client) DoEvent(ev *github.Event) error

DoEvent handles a GitHub event.

func (*Client) DoEventID

func (c *Client) DoEventID(id int64) error

DoEventID handles a GitHub event by ID.

https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types

func (*Client) DoEventPayload

func (c *Client) DoEventPayload(name, plStr string) error

func (*Client) WithContext

func (c *Client) WithContext(ctx context.Context) *Client

WithContext returns a new Client with the given context.

type ColorScheme

type ColorScheme map[ColorSchemeKey]StatusColors

ColorScheme describes the color scheme for all embed colors made by gitcord. It maps each color scheme key to a status color struct, which has two possible colors for two cases.

By default, all color scheme keys ap to DefaultStatusColors.

func (ColorScheme) Color

func (s ColorScheme) Color(k ColorSchemeKey, success bool) discord.Color

Color gets the color corresponding to the given key. If success is true, then the Success color is used, else Error is used.

func (ColorScheme) Override

func (s ColorScheme) Override(with ColorScheme) ColorScheme

Override creates a new ColorScheme that overrides all color keys inside s with the provided ones in with.

type ColorSchemeKey

type ColorSchemeKey uint

ColorSchemeKey is the key for a color within a color scheme.

const (
	UnknownColorSchemeKey ColorSchemeKey = iota
	IssueOpened
	IssueClosed
	IssueReopened
	IssueLabeled
	IssueUnlabeled
	IssueAssigned
	IssueUnassigned
	IssueMilestoned
	IssueDemilestoned
	IssueDeleted
	IssueLocked
	IssueUnlocked
	IssueTransferred
	IssueCommented
	IssueCommentDeleted
	PROpened
	PRReopened
	PRCommented
	PRClosed
	PRAssigned
	PRUnassigned
	PRDeleted
	PRTransferred
	PRLabeled
	PRUnlabeled
	PRMilestoned
	PRDemilestoned
	PRLocked
	PRUnlocked
	PRReviewRequested
	PRReviewRequestRemoved
	PRReadyForReview
	Reviewed
	ReviewDismissed
	ReviewCommented
	ReviewCommentDeleted
	ReviewThreaded
	ReviewThreadResolved
	ReviewThreadUnresolved
)

type Config

type Config struct {
	// GitHubOAuth is the GitHub OAuth token
	GitHubOAuth oauth2.TokenSource
	// DiscordToken is the Discord bot token
	DiscordToken string
	// DiscordChannelID is the ID of the parent channel in which all threads
	// will be created under
	DiscordChannelID discord.ChannelID
	// ColorScheme is the color scheme for use in embeds. Refer to ColorScheme
	// for more information.
	ColorScheme ColorScheme
	// ForceOpen will force create a new thread even if one already exists
	ForceOpen bool
	// Logger is the logger to use. If nil, the default logger will be used
	Logger *log.Logger
}

Config is the configuration for the Client

type IssueCommentClient

type IssueCommentClient client

func (*IssueCommentClient) EditIssueCommentMsg

func (c *IssueCommentClient) EditIssueCommentMsg(ev *github.IssueCommentEvent) error

func (*IssueCommentClient) EmbedDeletedMsg

func (c *IssueCommentClient) EmbedDeletedMsg(ev *github.IssueCommentEvent) error

func (*IssueCommentClient) EmbedIssueCommentMsg

func (c *IssueCommentClient) EmbedIssueCommentMsg(ev *github.IssueCommentEvent) error

type IssuesClient

type IssuesClient client

func (*IssuesClient) EditInitialMsg

func (c *IssuesClient) EditInitialMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedAssignedMsg

func (c IssuesClient) EmbedAssignedMsg(ev *github.IssuesEvent) error

func (*IssuesClient) EmbedClosedMsg

func (c *IssuesClient) EmbedClosedMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedDeletedMsg

func (c IssuesClient) EmbedDeletedMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedDemilestonedMsg

func (c IssuesClient) EmbedDemilestonedMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedLabeledMsg

func (c IssuesClient) EmbedLabeledMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedLockedMsg

func (c IssuesClient) EmbedLockedMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedMilestonedMsg

func (c IssuesClient) EmbedMilestonedMsg(ev *github.IssuesEvent) error

func (*IssuesClient) EmbedReopenedMsg

func (c *IssuesClient) EmbedReopenedMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedTransferredMsg

func (c IssuesClient) EmbedTransferredMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedUnassignedMsg

func (c IssuesClient) EmbedUnassignedMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedUnlabeledMsg

func (c IssuesClient) EmbedUnlabeledMsg(ev *github.IssuesEvent) error

func (IssuesClient) EmbedUnlockedMsg

func (c IssuesClient) EmbedUnlockedMsg(ev *github.IssuesEvent) error

func (*IssuesClient) OpenAndEmbedInitialMsg

func (c *IssuesClient) OpenAndEmbedInitialMsg(ev *github.IssuesEvent) error

type PRThreadError

type PRThreadError struct {
	PR  int
	Err error
}

PRThreadError is returned when a pull request does not have a thread.

func (*PRThreadError) Error

func (err *PRThreadError) Error() string

func (*PRThreadError) Unwrap

func (err *PRThreadError) Unwrap() error

type PRThreadExistsError

type PRThreadExistsError struct {
	PR     int
	Thread discord.Channel
}

PRThreadExistsError is returned when a pull request already has a thread.

func (*PRThreadExistsError) Error

func (err *PRThreadExistsError) Error() string

type PRsClient

type PRsClient client

func (*PRsClient) EditInitialMsg

func (c *PRsClient) EditInitialMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedAssignedMsg

func (c PRsClient) EmbedAssignedMsg(ev *github.PullRequestEvent) error

func (*PRsClient) EmbedClosedMsg

func (c *PRsClient) EmbedClosedMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedDeletedMsg

func (c PRsClient) EmbedDeletedMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedDemilestonedMsg

func (c PRsClient) EmbedDemilestonedMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedLabeledMsg

func (c PRsClient) EmbedLabeledMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedLockedMsg

func (c PRsClient) EmbedLockedMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedMilestonedMsg

func (c PRsClient) EmbedMilestonedMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedReadyForReviewMsg

func (c PRsClient) EmbedReadyForReviewMsg(ev *github.PullRequestEvent) error

func (*PRsClient) EmbedReopenedMsg

func (c *PRsClient) EmbedReopenedMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedReviewRequestRemovedMsg

func (c PRsClient) EmbedReviewRequestRemovedMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedReviewRequestedMsg

func (c PRsClient) EmbedReviewRequestedMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedTransferredMsg

func (c PRsClient) EmbedTransferredMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedUnassignedMsg

func (c PRsClient) EmbedUnassignedMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedUnlabeledMsg

func (c PRsClient) EmbedUnlabeledMsg(ev *github.PullRequestEvent) error

func (PRsClient) EmbedUnlockedMsg

func (c PRsClient) EmbedUnlockedMsg(ev *github.PullRequestEvent) error

func (*PRsClient) OpenAndEmbedInitialMsg

func (c *PRsClient) OpenAndEmbedInitialMsg(ev *github.PullRequestEvent) error

type ReviewCommentsClient

type ReviewCommentsClient client

func (ReviewCommentsClient) EditReviewCommentMsg

func (c ReviewCommentsClient) EditReviewCommentMsg(ev *github.PullRequestReviewCommentEvent) error

func (ReviewCommentsClient) EmbedReviewCommentDeletedMsg

func (c ReviewCommentsClient) EmbedReviewCommentDeletedMsg(ev *github.PullRequestReviewCommentEvent) error

func (ReviewCommentsClient) EmbedReviewCommentMsg

func (c ReviewCommentsClient) EmbedReviewCommentMsg(ev *github.PullRequestReviewCommentEvent) error

type ReviewThreadsClient

type ReviewThreadsClient client

func (ReviewThreadsClient) EditReviewThreadMsg

func (c ReviewThreadsClient) EditReviewThreadMsg(ev *github.PullRequestReviewThreadEvent) error

func (ReviewThreadsClient) EmbedReviewThreadMsg

func (c ReviewThreadsClient) EmbedReviewThreadMsg(ev *github.PullRequestReviewThreadEvent) error

func (ReviewThreadsClient) EmbedReviewThreadResolvedMsg

func (c ReviewThreadsClient) EmbedReviewThreadResolvedMsg(ev *github.PullRequestReviewThreadEvent) error

func (ReviewThreadsClient) EmbedReviewThreadUnresolvedMsg

func (c ReviewThreadsClient) EmbedReviewThreadUnresolvedMsg(ev *github.PullRequestReviewThreadEvent) error

type ReviewsClient

type ReviewsClient client

func (ReviewsClient) EditReviewMsg

func (c ReviewsClient) EditReviewMsg(ev *github.PullRequestReviewEvent) error

func (ReviewsClient) EmbedReviewDismissedMsg

func (c ReviewsClient) EmbedReviewDismissedMsg(ev *github.PullRequestReviewEvent) error

func (*ReviewsClient) EmbedReviewMsg

func (c *ReviewsClient) EmbedReviewMsg(ev *github.PullRequestReviewEvent) error

type StatusColors

type StatusColors struct {
	Success discord.Color
	Error   discord.Color
}

Directories

Path Synopsis
internal
slices
Package slices contains convenient generic functions for slices.
Package slices contains convenient generic functions for slices.

Jump to

Keyboard shortcuts

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