discord

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewApp

func NewApp(conf *Config) *common.BaseApp

NewApp initializes a new teleport-discord app and returns it.

Types

type ChatMsgResponse

type ChatMsgResponse struct {
	DiscordResponse
	Channel   string `json:"channel_id"`
	Text      string `json:"content"`
	DiscordID string `json:"id"`
}

type Config

type Config struct {
	common.BaseConfig
	Discord common.GenericAPIConfig

	// Teleport is a handle to the client to use when communicating with
	// the Teleport auth server. The PagerDuty app will create a GRPC-
	// based client on startup if this is not set.
	Client teleport.Client

	// StatusSink receives any status updates from the plugin for
	// further processing. Status updates will be ignored if not set.
	StatusSink common.StatusSink
}

func (*Config) CheckAndSetDefaults

func (c *Config) CheckAndSetDefaults() error

CheckAndSetDefaults checks the config struct for any logical errors, and sets default values if some values are missing. If critical values are missing and we can't set defaults for them — this will return an error.

func (*Config) GetTeleportClient

func (c *Config) GetTeleportClient(ctx context.Context) (teleport.Client, error)

GetTeleportClient implements PluginConfiguration. If a pre-created client was supplied on construction, this method will return that. If not, an RPC client will be created using the values in the config.

func (*Config) NewBot

func (c *Config) NewBot(clusterName, webProxyAddr string) (common.MessagingBot, error)

NewBot initializes the new Discord message generator (DiscordBot)

type DiscordBot

type DiscordBot struct {
	// contains filtered or unexported fields
}

DiscordBot is a discord client that works with AccessRequest. It's responsible for formatting and posting a message on Discord when an action occurs with an access request: a new request popped up, or a request is processed/updated.

func (DiscordBot) BroadcastAccessRequestMessage

func (b DiscordBot) BroadcastAccessRequestMessage(ctx context.Context, recipients []common.Recipient, reqID string, reqData pd.AccessRequestData) (accessrequest.SentMessages, error)

BroadcastAccessRequestMessage posts request info to Discord.

func (DiscordBot) CheckHealth

func (b DiscordBot) CheckHealth(ctx context.Context) error

func (DiscordBot) FetchRecipient

func (b DiscordBot) FetchRecipient(ctx context.Context, name string) (*common.Recipient, error)

func (DiscordBot) PostReviewReply

func (b DiscordBot) PostReviewReply(ctx context.Context, channelID, timestamp string, review types.AccessReview) error

PostReviewReply does nothing as Discord does not have threaded replies

func (DiscordBot) SendReviewReminders

func (b DiscordBot) SendReviewReminders(ctx context.Context, recipients []common.Recipient, accessList *accesslist.AccessList) error

SendReviewReminders will send a review reminder that an access list needs to be reviewed.

func (DiscordBot) SupportedApps

func (b DiscordBot) SupportedApps() []common.App

SupportedApps are the apps supported by this bot.

func (DiscordBot) UpdateMessages

func (b DiscordBot) UpdateMessages(ctx context.Context, reqID string, reqData pd.AccessRequestData, messagingData accessrequest.SentMessages, reviews []types.AccessReview) error

UpdateMessages updates already posted Discord messages

type DiscordEmbed

type DiscordEmbed struct {
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	Color       int    `json:"color,omitempty"`
	Author      struct {
		Name string `json:"name"`
	} `json:"author,omitempty"`
}

type DiscordMsg

type DiscordMsg struct {
	Msg
	Text   string         `json:"content,omitempty"`
	Embeds []DiscordEmbed `json:"embeds,omitempty"`
}

type DiscordResponse

type DiscordResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message,omitempty"`
}

type Msg

type Msg struct {
	Channel   string `json:"channel,omitempty"`
	User      string `json:"user,omitempty"`
	Username  string `json:"username,omitempty"`
	DiscordID string `json:"id,omitempty"`
}

Jump to

Keyboard shortcuts

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