github

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package github exposes the GitHub constructor, the raw-event accessors, and the Config/Message types for botbooter. Import it for a GitHub issue-ops bot: the adapter receives issue and PR comments over an issue_comment webhook and replies as issue comments through the GitHub REST API. Emoji reactions have no webhook, so OnReaction is fed by an opt-in poller over each Config.ReactionPollRepos entry's newest comments; the poller runs only when both repos are listed and an OnReaction handler was registered before the bot connects. A GitHub-only binary pulls in go-github and ghinstallation but never compiles discordgo, slack-go or go-telegram.

Index

Constants

This section is empty.

Variables

View Source
var ErrAmbiguousAuth = githubint.ErrAmbiguousAuth

ErrAmbiguousAuth is returned by New when both auth modes are configured.

View Source
var ErrBadChannelID = githubint.ErrBadChannelID

ErrBadChannelID is returned by a GitHub bot's Send when the channel ID is not "owner/repo#number". Branch it with errors.Is.

View Source
var ErrBadReactionConfig = githubint.ErrBadReactionConfig

ErrBadReactionConfig is returned by New when a reaction-polling Config field is malformed: a ReactionPollRepos entry that is not "owner/name" or the wildcard "owner/*", or a negative ReactionPollInterval.

View Source
var ErrMissingConfig = githubint.ErrMissingConfig

ErrMissingConfig is returned by New when a required Config field is empty.

Functions

func Addr

func Addr(b *botbooter.Bot) string

Addr returns the address b's webhook listener is bound to (host:port), or "" if b is not a GitHub bot or is not connected. Use it to recover the OS-assigned port after passing cfg.Addr ":0".

func Client

func Client(b *botbooter.Bot) *gogithub.Client

Client returns the underlying go-github client, or nil if b is not a GitHub bot. Use it for API calls beyond the adapter's send path (labels, reactions, checks).

func New

func New(cfg Config) (*botbooter.Bot, error)

New creates a GitHub bot. It runs an inbound webhook HTTP server at cfg.Addr, so put a TLS-terminating proxy in front and register the public HTTPS URL as the repository or App webhook (content type application/json, issue_comment events, with cfg.WebhookSecret). It returns ErrMissingConfig or ErrAmbiguousAuth on invalid config.

Types

type Config

type Config = githubint.Config

Config configures a GitHub bot. Exactly one auth mode must be set: Token (PAT) or the AppID/InstallationID/PrivateKey triple (GitHub App).

type Message

type Message = githubint.Message

Message is the typed raw payload of an inbound issue_comment event.

func RawEvent

func RawEvent(m *botbooter.Message) (*Message, bool)

RawEvent returns the typed issue_comment event carried on m, reporting whether m originated from GitHub.

type ReactionPayload

type ReactionPayload = githubint.ReactionPayload

ReactionPayload is the typed raw payload of a polled emoji reaction: the reaction and the issue comment it was added to. GitHub sends no webhook for reactions, so the adapter discovers them by polling when Config.ReactionPollRepos is set.

func RawReaction

func RawReaction(r *botbooter.Reaction) (*ReactionPayload, bool)

RawReaction returns the typed reaction payload carried on r, reporting whether r originated from GitHub. RawReaction(r).Reaction.GetContent gives the bare REST content name ("+1", "hooray") behind the unicode Emoji.

Jump to

Keyboard shortcuts

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